Skip to content

Repository files navigation

🦞 MiMo CLI Toolkit

为小米MiMo-V2.5 AI模型打造的轻量级命令行工具

Java License Platform

MiMo CLI Toolkit是一个专为开发者设计的命令行工具,让您能够在终端中轻松调用强大的小米MiMo-V2.5 AI模型。无论是代码生成、文档翻译还是智能问答,只需一行命令即可完成。

✨ 核心特性

🚀 开箱即用 - 5分钟完成安装配置,立即开始使用 🔧 配置灵活 - 支持命令行参数、环境变量、配置文件多种方式 💻 跨平台 - Windows、Linux、macOS全面支持 🛡️ 安全可靠 - API密钥从环境变量读取,避免泄露风险 📁 文件支持 - 支持从文件读取输入,方便批量处理 🎭 演示模式 - 内置Mock响应,无需API密钥即可测试 📊 完整日志 - 详细的日志输出,便于调试和问题排查

🎯 为什么选择MiMo CLI?

  • 填补空白 - MiMo生态首个命令行工具,降低使用门槛
  • 效率提升 - 无需打开浏览器或编写复杂代码,终端直接调用
  • 学习友好 - 内置Mock模式,零成本学习MiMo API使用
  • 扩展性强 - 模块化设计,轻松添加新功能

专为以下场景设计:

  • 🔍 快速测试MiMo模型的各项能力
  • 💻 自动化脚本集成AI功能
  • 📚 教育和演示用途
  • 🛠️ 开发者工具链集成

🚀 快速开始

环境要求

  • Java 11 或更高版本
  • Maven 3.6 或更高版本(用于构建)
  • MiMo API密钥(可选,用于实际API调用)

安装步骤

  1. 克隆项目到本地

    git clone https://github.com/liaozhe789/mimo-cli-toolkit.git
    cd mimo-cli-toolkit
  2. 构建项目

    mvn clean package
  3. 运行应用

    # 使用生成的JAR文件
    java -jar target/mimo-cli-1.0.0.jar "你好,MiMo!"

🚀 Getting Started

Quick Demo (No Installation Required)

Try the simplified version immediately:

# 1. Clone the repository
git clone https://github.com/liaozhe789/mimo-cli-toolkit.git
cd mimo-cli-toolkit

# 2. Compile the simplified version
javac -d target SimplifiedMain.java

# 3. Run a quick demo
java -cp target SimplifiedMain --version
java -cp target SimplifiedMain "Explain MiMo CLI"
java -cp target SimplifiedMain "Write a Java program"

Full Version Setup

For the complete version with all features:

# Using Maven (recommended)
mvn clean package
java -jar target/mimo-cli-1.0.0.jar --help

# Or use the provided scripts
./run.bat "Your prompt here"          # Windows
./run.sh "Your prompt here"           # Linux/macOS

📖 Usage Guide

Basic Usage

# Simple text generation
mimo-cli "Write a Java Hello World program"

# With parameters
mimo-cli --model v2.5 --max-tokens 1000 "Explain quantum computing"

# Adjust temperature
mimo-cli --temperature 0.3 "Translate 'Hello world' to Chinese"

# Read from file
mimo-cli --file input.txt

Command Line Options

# 显示帮助信息
mimo-cli --help

# 显示版本信息
mimo-cli --version

# 指定模型版本
mimo-cli --model v2.5 "你的提示词"

# 限制生成token数量
mimo-cli --max-tokens 500 "你的提示词"

# 调整生成温度(0.0-1.0)
mimo-cli --temperature 0.8 "你的提示词"

# 从文件读取提示词
mimo-cli --file prompt.txt

Command Line Options

Usage: mimo-cli [OPTIONS] PROMPT
  -h, --help                 Show this help message
  -v, --version              Show version information
  -m, --model MODEL          MiMo model version (default: v2.5)
  -t, --max-tokens TOKENS    Maximum tokens to generate (default: 500)
  -e, --temperature VALUE    Temperature for generation (default: 0.7)

Setting Up API Key

  1. Get your MiMo API key from the MiMo developer portal.

  2. Set as environment variable:

    # On Linux/macOS
    export MIMO_API_KEY=your_api_key_here
    
    # On Windows
    set MIMO_API_KEY=your_api_key_here
  3. Or create a configuration file (mimo-cli.properties):

    api.key=your_api_key_here
    api.url=https://api.mimo.ai/v1/chat/completions
    model.default=v2.5
    max.tokens.default=500
    temperature.default=0.7

Configuration Files

The CLI looks for configuration in this order:

  1. Environment variables
  2. mimo-cli.properties in current directory
  3. ~/.config/mimo-cli/mimo-cli.properties
  4. Default values

Development

Project Structure

mimo-cli/
├── src/main/java/com/mimo/cli/
│   ├── Main.java          # Entry point
│   ├── MiMoClient.java    # API client
│   └── Config.java        # Configuration manager
├── pom.xml               # Maven configuration
└── README.md            # This file

Building from Source

# Compile
mvn compile

# Run tests
mvn test

# Create executable JAR
mvn clean package

# Run with Maven
mvn exec:java -Dexec.mainClass="com.mimo.cli.Main" -Dexec.args="Your prompt here"

Running Tests

The project includes mock mode for testing without an API key:

# The CLI will use mock responses when no API key is set
java -jar target/mimo-cli-1.0.0.jar "Test prompt"

🎯 实用示例

示例1:代码生成

# 生成Java代码
mimo-cli "写一个Java函数,计算两个数字的和"

# 生成Python代码
mimo-cli "写一个Python函数,计算斐波那契数列"

# 生成SQL查询
mimo-cli "写一个SQL查询,获取用户表中最近7天注册的用户"

示例2:文本处理

# 中文翻译
mimo-cli "将'Hello, how are you?'翻译成中文"

# 文本摘要
mimo-cli --max-tokens 200 "总结这篇关于人工智能的文章"

# 文本改写
mimo-cli "将这段文字改写得更加正式:'这个产品很好用,推荐购买'"

示例3:技术问答

# 解释技术概念
mimo-cli "解释什么是RESTful API"

# 解决编程问题
mimo-cli "Java中如何优雅地处理空指针异常?"

# 学习建议
mimo-cli "给Java初学者推荐学习路线"

示例4:文件处理

# 从文件读取提示词
mimo-cli --file requirements.txt "根据这个需求文档生成测试用例"

# 批量处理(结合shell)
for file in prompts/*.txt; do
  mimo-cli --file "$file" > "outputs/$(basename $file)"
done

Troubleshooting

Common Issues

  1. "MIMO_API_KEY environment variable is not set"

    • Solution: Set the API key as shown in the setup section
  2. Connection timeout

    • Solution: Check your internet connection and firewall settings
    • You can increase timeout in configuration
  3. API returns error

    • Solution: Verify your API key is valid and has sufficient credits

Debug Mode

Enable debug logging to see detailed information:

# Set environment variable
export MIMO_DEBUG=true

# Or add to configuration file
debug.mode=true

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Development Guidelines

  • Follow Java coding conventions
  • Add unit tests for new features
  • Update documentation accordingly
  • Ensure backward compatibility

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the MiMo team for creating the amazing MiMo-V2.5 model
  • Built with Apache Commons CLI, HttpClient, and Jackson
  • Inspired by the need for simple AI command-line tools

Roadmap

  • Add support for file input/output
  • Implement batch processing mode
  • Add streaming response support
  • Create installation script for package managers
  • Add more configuration options
  • Support for different API endpoints

Support


Happy coding with MiMo! 🚀

About

A lightweight command-line interface for Xiaomi MiMo-V2.5 AI model. Easy to use, cross-platform, with mock mode for testing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages