一、軟件介紹
文末提供程序和源碼下載
? ? ? 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) or?echo %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