DualMind is a versatile AI assistant designed to assist developers, researchers, and AI enthusiasts in generating high-quality responses for both conversational and coding tasks. It leverages advanced language models to provide thoughtful, context-aware responses through multiple interfaces.
- Multi-Interface Support: Access the AI assistant through:
- Terminal CLI
- REST API (OpenAI-compatible)
- Flutter mobile app
- Two-Phase Processing: Uses a reasoning model to think through the problem, then a coding model to generate the final response.
- Session Management: Maintains conversation history for contextual responses.
- Streaming Responses: Real-time streaming of AI responses.
- OpenAI-Compatible API: Works with any client that supports the OpenAI API format.
- Multiple LLM Provider Support: Compatible with LiteLLM, OpenRouter, and other OpenAI-compatible APIs.
- Rust (for the backend)
- Flutter (for the mobile app)
- API keys for LLM providers:
-
Clone the repository:
git clone https://github.com/ahrar-deriv/dualmind.git cd dualmind -
Create a
.envfile in the root directory with your configuration:# API Configuration API_URL=https://litellm.URL.ai # API_URL=https://openrouter.ai/api R_API_KEY=your_api_key_here # Model Configuration REASONING_MODEL=deepseek-r1-distill-llama-70b CODING_MODEL=qwen-max TEMPERATURE=0.6 -
Build the Rust backend:
cargo build --release
-
Build the Flutter app (optional):
cd chat_app flutter run # For iOS
Run the assistant in terminal mode:
cargo runThis will start an interactive session where you can chat with the AI assistant.
Run the assistant as an API server:
cargo run -- --apiThe server will start on port 3000 by default. You can then make requests to the API:
curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "dualmind",
"messages": [{"role": "user", "content": "Hello world"}],
"stream": false
}'-
Start the API server as described above.
-
Navigate to the
chat_appdirectory:cd chat_app -
Configure the API endpoint in the app settings:
- Open the app's configuration file (e.g.,
lib/config.dart). - Update the
apiUrlvariable to point to your running server (e.g.,http://localhost:3000).
- Open the app's configuration file (e.g.,
-
Launch the app:
flutter run
The API is compatible with the OpenAI Chat Completions API. Here are the main endpoints:
Create a chat completion. This is the main endpoint for interacting with the AI.
Request Body:
{
"model": "dualmind",
"messages": [{ "role": "user", "content": "Hello, how are you?" }],
"temperature": 0.7,
"stream": false
}Parameters:
model: Always use "dualmind" (required)messages: Array of message objects with role and content (required)temperature: Controls randomness (0-1, optional, default: 0.7)stream: Whether to stream the response (optional, default: false)session_id: Custom session ID for conversation continuity (optional)
Response:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677858242,
"model": "dualmind",
"choices": [
{
"message": {
"role": "assistant",
"content": "I'm doing well, thank you for asking! How can I help you today?"
},
"finish_reason": "stop",
"index": 0
}
]
}Error Response Example:
{
"error": {
"message": "Invalid API key",
"type": "authentication_error",
"code": 401
}
}Common Error Codes:
401: Invalid API key400: Invalid request format500: Internal server error
DualMind maintains conversation history for contextual responses. To continue a conversation, include the session_id parameter in your API requests:
{
"model": "dualmind",
"messages": [{ "role": "user", "content": "What's the capital of France?" }],
"session_id": "your-session-id"
}You can configure the assistant using environment variables or command-line arguments:
cargo run -- --api_url=https://litellm.ai --api_key=your_api_key_here \
--reasoning_model=deepseek-r1-distill-llama-70b \
--coding_model=qwen-max --temperature=0.6Available options:
--api_url: URL of the LLM provider API--api_key: API key for authentication--reasoning_model: Model to use for the reasoning phase--coding_model: Model to use for the coding/response phase--temperature: Temperature setting for response generation
DualMind uses a two-phase approach:
- Reasoning Phase: The assistant first uses a reasoning model to think through the problem and generate a plan or reasoning.
- Execution Phase: The reasoning is then passed to a coding model that generates the final response.
This approach helps produce more thoughtful and accurate responses, especially for complex queries.
- Rate Limits: The API enforces rate limits to prevent abuse. Please refer to your LLM provider's documentation for specific limits.
- Token Usage: Each request consumes tokens based on the input and output size. Monitor your token usage to avoid exceeding quotas.
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create a new branch for your changes.
- Ensure your code adheres to the project's coding standards.
- Write unit tests for any new functionality.
- Submit a pull request with a clear description of your changes.
For bug reports or feature requests, please open an issue in the repository.
This project is licensed under the MIT License - see the LICENSE file for details.
If you prefer not to build from source, you can download pre-built executables:
- Download the appropriate executable for your platform from the Releases page
- Create a
.envfile in the same directory as the executable with your configuration:# API Configuration API_URL=https://your-llm-provider-url.com/api R_API_KEY=your_api_key_here # Model Configuration REASONING_MODEL=your-reasoning-model CRAFT_MODEL=your-coding-model TEMPERATURE=0.6

