# cli_assistant **Repository Path**: hanshu_alan/cli_assistant ## Basic Information - **Project Name**: cli_assistant - **Description**: No description available - **Primary Language**: Rust - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-04 - **Last Updated**: 2025-11-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AI之友-聊天知识管理命令行工具 这是一个命令行工具,用于管理和AI聊天的内容,实现个人或者团队知识库的积累。 # 配置 ``` export AI_API_KEY="..." # API token export AI_SERVER_BASE_URL="https://api.ppinfra.com/v3/openai" export AI_MODEL="deepseek/deepseek-r1/community" # deepseek/deepseek-r1/community, deepseek/deepseek-v3 ``` 从理论上讲,可以接其它达模型。我是用的是ppinfra.com提供的大模型。 点击下面的链接,可以获得5000万token的大模型API服务,但这个大模型仅限于`deepseek/deepseek-r1/community` [欧派算力云](https://ppinfra.com/user/register?invited_by=LD0BRD) # 运行 ```bash bash-3.2$ cli_assistant --help caozongying_cao is the author of cli assistant Usage: cli_assistant [OPTIONS] Options: -q, --question 问题 -l, --long 长问题 -t, --history 带入历史记录的数量,如果t=0,表示不带入历史记录,如果t=2则表示带入前两次会话记录, 默认值为1 -k, --tokb 将当前的回复永久存储到对应的话题中,如果这个话题存在,系统会给出提示并退出运行 -u, --usekb 使用指定编号的kb知识来回答问题 -s, --listkb 列出所有的kb话题 -e, --temperature 设置回答温度,值为0到2 [default: 0] -h, --help Print help -V, --version Print version ``` # 使用方式 ```bash mkdir ai_kb_db # 创建目录,这个目录可以是任意名字,和AI的聊天记录将以文本文件的形式存在在这个目录下面 cd ai_kb_db touch .ai_db # 创建一个空白文件作为ai目录的标识 mkdir topic # 聊天记录将存储在名为topic的目录下 cd topic # 进入topic目录,进行这个topic的聊天 # 定义你的智能体 touch .system # 定义扫描的项目,具体参考`辅助编程`部分 touch config.yml # 在.system中输入你对智能体的定义,比如:我是一个智能体,回复采用中文,我的任务是帮助用户处理xxx类的工作 # 如果没有创建.system,系统会默认使用"我是一个智能体"来作为智能体的定义 # 从命令行输入简单问题 cli_assistant -q 你的问题 # 开始聊天 cat output.md # 查看ai返回的结果 # 从long_question.md中输入长篇问题 cli_assistant cat output.md # 查看ai返回的结果 # 查看聊天历史 cat messages # 将当前的回复整合到 knowlege base(kb)中,标题为"总结1" cli_assistant -q 整合之前的聊天内容 -t 10000 -k 总结1 # 列出kb中的所有标题 cli_assistant -s # 使用"总结1“,(通过cli_assistant中列出的序号来选择)来回答这个问题 cli_assistant -q 帮我创建一个新的模块 -u 2 ``` # 辅助编程 在config.yml中设置你的项目信息,当运行cli_assistant命令时,程序会扫描项目文件夹中的文件,处理包含`// todo: `的文件。 目前只能处理第一个包含todo的文件。 config.yml的定义如下: ```yml path=[项目的绝对路径] handle_ext: - vue - ts excluded_folders: - node_modules - target - __pycache__ ``` 如果你不想文件中的todo被处理,请加上exclude-ai-todo ```rust let x = 3; // todo: 重构这个名称 exclude-ai-todo ``` ## 引用别的文件 在todo中,允许引入别的文件,为大模型提供参考。 文件路径相对于config.yml中的path ```vue // todo: 重构下面的代码,参考{file1} // file:file1:src/Home.vue hello ``` 完成上述配置后,其它操作还是和之前的一样,运行cli_assistant启动程序。 沟通记录会保存在messages文件中。 在output.md中查看处理结果。 # 沟通与交流 [csdn博客](https://blog.csdn.net/firefox1?type=blog) [知乎](https://www.zhihu.com/people/cao-zong-ying-58/columns) [联系我](mailto:zongying_cao@163.com)