# AiShell **Repository Path**: ezemeti/AiShell ## Basic Information - **Project Name**: AiShell - **Description**: AI Shell是一个基于 Python 的命令行工具,旨在提供一个交互式的 PowerShell 终端,并集成 AI 助手功能。用户可以通过该终端执行 PowerShell 命令,同时 AI 助手会根据用户的输入提供相应的命令建议和执行结果。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-04 - **Last Updated**: 2025-06-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AI Shell 项目介绍 ## 项目概述 **AI Shell** 是一个基于 Python 的命令行工具,旨在提供一个交互式的 PowerShell 终端,并集成 AI 助手功能。用户可以通过该终端执行 PowerShell 命令,同时 AI 助手会根据用户的输入提供相应的命令建议和执行结果。 ## 使用说明 1. **配置 API 密钥**: 在 `Config.json` 文件中配置 `api_key`,或者在环境变量中设置 `OPENAI_API_KEY`。又或者修改`Shell/utils/config_manager.py`文件中的`load_config`函数,添加`api_key`的获取方式。 2. **启动终端**: 运行 `main.py` 文件启动终端。 3. **执行命令**: 在终端中输入 PowerShell 命令,AI 助手会提供相应的建议和执行结果。 4. **安装依赖**: 项目依赖 Python 3 和一些第三方库,可以通过 `requirements.txt` 文件查看依赖列表,并使用`pip install -r requirements.txt`安装。 ## 主要功能模块 ### 目录结构 ``` D:\STUDY\PYTHON\AISHELL │ AIShell.py │ ├───.idea │ .gitignore │ workspace.xml │ ├───Config │ model.json # 支持的模型库 │ Config.json # 配置文件 │ └───Shell ├───core │ conversation.py │ executor.py │ model.py │ terminal.py │ ├───utils │ config_manager.py │ helpers.py | ExamineConfig.py │ └───__init__.py ``` ### `AIShell.py` - **功能**: 程序的入口文件,负责启动终端。 ### `Config/model.json` - **功能**: 列出支持的模型库。 - **内容示例**: ```json { "Openai": [ "moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k", "Baichuan4-Turbo", "Baichuan4-Air", "Baichuan4", "Baichuan3-Turbo", "Baichuan3-Turbo-128k", "Baichuan2-Turbo", "Baichuan2-53B", "qwen2.5-7b-instruct", "qwen-max," ], "GLM": [ "glm-4-flash", "glm-4-plus", "glm-4-0520", "glm-4", "glm-4-air", "glm-4-airx", "glm-4-long", "glm-4-flashx", "glm-4v-plus", "glm-4v", "glm-4v-flash" ], "mistral": [ "pixtral-large-latest", "mistral-moderation-latest", "mistral-large-latest", "ministral-3b-latest", "ministral-8b-latest", "mistral-small-latest", "codestral-latest", "mistral-embed" ] } ``` ### `Config/Config.json` - **功能**: 配置文件,包含模型名称、API 密钥等信息。 - **内容示例**: ```json { "Model": { "model_name": "pixtral-large-latest", "api_key": "your_mistral_large_api_key", "model_url": "", "model_prompt": "prompt" }, "Terminal": { "terminal_font": "slant", "terminal_color": "cyan", "terminal_renderText": "AI Shell" } } ``` ### `Shell/core/conversation.py` - **功能**: 负责处理对话历史和与 AI 的交互。 ### `Shell/core/executor.py` - **功能**: 负责执行 PowerShell 命令。 ### `Shell/core/model.py` - **功能**: 负责与 AI 模型的交互,包括调用 AI 模型并获取响应。 ### `Shell/core/terminal.py` - **功能**: 负责终端的交互逻辑。 ### `Shell/utils/config_manager.py` - **功能**: 负责加载配置文件和环境变量。 ### `Shell/utils/helpers.py` - **功能**: 包含一些辅助函数,如清理屏幕。 ### `Shell/utils/ExamineConfig.py` - **功能**: 检查配置文件是否存在。 ## 配置文件解释 ### `Config/model.json` - **`Openai`**: 支持的 OpenAI 模型列表。 - **`GLM`**: 支持的 GLM 模型列表。 - **`mistral`**: 支持的 Mistral 模型列表。 ### `Config/Config.json` - **`Model`**: - **`model_name`**: 当前使用的模型名称。 - **`api_key`**: 模型的 API 密钥。 - **`model_url`**: 模型的 URL(可选)。 - **`model_prompt`**: 模型使用的提示(可选)。 - **`Terminal`**: - **`terminal_font`**: 终端使用的字体。 - **`terminal_color`**: 终端文本的颜色。 - **`terminal_renderText`**: 终端渲染的文本内容。 ## 打包 **打包命令**: ``` pyinstaller AIShell.spec ``` ## 贡献 欢迎贡献代码和提出改进建议。请遵循项目的代码风格和贡献指南。 ## 许可证 该项目采用 MIT 许可证。详情请参阅 `LICENSE` 文件。