deepseek-cli开源的强大命令行界面,用于与 DeepSeek 的 AI 模型进行交互

一、软件介绍

文末提供程序和源码下载

deepseek-cli一个强大的命令行界面,用于与 DeepSeek 的 AI 模型进行交互。

二、Features 特征

  • Multiple Model Support

    多模型支持

    • DeepSeek-V3 (deepseek-chat)
    • DeepSeek-R1 (deepseek-reasoner)
    • DeepSeek 编码器 (deepseek-coder)
  • 🔄 高级对话功能

    • 具有上下文保留功能的多轮对话
    • 系统消息定制
    • 对话历史记录跟踪
    • 上下文缓存以获得更好的性能
    • 用于快速查询的内联模式
  • 🧪 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 开发模式支持

三、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)
  • 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
  • For development installation issues:

    对于开发安装问题:

    • Make sure you're in the correct directory
      确保您位于正确的目录中
    • Try: pip install -e . --upgrade
      尝试:pip install -e . --upgrade

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
      角色扮演功能
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 样式的标记来定义间隙:

notranslate 复制代码
<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

相关推荐
HelloGitHub2 分钟前
《HelloGitHub》第 109 期
开源·github
亚马逊云开发者5 分钟前
大胆试错、持续推进,拓展 GenAI 在客户服务领域的新场景
人工智能
我还没秃,还能学10 分钟前
神经网络笔记 - 神经网络
人工智能·笔记·神经网络
奋斗者1号13 分钟前
数据为基:机器学习中数值与分类数据的处理艺术及泛化实践
人工智能·机器学习·分类
东坡肘子25 分钟前
Chrome 会成为 OpenAI 的下一个目标?| 肘子的 Swift 周报 #081
人工智能·swiftui·swift
2301_7875528736 分钟前
AI-Browser适用于 ChatGPT、Gemini、Claude、DeepSeek、Grok的客户端开源应用程序,集成了 Monaco 编辑器。
人工智能·chatgpt·自动化·编辑器·deepseek
pljnb44 分钟前
门控循环单元(GRU)
人工智能·深度学习·gru
gaoenyang7605251 小时前
pytorch写张量pt文件,libtorch读张量pt文件
人工智能·pytorch·python
LeeZhao@2 小时前
【数据挖掘】时间序列预测-常用序列预测模型
人工智能·自然语言处理·数据挖掘·agi
没有梦想的咸鱼185-1037-16632 小时前
解锁空间数据新质生产力暨:AI(DeepSeek、ChatGPT)、Python、ArcGIS Pro多技术融合下的空间数据分析、建模与科研绘图及论文写作
人工智能·python·深度学习·机器学习·arcgis·chatgpt·数据分析