Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPP_CLI] MLC Cli App over JSONEngine interface #3114

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

srkreddy1238
Copy link
Contributor

Comprehensive CPP Cli developed over existing JSONEngine interface.
Intended to use in environments with only cli access like Android ADB shells.

Comprehensive CPP Cli developed over existing JSONEngine interface.
Intended to use in environments with only cli access like Android ADB shells.
@tqchen
Copy link
Contributor

tqchen commented Jan 30, 2025

@mengshyu can you also help to review this pR

@mengshyu
Copy link
Contributor

Hi @srkreddy1238, It would be good to implement mlc_cli_chat following the structure of the iOS and Android app implementations, which consist of three major components: MLCEngine, JSONFFIEngine, and OpenAIProtocol, as this may enhance consistency and maintainability.

The MLCEngine serves as the business logic layer responsible for processing chat requests, managing state, and orchestrating interactions with the inference engine. It ensures efficient handling of streaming responses, allowing smooth and continuous chat interactions. Below this, JSONFFIEngine functions as the execution layer, acting as a bridge between the application logic and the underlying inference engine. It provides an interface for executing model inference, managing background processing, and ensuring efficient communication between the AI model and the rest of the system. At the data layer, OpenAIProtocol defines the standardized structures for handling request and response data, ensuring consistency in how chat interactions are formatted and processed. By maintaining a structured approach to data representation, it enables seamless integration between the business logic and execution layers.

Android: https://github.com/mlc-ai/mlc-llm/tree/main/android/mlc4j/src/main/java/ai/mlc/mlcllm

iOS: https://github.com/mlc-ai/mlc-llm/tree/main/ios/MLCSwift/Sources/Swift


#include "base.h"

/// Helper function to get the json format of messages
Copy link
Contributor

Choose a reason for hiding this comment

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

You may consider using picojson library

@@ -158,6 +158,8 @@ if(NOT CARGO_EXECUTABLE)
message(FATAL_ERROR "Cargo is not found! Please install cargo.")
endif()

add_subdirectory(apps/mlc_cli_chat)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest using USE_CLI_CHAT (default value: false) to determine whether to compile the executable.

@srkreddy1238
Copy link
Contributor Author

@mengshyu thanks for the review. We have done this a while back following python chat interface we have.
Let me refer Android implementation and enhance it as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants