deepseek-cli开源的强大命令行界面,用于与 DeepSeek 的 AI 模型进行交互
一、软件介绍
文末提供程序和源码下载
deepseek-cli一个强大的命令行界面,用于与 DeepSeek 的 AI 模型进行交互。
二、Features 特征
-
Multiple Model Support
多模型支持- DeepSeek-V3 (deepseek-chat)
- DeepSeek-R1 (deepseek-reasoner)
- DeepSeek 编码器 (deepseek-coder)
- DeepSeek-V3 (deepseek-chat)
-
🔄 高级对话功能
- 具有上下文保留功能的多轮对话
- 系统消息定制
- 对话历史记录跟踪
- 上下文缓存以获得更好的性能
- 用于快速查询的内联模式
-
🧪 Beta 功能
- 前缀完成:完成来自给定前缀的助手消息
- 中间填充 (FIM):完成前缀和后缀之间的内容
- Context Caching:自动缓存以获得更好的性能
-
🛠️ Advanced Controls 🛠️ 高级控制
- 带预设的温度控制
- JSON 输出模式
- Streaming responses 流式处理响应
- Function calling 函数调用
- Stop sequences 停止序列
- Top-p sampling Top-p 采样
- Frequency and presence penalties
频率和存在惩罚
-
📦 Package Management 📦 包管理
- Automatic version checking
自动版本检查 - Update notifications 更新通知
- Easy installation and updates
易于安装和更新 - Development mode support 开发模式支持
- Automatic version checking
三、Installation 安装
您可以通过两种方式安装 DeepSeek CLI:
Option 1: Install from PyPI (Recommended)
选项 1:从 PyPI 安装(推荐)
pip install deepseek-cli
Option 2: Install from Source (Development)
选项 2:从源 (开发) 安装
git clone https://github.com/PierrunoYT/deepseek-cli.git
cd deepseek-cli
pip install -e .
Updating the Package 更新软件包
To update to the latest version:
要更新到最新版本:
pip install --upgrade deepseek-cli
For development installation, pull the latest changes and reinstall:
对于开发安装,请拉取最新的更改并重新安装:
git pull
pip install -e . --upgrade
The CLI will automatically check for updates on startup and notify you when a new version is available.
CLI 将在启动时自动检查更新,并在有新版本可用时通知您。
API Key Setup API 密钥设置
Set your DeepSeek API key as an environment variable:
将你的 DeepSeek API 密钥设置为环境变量:
macOS/Linux macOS/Linux 作系统
export DEEPSEEK_API_KEY="your-api-key"
Windows 窗户
set DEEPSEEK_API_KEY="your-api-key"
To make it permanent, add it to your environment variables through System Settings.
要使其成为永久的,请通过 System Settings 将其添加到您的环境变量中。
四、Usage 用法
DeepSeek CLI supports two modes of operation: interactive mode and inline mode.
DeepSeek CLI 支持两种作模式:交互模式和内联模式。
Interactive Mode 交互模式
After installation, you can start the CLI in interactive mode in two ways:
安装后,您可以通过两种方式以交互模式启动 CLI:
If installed from PyPI: 如果从 PyPI 安装:
deepseek
If installed in development mode:
如果在开发模式下安装:
deepseek
# or
python -m deepseek_cli
Inline Mode 内联模式
You can also use DeepSeek CLI in inline mode to get quick answers without starting an interactive session:
您还可以在内联模式下使用 DeepSeek CLI 来快速获得答案,而无需启动交互式会话:
# Basic usage
deepseek -q "What is the capital of France?"# Specify a model
deepseek -q "Write a Python function to calculate factorial" -m deepseek-coder# Get raw output without token usage information
deepseek -q "Write a Python function to calculate factorial" -r# Combine options
deepseek -q "Write a Python function to calculate factorial" -m deepseek-coder -r
Available inline mode options:
可用的内联模式选项:
-q, --query
: The query to send to the model
-q, --query
:要发送到模型的查询-m, --model
: The model to use (deepseek-chat, deepseek-coder, deepseek-reasoner)
-m, --model
: 要使用的模型 (deepseek-chat, deepseek-coder, deepseek-reasoner)-r, --raw
: Output raw response without token usage information
-r, --raw
:输出不带 Token 使用信息的原始响应
Troubleshooting 故障 排除
-
If the API key is not recognized:
如果无法识别 API 密钥:- Make sure you've set the DEEPSEEK_API_KEY environment variable
确保已设置 DEEPSEEK_API_KEY 环境变量 - Try closing and reopening your terminal
尝试关闭并重新打开您的终端 - Check if the key is correct with:
echo $DEEPSEEK_API_KEY
(Unix) orecho %DEEPSEEK_API_KEY%
(Windows)
使用以下命令检查密钥是否正确:echo $DEEPSEEK_API_KEY
(Unix) 或echo %DEEPSEEK_API_KEY%
(Windows)
- Make sure you've set the DEEPSEEK_API_KEY environment variable
-
If you get import errors:
如果您收到导入错误:- Ensure you've installed the package:
pip list | grep deepseek-cli
确保您已安装软件包:pip list | grep deepseek-cli
- Try reinstalling:
pip install --force-reinstall deepseek-cli
尝试重新安装:pip install --force-reinstall deepseek-cli
- Ensure you've installed the package:
-
For development installation issues:
对于开发安装问题:- Make sure you're in the correct directory
确保您位于正确的目录中 - Try:
pip install -e . --upgrade
尝试:pip install -e . --upgrade
- Make sure you're in the correct directory
Available Commands 可用命令
Basic Commands: 基本命令:
/help
- Show help message
/help
- 显示帮助消息/models
- List available models
/models
- 列出可用型号/model X
- Switch model (deepseek-chat, deepseek-coder, deepseek-reasoner)
/model X
- 切换模型(deepseek-chat、deepseek-coder、deepseek-reasoner)/clear
- Clear conversation history
/clear
- 清除对话历史记录/history
- Display conversation history
/history
- 显示对话历史记录/about
- Show API information
/about
- 显示 API 信息/balance
- Check account balance
/balance
- 查看账户余额
Model Settings: 模型设置:
/temp X
- Set temperature (0-2) or use preset (coding/data/chat/translation/creative)
/temp X
- 设置温度 (0-2) 或使用预设 (coding/data/chat/translation/creative)/freq X
- Set frequency penalty (-2 to 2)
/freq X
- 设置频率惩罚(-2 到 2)/pres X
- Set presence penalty (-2 to 2)
/pres X
- 设置存在惩罚(-2 到 2)/top_p X
- Set top_p sampling (0 to 1)
/top_p X
- 设置 top_p 采样(0 到 1)
Beta Features: 测试版功能:
/beta
- Toggle beta features
/beta
- 切换 Beta 版功能/prefix
- Toggle prefix completion mode
/prefix
- 切换前缀完成模式/fim
- Toggle Fill-in-the-Middle completion
/fim
- 切换 Fill-in-the-Middle 完成/cache
- Toggle context caching
/cache
- 切换上下文缓存
Output Control: 输出控制:
/json
- Toggle JSON output mode
/json
- 切换 JSON 输出模式/stream
- Toggle streaming mode
/stream
- 切换流式传输模式/stop X
- Add stop sequence
/stop X
- 添加停止序列/clearstop
- Clear stop sequences
/clearstop
- 清除停止序列
Function Calling: 函数调用:
/function {}
- Add function definition (JSON format)
/function {}
- 添加函数定义(JSON 格式)/clearfuncs
- Clear registered functions
/clearfuncs
- 清除已注册的函数
Model-Specific Features 特定于模型的特征
DeepSeek-V3 (deepseek-chat)
DeepSeek-V3 (deepseek-chat)
- 64K context length (64,000 tokens)
64K 上下文长度(64,000 个令牌) - Default max output: 4096 tokens
默认最大输出:4096 个代币 - Beta max output: 8192 tokens (requires beta mode)
Beta 最大输出:8192 个代币(需要 Beta 模式) - Supports all features 支持所有功能
- General-purpose chat model
通用聊天模型 - Latest improvements: 最新改进:
- Enhanced instruction following (77.6% IFEval accuracy)
增强的指令跟随(IFEval 准确率为 77.6%) - Improved JSON output (97% parsing rate)
改进的 JSON 输出(97% 的解析率) - Advanced reasoning capabilities
高级推理功能 - Role-playing capabilities
角色扮演功能
- Enhanced instruction following (77.6% IFEval accuracy)
DeepSeek-R1 (deepseek-reasoner)
DeepSeek-R1 (deepseek-reasoner)
- 64K context length 64K 上下文长度
- 8K output tokens 8K 输出令牌
- 32K Chain of Thought output
32K Chain of Thought 输出 - Excels at complex reasoning
擅长复杂推理 - Unsupported features: function calling, JSON output, FIM
不支持的功能:函数调用、JSON 输出、FIM - Unsupported parameters: temperature, top_p, presence/frequency penalties
不支持的参数:温度、top_p、存在/频率损失
DeepSeek Coder (deepseek-coder)
DeepSeek 编码器 (deepseek-coder)
- Default max output: 4096 tokens
默认最大输出:4096 个代币 - Beta max output: 8192 tokens (requires beta mode)
Beta 最大输出:8192 个代币(需要 Beta 模式) - Optimized for code generation
针对代码生成进行了优化 - Supports all features 支持所有功能
Feature Details 功能详细信息
Fill-in-the-Middle (FIM) 中间填充 (FIM)
Use XML-style tags to define the gap:
使用 XML 样式的标记来定义间隙:
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code><fim_prefix>def calculate_sum(a, b):</fim_prefix><fim_suffix> return result</fim_suffix>
</code></span></span></span></span>
JSON Mode JSON 模式
Forces model to output valid JSON. Example system message:
强制模型输出有效的 JSON。系统消息示例:
{"response": "structured output","data": {"field1": "value1","field2": "value2"}
}
Context Caching 上下文缓存
- Automatically caches context for better performance
自动缓存上下文以获得更好的性能 - Minimum cache size: 64 tokens
最小缓存大小:64 个令牌 - Cache hits reduce token costs
缓存命中可降低令牌成本 - Enabled by default 默认启用
Temperature Presets 温度预设
coding
: 0.0 (deterministic)
编码
:0.0(确定性)data
: 1.0 (balanced)
数据
:1.0(平衡)chat
: 1.3 (creative)
聊天
:1.3(创造模式)translation
: 1.3 (creative)
翻译
:1.3(创意)creative
: 1.5 (very creative)
创意
:1.5(非常有创意)
Error Handling 错误处理
- Automatic retry with exponential backoff
使用指数退避的自动重试 - Rate limit handling 速率限制处理
- Clear error messages 清除错误消息
- API status feedback API 状态反馈
五、软件下载
夸克网盘分享
本文信息来源于GitHub作者地址:https://github.com/PierrunoYT/deepseek-cli