Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 44 additions & 111 deletions docs/service/mllm_cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This document describes the MLLM command-line interface (CLI) tool, which operat

**Currently, the system officially supports the following models:**

* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai``
* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify model list formatting.

The comma-separated list of models within a single code literal (mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai) may confuse readers about whether this is a literal string to use somewhere or two separate supported models.

Consider reformatting as separate bulleted items for clarity:

📝 Suggested formatting improvement
-* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
+* **LLM**: 
+    * ``mllmTeam/Qwen3-0.6B-w4a32kai``
+    * ``mllmTeam/Qwen3-4B-w4a8-i8mm-kai``

Or use "and" to separate:

-* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
+* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai`` and ``mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
* **LLM**:
* ``mllmTeam/Qwen3-0.6B-w4a32kai``
* ``mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
Suggested change
* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
* **LLM**: ``mllmTeam/Qwen3-0.6B-w4a32kai`` and ``mllmTeam/Qwen3-4B-w4a8-i8mm-kai``
🤖 Prompt for AI Agents
In `@docs/service/mllm_cli.rst` at line 11, The LLM entry currently shows a
comma-separated pair inside one code literal which is ambiguous; update the docs
so each model appears clearly as its own item or as two separate code literals
joined with "and" — edit the line with the code literal
"mllmTeam/Qwen3-0.6B-w4a32kai,mllmTeam/Qwen3-4B-w4a8-i8mm-kai" and replace it
with either separate bullet lines each containing a single code literal (e.g.,
"mllmTeam/Qwen3-0.6B-w4a32kai" and "mllmTeam/Qwen3-4B-w4a8-i8mm-kai") or a
single sentence using two code literals separated by "and" to remove ambiguity.

* **OCR**: ``mllmTeam/DeepSeek-OCR-w4a8-i8mm-kai``

This guide covers three main areas:
Expand Down Expand Up @@ -136,168 +136,101 @@ Once configured, you can click the **Check** button to ensure the connection is
Build Configuration Guide
-------------------------

The Go build tasks (`build_android_mllm_server.yaml` and `build_android_mllm_client.yaml`) use hardcoded paths that are specific to the build server's environment. If you are setting up a new build environment, you **must** modify these paths before proceeding to compilation.
Go build tasks (`build_android_mllm_server.yaml` and `build_android_mllm_client.yaml`) now use **dynamic paths** (via `$(pwd)`) to locate project files. This makes the scripts much more portable.

Understanding the Build Scripts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The core of the cross-compilation logic for Go is within the `ShellCommandTask` of the `.yaml` build files. It sets several environment variables to configure `cgo` for cross-compiling to Android ARM64.

* ``GOOS=android``, ``GOARCH=arm64``: Tells Go to build for Android ARM64.
* ``CGO_ENABLED=1``: Enables ``cgo`` to allow Go to call C/C++ code.
* ``CC`` and ``CXX``: Specifies the C and C++ compilers from the Android NDK, used to compile any C/C++ parts within the Go program.
* ``CGO_CFLAGS``: Tells the C compiler where to find the MLLM C API header files (e.g., ``Runtime.h``).
* ``CGO_LDFLAGS``: Tells the linker where to find the compiled MLLM shared libraries (``.so`` files) that the final executable needs to link against.

Modifying Hardcoded Paths
~~~~~~~~~~~~~~~~~~~~~~~~~

The two most critical variables you will need to change are `CGO_CFLAGS` and `CGO_LDFLAGS`.

**Example from `build_android_mllm_server.yaml`**:

.. code-block:: yaml
However, there are still specific environment configurations you **must** check and modify to match your local build machine.

# ...
export CGO_LDFLAGS="-L/root/zty_workspace/mllm_zty/build-android-arm64-v8a/bin"
export CGO_CFLAGS="-I/root/zty_workspace/mllm_zty"
# ...
Open `tasks/build_android_mllm_server.yaml` and check the following variables:

**How to Modify**:
1. **``ANDROID_NDK_HOME`` (Critical)**
The script assumes the NDK is located at `/opt/ndk/android-ndk-r28b`.
* **Action:** Change this path to the actual location of the Android NDK on your machine.

1. **``CGO_CFLAGS="-I/path/to/your/project/root"``**
The `-I` flag specifies an include directory. This path should point to the root of the MLLM project directory on your build server, where the `mllm/c_api/` headers are located. In the example, this is `/root/zty_workspace/mllm_zty`. Change this to match your project's location.
2. **``GOPROXY`` (Network)**
The script uses `https://goproxy.cn` to accelerate downloads in China.
* **Action:** If you are outside of China, you may remove this line or change it to `https://proxy.golang.org`.

2. **``CGO_LDFLAGS="-L/path/to/your/compiled/libs"``**
The `-L` flag specifies a library directory. This path must point to the directory where the C++ build (Step 1) placed the `.so` files. In the example, this is `/root/zty_workspace/mllm_zty/build-android-arm64-v8a/bin`. If your build output directory is different, you must update this path accordingly.

By correctly updating these two paths in both `build_android_mllm_server.yaml` and `build_android_mllm_client.yaml`, you can adapt the build process to any server environment.

Compilation and Deployment
--------------------------

This section provides the complete workflow for compiling all C++ and Go components, deploying them to an Android target, and running the system.
This section outlines the workflow for compiling the C++ and Go components and deploying them directly to an Android device.

Prerequisites
~~~~~~~~~~~~~

* A build environment, such as a server or Docker container, with the Android NDK and Go compiler installed, hereinafter referred to as the 'build server'.
* An Android target device with `adb` access enabled.
* `rsync` and `scp` for file synchronization between your development machine and the build server.
* Android NDK and Go compiler installed and configured.
* An Android device connected via `adb`.

Step 1: Compile C++ Core Libraries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

First, we compile the MLLM C++ core, which produces the essential shared libraries (`.so` files).

1. **Sync Code to Build Server**:
Synchronize your local project directory with the build server.

.. code-block:: bash
Compile the MLLM C++ core to generate the required shared libraries (`.so` files).

# Replace <port>, <user>, and <build-server-ip> with your server details
rsync -avz --checksum -e 'ssh -p <port>' --exclude 'build' --exclude '.git' ./ <user>@<build-server-ip>:/your_workspace/your_programname/
1. **Configure Build Script**:
Ensure `tasks/build_android.yaml` is configured with your NDK path.

2. **Run the Build Task**:
On the build server, execute the build task. This task uses `tasks/build_android.yaml` to configure and run CMake.
2. **Run Compilation**:
Execute the build task from the project root.

Before executing this step, you also need to ensure that the hardcoded directories in build_android.yaml have been modified to match your requirements. The modification method is the same as for the Go compilation file mentioned earlier.

.. code-block:: bash

# These commands are run on your build server.
cd /your_workspace/your_programname/
python task.py tasks/build_android.yaml

3. **Retrieve Compiled Libraries**:
After the build succeeds, copy the compiled shared libraries from the build server back to your local machine. These libraries are the C++ backend that the Go application will call.

.. code-block:: bash

# You run these commands on your local machine to copy the files from the build server.
# Navigate to your local build artifacts directory
cd /path/to/your/local_artifacts_dir/

# Copy the libraries
scp -P <port> <user>@<build-server-ip>:/your_workspace/your_programname/build-android-arm64-v8a/bin/libMllmRT.so .
scp -P <port> <user>@<build-server-ip>:/your_workspace/your_programname/build-android-arm64-v8a/bin/libMllmCPUBackend.so .
scp -P <port> <user>@<build-server-ip>:/your_workspace/your_programname/build-android-arm64-v8a/bin/libMllmSdkC.so .
**Output**: The compiled libraries (`libMllmRT.so`, `libMllmCPUBackend.so`, `libMllmSdkC.so`) will be located in `build-android-arm64-v8a/bin/`.

Step 2: Compile the Go Server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Next, cross-compile the Go server application for Android.
Cross-compile the Go server application for Android.

1. **Sync Code**: Ensure your latest Go code is on the build server. This is only necessary if you've made changes to the Go server files (e.g., in the ``mllm-cli`` directory).

2. **Run the Build Task**:
On the build server, execute the server build task. Make sure you have correctly configured the hardcoded paths in this YAML file as described in the "Build Configuration Guide" section.
1. **Run Compilation**:
Execute the server build task.

.. code-block:: bash

cd /your_workspace/your_programname/
python task.py tasks/build_android_mllm_server.yaml

3. **Retrieve the Executable**:
Copy the compiled `mllm_web_server` binary from the build server back to your local machine.

.. code-block:: bash

# Navigate to your local build artifacts directory
cd /path/to/your/local_artifacts_dir/

# Copy the executable
scp -P <port> <user>@<build-server-ip>:/your_workspace/your_programname/build-android-arm64-v8a/bin/mllm_web_server .
**Output**: The executable `mllm_web_server` will be generated in `build-android-arm64-v8a/bin/`.

Step 3: Compile the Go Client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you are using Chatbox or a similar client, you can skip this step.
Step 3: Compile the Go Client (Optional)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Similarly, compile the Go client application.
If you need the command-line WebSocket client, compile it using the following task.

1. **Sync Code**: Ensure your latest Go client code is on the build server.

2. **Run the Build Task**:
On the build server, execute the client build task. This also requires the build YAML to be correctly configured.
1. **Run Compilation**:

.. code-block:: bash

cd /your_workspace/your_programname/
python task.py tasks/build_android_mllm_client.yaml

3. **Retrieve the Executable**:
Copy the compiled `mllm_ws_client` binary from the build server to your local machine.

.. code-block:: bash

# Navigate to your local build artifacts directory
cd /path/to/your/local_artifacts_dir/

# Copy the executable
scp -P <port> <user>@<build-server-ip>:/your_workspace/your_programname/build-android-arm64-v8a/bin/mllm_ws_client .
**Output**: The executable `mllm_ws_client` will be generated in `build-android-arm64-v8a/bin/`.

Step 4: Deploy to Target Device
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Push all compiled artifacts (libraries and executables) to your target Android device.
Push the compiled artifacts directly from the build output directory to your Android device using `adb`.

.. code-block:: bash

# Connect to your device if you haven't already
adb connect <device-id-or-ip:port>
# 1. Connect to device (if not already connected via USB)
adb connect <device-ip:port>

Comment on lines +217 to 218
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify connection method in comment.

The comment states "if not already connected via USB" but the command adb connect <device-ip:port> is specifically for establishing a network (TCP/IP) connection, not USB. USB-connected devices don't require the adb connect command—they're automatically detected when physically connected.

Consider updating the comment to reflect the actual use case:

📝 Suggested correction
-   # 1. Connect to device (if not already connected via USB)
+   # 1. Connect to device over network (skip if already connected via USB or network)
    adb connect <device-ip:port>

Or if USB is assumed:

-   # 1. Connect to device (if not already connected via USB)
-   adb connect <device-ip:port>
+   # 1. Ensure device is connected (via USB or run 'adb connect <device-ip:port>' for network)
🤖 Prompt for AI Agents
In `@docs/service/mllm_cli.rst` around lines 217 - 218, Update the explanatory
comment around the adb command so it accurately describes that `adb connect
<device-ip:port>` establishes a TCP/IP (network) connection to a device and is
not used for USB-connected devices; replace or clarify the phrase "if not
already connected via USB" to state that USB devices are detected automatically
and `adb connect` is only needed for network connections (reference the line
containing `adb connect <device-ip:port>` and the adjacent comment text).

# Push the shared libraries from your local artifacts directory
adb push libMllmRT.so /path/to/your/deployment_dir/
adb push libMllmCPUBackend.so /path/to/your/deployment_dir/
adb push libMllmSdkC.so /path/to/your/deployment_dir/
# 2. Push libraries and executables
# Navigate to the build output directory
cd build-android-arm64-v8a/bin/

# Push the server and client executables
adb push mllm_web_server /path/to/your/deployment_dir/
# Define your target directory on Android (e.g., /data/local/tmp/mllm/)
export ANDROID_DIR=/data/local/tmp/mllm/

# (Optional) Push the Go client if you compiled it in Step 3
adb push mllm_ws_client /path/to/your/deployment_dir/
# Push files
adb push libMllmRT.so $ANDROID_DIR
adb push libMllmCPUBackend.so $ANDROID_DIR
adb push libMllmSdkC.so $ANDROID_DIR
adb push mllm_web_server $ANDROID_DIR

# (Optional) Push client if compiled
# adb push mllm_ws_client $ANDROID_DIR
Step 5: Running and Testing
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -352,4 +285,4 @@ You should now be able to interact with the model from the client terminal. Type
adb forward tcp:8081 tcp:8080

3. **Open Chatbox**:
Open the Chatbox application on your host machine and configure it according to the "Alternative Client: Chatbox" section above. You can now chat with the model through the GUI.
Open the Chatbox application on your host machine and configure it according to the "Alternative Client: Chatbox" section above. You can now chat with the model through the GUI.
2 changes: 1 addition & 1 deletion mllm-cli/cmd/mllm-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
log.Fatal("FATAL: InitializeContext failed!")
}
mllm.SetLogLevel(2)
if !mllm.StartService(4) {
if !mllm.StartService(1) {
log.Fatal("FATAL: StartService failed!")
}
defer mllm.StopService()
Expand Down
17 changes: 8 additions & 9 deletions mllm-cli/go.mod
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
module mllm-cli

go 1.22.2
go 1.23.0

require (
github.com/charmbracelet/bubbles v0.21.0
github.com/gorilla/websocket v1.5.3 //
)
toolchain go1.24.11

require github.com/charmbracelet/bubbles v0.21.0

require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/bubbletea v1.3.4 // indirect
github.com/charmbracelet/bubbletea v1.3.4
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/lipgloss v1.1.0
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/google/uuid v1.6.0
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/muesli/termenv v0.16.0
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/term v0.34.0
golang.org/x/text v0.3.8 // indirect
github.com/google/uuid v1.6.0
)
12 changes: 10 additions & 2 deletions mllm-cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI=
Expand All @@ -14,10 +16,16 @@ github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2ll
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
Expand All @@ -39,12 +47,12 @@ github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
Expand Down
4 changes: 2 additions & 2 deletions mllm-cli/mllm/c.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package mllm
#cgo CFLAGS: -std=c11
#cgo LDFLAGS: -lMllmSdkC -lMllmRT -lMllmCPUBackend

#include <mllm/mllm-c.h>
#include "mllm/c_api/Runtime.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find Runtime.h header file
echo "=== Searching for Runtime.h ==="
fd -t f "Runtime.h"

echo -e "\n=== Searching for mllm/c_api directory ==="
fd -t d "c_api"

echo -e "\n=== Listing files in mllm/c_api if it exists ==="
find . -type d -name "c_api" -exec ls -la {} \;

Repository: UbiquitousLearning/mllm

Length of output: 927


🏁 Script executed:

#!/bin/bash

echo "=== Content of mllm/c_api/Runtime.h ==="
cat -n mllm/c_api/Runtime.h

echo -e "\n=== Checking c.go file (first 30 lines) ==="
head -n 30 mllm-cli/mllm/c.go

echo -e "\n=== Checking c.go file for all function calls ==="
grep -E "(isOk|initializeContext|shutdownContext|startService|stopService|setLogLevel|createQwen3Session|createDeepseekOCRSession|freeSession|insertSession|sendRequest|pollResponse|freeResponseString|MllmCAny)" mllm-cli/mllm/c.go | head -20

Repository: UbiquitousLearning/mllm

Length of output: 3590


🏁 Script executed:

#!/bin/bash

echo "=== Content of mllm/c_api/Object.h ==="
cat -n mllm/c_api/Object.h

echo -e "\n=== Checking c.go for complete function usage ==="
grep -n "C\." mllm-cli/mllm/c.go | grep -E "(isOk|initializeContext|shutdownContext|startService|stopService|setLogLevel|createQwen3Session|createDeepseekOCRSession|freeSession|insertSession|sendRequest|pollResponse|freeResponseString)" | head -30

echo -e "\n=== Checking c.go file size and encoding ==="
wc -l mllm-cli/mllm/c.go
file mllm-cli/mllm/c.go

echo -e "\n=== Checking for trailing whitespace in c.go ==="
rg -n " $|	$" mllm-cli/mllm/c.go

echo -e "\n=== Checking line endings in c.go ==="
file -b mllm-cli/mllm/c.go | grep -i "line"

echo -e "\n=== Checking for control codes in c.go ==="
od -c mllm-cli/mllm/c.go | grep -E "\\\\[0-7]{3}" | head -5

Repository: UbiquitousLearning/mllm

Length of output: 3533


🏁 Script executed:

#!/bin/bash

echo "=== Complete analysis of trailing whitespace in c.go ==="
cat -n mllm-cli/mllm/c.go | grep -E " $|	$"

echo -e "\n=== Count of lines with trailing whitespace ==="
grep -c " $\|	$" mllm-cli/mllm/c.go

echo -e "\n=== Verify UTF-8 encoding ==="
hexdump -C mllm-cli/mllm/c.go | head -20

echo -e "\n=== Check for BOM ==="
head -c 3 mllm-cli/mllm/c.go | od -An -tx1

Repository: UbiquitousLearning/mllm

Length of output: 1034


🏁 Script executed:

#!/bin/bash

echo "=== Reading c.go to show trailing whitespace context ==="
sed -n '65,75p' mllm-cli/mllm/c.go | cat -A
sed -n '78,90p' mllm-cli/mllm/c.go | cat -A
sed -n '130,145p' mllm-cli/mllm/c.go | cat -A

echo -e "\n=== Verify all C function declarations are present in Runtime.h ==="
echo "Functions used in c.go that must be declared in Runtime.h:"
echo "- initializeContext: $(grep -c 'initializeContext()' mllm/c_api/Runtime.h)"
echo "- shutdownContext: $(grep -c 'shutdownContext()' mllm/c_api/Runtime.h)"
echo "- isOk: $(grep -c 'isOk(' mllm/c_api/Runtime.h)"
echo "- startService: $(grep -c 'startService(' mllm/c_api/Runtime.h)"
echo "- stopService: $(grep -c 'stopService()' mllm/c_api/Runtime.h)"
echo "- setLogLevel: $(grep -c 'setLogLevel(' mllm/c_api/Runtime.h)"
echo "- createQwen3Session: $(grep -c 'createQwen3Session(' mllm/c_api/Runtime.h)"
echo "- createDeepseekOCRSession: $(grep -c 'createDeepseekOCRSession(' mllm/c_api/Runtime.h)"
echo "- freeSession: $(grep -c 'freeSession(' mllm/c_api/Runtime.h)"
echo "- insertSession: $(grep -c 'insertSession(' mllm/c_api/Runtime.h)"
echo "- sendRequest: $(grep -c 'sendRequest(' mllm/c_api/Runtime.h)"
echo "- pollResponse: $(grep -c 'pollResponse(' mllm/c_api/Runtime.h)"
echo "- freeResponseString: $(grep -c 'freeResponseString(' mllm/c_api/Runtime.h)"
echo "- MllmCAny: $(grep -c 'MllmCAny' mllm/c_api/Object.h)"

Repository: UbiquitousLearning/mllm

Length of output: 1672


The new header "mllm/c_api/Runtime.h" correctly provides all required C API declarations, so the include change at line 10 is valid.

However, the file has trailing whitespace on 10 lines (69, 80, 81, 84, 95, 107, 115, 126, 134, 139), which violates the coding guideline requiring no trailing whitespace. Remove trailing spaces from these lines.

🤖 Prompt for AI Agents
In `@mllm-cli/mllm/c.go` at line 10, Remove all trailing whitespace in the
modified source file so it adheres to the project's no-trailing-whitespace
guideline: trim end-of-line spaces across the file (there are 10 occurrences
reported) including the lines around the new include directive "#include
\"mllm/c_api/Runtime.h\"" so that no line ends with extraneous spaces and the
file saves with clean line endings.

#include <stdlib.h>

static void* MllmCAny_get_v_custom_ptr(MllmCAny handle) {
Expand Down Expand Up @@ -142,4 +142,4 @@ func (s *Session) PollResponse(requestID string) string {

func (s *Session) SessionID() string {
return s.sessionID
}
}
37 changes: 18 additions & 19 deletions tasks/build_android_mllm_client.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
Tasks:
- ShellCommandTask:
command: |
echo "===== STEP 2: Setting up Go cross-compilation environment... ====="
export GOPROXY=https://goproxy.cn,direct
export GOOS=android
export GOARCH=arm64
export CGO_ENABLED=1
export ANDROID_NDK_HOME=/opt/ndk/android-ndk-r28b
export CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang
export CXX=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++

echo "===== STEP 3: Setting CGo linker and compiler flags... ====="
export CGO_LDFLAGS="-L/root/zty_workspace/mllm_zty/build-android-arm64-v8a/bin"
export CGO_CFLAGS="-I/root/zty_workspace/mllm_zty"

echo "===== STEP 4: Compiling Go MLLM WebSocket Client... ====="
cd mllm-cli && \
echo "Running 'go mod tidy' to ensure all dependencies are present..." && \
go mod tidy && \
echo "Starting client build..." && \
go build -o ../build-android-arm64-v8a/bin/mllm_ws_client -tags=mobile ./cmd/mllm-client/main.go
export GOPROXY=https://goproxy.cn,direct
export GOOS=android
export GOARCH=arm64
export CGO_ENABLED=1

export ANDROID_NDK_HOME=/opt/ndk/android-ndk-r28b
export CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang
export CXX=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++

export CGO_LDFLAGS="-L$(pwd)/build-android-arm64-v8a/bin -lMllmSdkC -lMllmRT -lMllmCPUBackend -llog"

export CGO_CFLAGS="-I$(pwd) -I/tmp/mllm_build"

cd mllm-cli && \
echo "Running 'go mod tidy' to ensure all dependencies are present..." && \
go mod tidy && \
echo "Starting client build..." && \
go build -o ../build-android-arm64-v8a/bin/mllm_ws_client -tags=mobile ./cmd/mllm-client/main.go
Loading