Skip to main content

Minimal agentic reasoning tool with multiple LLM backend support

Project description

mini-unit

PyPI version Python 3.8+ License: MIT

极简 Agentic 推理工具,支持多种 LLM 后端(百度内部 LLM / DeepSeek / MiniMax),基于工具调用实现多轮推理和代码探索。专注于自动化单元测试生成。

安装

从 PyPI 安装(推荐)

pip install mini-unit

从源码安装

git clone https://github.com/yourusername/mini-unit.git
cd mini-unit
pip install -e .

快速开始

方式 1: 使用命令行工具

# 设置环境变量
export LLM_BACKEND=baidu  # 或 openai/minimax
export BAIDU_LLM_API_KEY=your-key

# 运行
mini-unit "帮我写单元测试"

方式 2: 使用启动脚本

1. 安装依赖

pip install -r requirements.txt

2. 选择并启动 LLM 后端

选项 A: 百度内部 LLM(默认)
source start_baidu.sh
python3 main.py "帮我写单元测试"
选项 B: DeepSeek
export DEEPSEEK_API_KEY=sk-your-key
source start_deepseek.sh
mini-unit "帮我写单元测试"
选项 C: MiniMax
export MINIMAX_API_KEY=your-key
source start_minimax.sh
mini-unit "帮我写单元测试"

启动脚本说明

项目提供了 3 个启动脚本:

  • start_baidu.sh - 百度内部 LLM
  • start_deepseek.sh - DeepSeek
  • start_minimax.sh - MiniMax

使用方式:

source start_baidu.sh     # 加载环境变量
python3 main.py "问题"     # 运行

支持的 LLM 后端

1. 百度内部 LLM

配置(见 start_baidu.sh):

export LLM_BACKEND=baidu
export BAIDU_LLM_URL=http://llms-se.baidu-int.com:8200/chat/completions
export BAIDU_LLM_API_KEY=sk---haoxinda---shEsw6b4ZHkYh5pfd8xs6A==
export BAIDU_LLM_MODEL=gpt-3.5-turbo
export BAIDU_LLM_TEMPERATURE=0.3

2. DeepSeek

配置(见 start_deepseek.sh):

export LLM_BACKEND=openai
export DEEPSEEK_API_KEY=sk-your-key  # 必须设置
export DEEPSEEK_BASE_URL=https://api.deepseek.com
export DEEPSEEK_MODEL=deepseek-chat

3. MiniMax

配置(见 start_minimax.sh):

export LLM_BACKEND=minimax
export MINIMAX_API_KEY=your-key  # 必须设置
export MINIMAX_BASE_URL=https://api.minimax.chat/v1
export MINIMAX_MODEL=MiniMax-M2.7
export MINIMAX_TEMPERATURE=0.3
export MINIMAX_REASONING_SPLIT=true  # 分离显示思考过程

增强 Prompt 模式

默认启用增强模式,包含:

  • ⚠️⚠️⚠️ 强制性的 9 步探索流程
  • 防止低级编译错误(undefined、not used)
  • 智能处理外部依赖(2 次失败后跳过)
  • 质量检查清单

控制方式:

export USE_ENHANCED_PROMPT=auto   # 默认,全部启用
export USE_ENHANCED_PROMPT=false  # 禁用

可用工具

  1. glob - 文件模式匹配
  2. read - 读取文件
  3. grep - 搜索内容
  4. write - 写入文件

使用示例

# 写单元测试
python3 main.py "帮我写 /path/to/file.go 的单元测试"

# 交互式
python3 main.py

# 单次执行
python3 main.py "解释这个函数"

配置速查表

环境变量 默认值 说明
LLM_BACKEND baidu 后端:baidu/openai/minimax
USE_ENHANCED_PROMPT auto Prompt 模式
MAX_TURNS 30 最大推理轮数

项目结构

/Users/haoxinda/cc/pp/
├── main.py               # CLI 入口
├── loop.py              # 推理循环
├── tools.py             # 工具定义
├── prompts.py           # 系统提示词
├── requirements.txt     # 依赖
├── start_baidu.sh       # 百度启动脚本
├── start_deepseek.sh    # DeepSeek 启动脚本
└── start_minimax.sh     # MiniMax 启动脚本

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mini_unit-0.1.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mini_unit-0.1.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file mini_unit-0.1.0.tar.gz.

File metadata

  • Download URL: mini_unit-0.1.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for mini_unit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a665e4762e078f95c20e564752f74e6da2e68071ce6dd7fffa3d9b968489df5
MD5 b33998106918b173339d3bbbfacd9914
BLAKE2b-256 5375aaf3532c28426cb66e92771f7f121884e53d8f2d0f8d8ab6ab1d3b360a55

See more details on using hashes here.

File details

Details for the file mini_unit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mini_unit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for mini_unit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ff7b8412625051f08d120a2e1fa7d1d9ab0ffe98ed113d5117dfa5045499ad8
MD5 fe1555c8b96c26a57de386a38ff65636
BLAKE2b-256 dcc786c12f21bb59cfa08d0db33edf9b03e9141dd5f41327866afc6028659525

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page