A lightweight AI agent powered by the DeepSeek API that can list directories and write code to files.
- 📂 List directories — Explore the contents of any directory on your filesystem
- ✍️ Write code/files — Ask for code and the agent will save it directly to a new file
- 🔄 Streaming responses — See the agent's reply as it's generated
- 🔧 Extensible tool system — Add new capabilities by dropping a file into
tools/
- Python 3.10+
- A DeepSeek API key
-
Clone the repo and navigate into the project folder.
-
Install dependencies:
pip install -r requirements.txt
-
Set your API key:
# Windows (PowerShell) set DEEPSEEK_API_KEY=your_key_here
Or create a
.envfile in the project root:DEEPSEEK_API_KEY=your_key_here
python deepseek_chat.pyType your requests at the You: prompt. The agent can:
| You say... | It does |
|---|---|
| "List the files in the current directory" | Calls list_directory |
| "What's in C:\Projects?" | Calls list_directory |
| "Write a Python script that prints hello" | Generates the code and calls create_file |
| "Create a React component called Button" | Writes the component to a file |
| "Tell me a joke" | ❌ Refuses — outside its capabilities |
Type quit, exit, or q, or press Ctrl+C to stop.
├── deepseek_chat.py # Main agent — orchestrates the chat loop
├── requirements.txt # Python dependencies
├── README.md
└── tools/
├── __init__.py # Registers all tool definitions + dispatch
├── list_directory.py # Tool: list directory contents
└── create_file.py # Tool: create a file with content
-
Create
tools/your_tool.pywith:definition— the OpenAI-compatible function schemahandler(**kwargs)— the Python function that runs the tool
-
Register it in
tools/__init__.py:from . import your_tool definitions = [ list_directory.definition, create_file.definition, your_tool.definition, ] dispatch = { "list_directory": list_directory.handler, "create_file": create_file.handler, "your_tool": your_tool.handler, }
No changes needed in deepseek_chat.py — it automatically picks up whatever is in tools/__init__.py.
Uses DeepSeek's API via the OpenAI-compatible SDK. The model is configured as deepseek-v4-pro in the streaming response handler.