Skip to content

Mahdi-Rashidiyan/DeepCode

Repository files navigation

DeepCode - REST API Agent Setup Guide

What is DeepCode?

DeepCode is an AI coding agent that uses Ollama (local AI models) to help you build REST APIs, apps, and more. It doesn't work as a traditional REST API - instead, it communicates with Ollama running on your machine.


Prerequisites

1. Install Ollama

2. Install Python Dependencies

cd "c:\Users\Liver\OneDrive\Desktop\DeepCode"
pip install requests rich watchdog

3. Start Ollama Server

ollama serve

Leave this terminal window open. You should see:

Listening on 127.0.0.1:11434

4. Pull AI Models (in another terminal)

# Fast model (for quick iterations)
ollama pull qwen2.5-coder

# Powerful model (for complex tasks)
ollama pull deepseek-coder-v2:16b

Running DeepCode

# Navigate to project
cd "c:\Users\Liver\OneDrive\Desktop\DeepCode"

# Run the agent
python deepcode.py

How It Works

┌─────────────────────────────────────────┐
│  Your Task (e.g., "Build REST API")     │
└────────────┬────────────────────────────┘
             │
             ▼
┌─────────────────────────────────────────┐
│  DeepCode Agent (this script)            │
│  - Analyzes your task                    │
│  - Selects appropriate model             │
│  - Breaks down into actions              │
└────────────┬────────────────────────────┘
             │
             ▼
┌─────────────────────────────────────────┐
│  Ollama Server (localhost:11434)         │
│  - Qwen2 model (fast)                    │
│  - DeepSeek model (powerful)             │
└────────────┬────────────────────────────┘
             │
             ▼
┌─────────────────────────────────────────┐
│  Generated Code & Changes                │
└─────────────────────────────────────────┘

Example Commands

Build a Simple REST API

You > build a rest api with flask for a todo app

This will:

  1. Detect it's a simple task → Use Qwen2 (fast)
  2. Read existing files
  3. Generate code
  4. Write files to disk
  5. Run commands as needed

Optimize Code

You > optimize the database queries and add caching

This will:

  1. Detect it's complex → Use DeepSeek (powerful)
  2. Analyze your code
  3. Suggest optimizations
  4. Implement improvements

API Endpoints (Ollama Internal)

These are what DeepCode uses internally:

Endpoint Purpose
GET /api/tags List available models
POST /api/generate Generate text (simple)
POST /api/chat Chat interface (advanced)

Note: These are NOT exposed publicly - only accessible locally at http://localhost:11434


Fixing 404 Errors

Error: "404 - Ollama API endpoint not found"

Cause: Ollama server not running or not accessible

Fix:

  1. Open new terminal
  2. Run: ollama serve
  3. Wait for message: Listening on 127.0.0.1:11434
  4. Go back to DeepCode terminal and try again

Error: "Model not found on Ollama"

Cause: Model not installed

Fix:

ollama pull qwen2.5-coder
ollama pull deepseek-coder-v2:16b

Smart Model Selection

DeepCode automatically chooses the best model:

Uses Qwen2 (⚡ Fast) for:

  • "Create a simple REST API"
  • "Add error handling"
  • "Fix typo in main.py"
  • "Update the homepage"

Uses DeepSeek (🚀 Powerful) for:

  • "Optimize database performance"
  • "Refactor architecture"
  • "Add machine learning model"
  • "Implement caching system"

Force a specific model:

You > use qwen
You > use deepseek

Features

Multi-Agent Collaboration

Enable to have 5 agents work together:

You > multiagent on

Agents:

  • Architect: Plans structure and design
  • Coder: Writes implementation
  • Reviewer: Reviews for bugs
  • Tester: Writes and runs tests
  • Optimizer: Optimizes performance

Code Evolution Tracking

See how your code changes:

You > evolution

Smart Context Analysis

You > context

Shows:

  • Tech stack detected
  • Dependencies found
  • File structure
  • Relevant files

Troubleshooting

My code works but getting 404 errors

This usually means:

  1. Ollama server crashed or stopped
  2. Connection lost between DeepCode and Ollama
  3. Model was unloaded from memory

Quick fix:

# Terminal 1: Restart Ollama
Stop-Process -Name ollama -Force
ollama serve

# Terminal 2: Run DeepCode again
python deepcode.py

DeepCode hangs or times out

Solutions:

  1. Check if Ollama is responding: curl http://localhost:11434/api/tags
  2. Restart Ollama
  3. Check available RAM (models need 4GB+)
  4. Close other applications

Model keeps failing

Solutions:

# Remove and reinstall model
ollama rm qwen2.5-coder
ollama pull qwen2.5-coder

# Or restart Ollama
ollama serve

System Requirements

Resource Minimum Recommended
RAM 4 GB 8+ GB
Disk 5 GB 10+ GB
CPU Any Multi-core
GPU Not required NVIDIA/AMD

Next Steps

  1. Start Ollama: ollama serve
  2. Run DeepCode: python deepcode.py
  3. Try a task: build a simple rest api
  4. Check results: Look at generated files
  5. View logs: Use troubleshooting guide if issues occur

Getting Help

About

DeepCode is an AI coding agent that uses **Ollama** (local AI models) to help you build REST APIs, apps, and more. It doesn't work as a traditional REST API - instead, it communicates with Ollama running on your machine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors