- This repository contains a powerful coding assistant application that integrates the DeepSeek API, capable of handling user conversations and generating structured JSON responses. Users can read local file content, create new files, and modify existing files in real time through a command-line interface.
-
DeepSeek Client Configuration
- Automatically configures the API client to connect to DeepSeek services using a valid
DEEPSEEK_API_KEY. - Streams GPT-style responses based on the DeepSeek endpoint specified via environment variables.
- Automatically configures the API client to connect to DeepSeek services using a valid
-
Data Models
- Uses Pydantic for type-safe file operations, including:
- FileToCreate: Describes files to create or update.
- FileToEdit: Describes code snippets to replace in existing files.
- AssistantResponse: Structured chat responses with optional file operations.
- Uses Pydantic for type-safe file operations, including:
-
System Prompt
- A comprehensive system prompt (
system_PROMPT) guides conversations to ensure strict adherence to JSON output formats, including file creation/editing instructions.
- A comprehensive system prompt (
-
Utility Functions
read_local_file: Reads and returns the content of a specified file as a string.create_file: Creates/overwrites files with user-provided content.show_diff_table: Displays proposed file changes in a tabular format.apply_diff_edit: Applies snippet-level modifications to existing files.
-
/addCommand- Use
/add path/to/fileto quickly read a file's content and insert it into the conversation. - Use
/add path/to/folderto add all files in a directory (excluding binaries/hidden files) to the conversation.
- Use
-
Conversation Flow
- Maintains a
conversation_historylist to track user/assistant messages. - Streams assistant responses via the DeepSeek API, parsed into JSON for text replies and file operation instructions.
- Maintains a
-
Interactive Session
- Run the script (e.g.,
python3 main.py) to start an interactive loop. - Enter requests or coding questions; use
/add path/to/fileto inject file content. - Approve/reject file changes when proposed by the assistant.
- Type
exitorquitto end the session.
- Run the script (e.g.,
-
If you don’t have a
DEEPSEEK_KEY, register at https://api-docs.deepseek.com/ (takes ~5 minutes). New accounts typically receive 10 CNY credits. -
Configure the
.envfile with your DeepSeek API key:DEEPSEEK_KEY=your_api_key_here -
Install dependencies and run (choose one method):
- Using pip:
git clone --depth 1 https://github.com/dkustec/deepseek-quickstart pip install -r requirements.txt python3 main.py
- Using pip:
-
Experience features like multi-line streaming responses,
/add path/to/filefor file injection, and precise file edits after approval.
The main-r1.py script uses DeepSeek’s reasoning model (deepseek-reasoner) with Chain-of-Thought (CoT) support:
- Displays reasoning steps before final answers.
- Retains all file operations and diff-editing capabilities.
- Shows intermediate reasoning while logging only final conclusions.
Start with python3 main-r1.py for an enhanced reasoning experience.
Note: This is an experimental project by xiaomingx to test DeepSeek v3 API features. Use as a rapid prototyping tool with caution.
- Official DeepSeek repository: https://github.com/deepseek-ai
- I’m still exploring the API myself! 🚀