diff --git a/MODEL_CONFIGURATION.md b/MODEL_CONFIGURATION.md new file mode 100644 index 000000000..4182cd1a5 --- /dev/null +++ b/MODEL_CONFIGURATION.md @@ -0,0 +1,437 @@ +# Model Configuration Guide + +This guide provides detailed instructions for configuring different AI model providers in ChatDev. + +## Table of Contents + +1. [OpenAI Models](#openai-models) +2. [Google Gemini Models](#google-gemini-models) +3. [DeepSeek Models](#deepseek-models) +4. [OpenAI-Compatible APIs](#openai-compatible-apis) +5. [Environment Variables Reference](#environment-variables-reference) +6. [Model Comparison](#model-comparison) + +--- + +## OpenAI Models + +### Supported Models + +- `GPT_3_5_TURBO` - Fast, cost-effective, good for simple projects +- `GPT_4` - High quality, best for complex projects +- `GPT_4_TURBO` - Latest GPT-4 with extended context +- `GPT_4O` - Optimized GPT-4 model +- `GPT_4O_MINI` - Lightweight version of GPT-4o + +### Setup + +1. **Get API Key:** + - Visit [OpenAI Platform](https://platform.openai.com/) + - Create an account or sign in + - Navigate to API Keys section + - Create a new API key + +2. **Set Environment Variable:** + ```bash + # Unix/Linux/macOS + export OPENAI_API_KEY="sk-your-key-here" + + # Windows (PowerShell) + $env:OPENAI_API_KEY="sk-your-key-here" + + # Windows (Command Prompt) + set OPENAI_API_KEY=sk-your-key-here + ``` + +3. **Optional: Custom Base URL** + For using OpenAI-compatible proxies or regional endpoints: + ```bash + export BASE_URL="https://api.openai.com/v1" + # Or for custom endpoint: + export BASE_URL="https://your-proxy.com/v1" + ``` + +4. **Run ChatDev:** + ```bash + python3 run.py --task "Your task" --name "Project" --model "GPT_4O" + ``` + +### Cost Considerations + +- GPT-3.5-turbo: ~$0.0015 per 1K tokens (input), ~$0.002 per 1K tokens (output) +- GPT-4: ~$0.03 per 1K tokens (input), ~$0.06 per 1K tokens (output) +- GPT-4 Turbo: ~$0.01 per 1K tokens (input), ~$0.03 per 1K tokens (output) +- GPT-4o: ~$0.005 per 1K tokens (input), ~$0.015 per 1K tokens (output) +- GPT-4o-mini: ~$0.00015 per 1K tokens (input), ~$0.0006 per 1K tokens (output) + +--- + +## Google Gemini Models + +### Supported Models + +- `GEMINI_PRO` - General purpose model +- `GEMINI_PRO_VISION` - Multimodal model with vision capabilities +- `GEMINI_1_5_PRO` - Latest Pro model with extended context (2M tokens) +- `GEMINI_1_5_FLASH` - Fast model with large context (1M tokens) + +### Setup + +1. **Get API Key:** + - Visit [Google AI Studio](https://makersuite.google.com/app/apikey) + - Sign in with your Google account + - Click "Create API Key" + - Copy your API key + +2. **Install Google Generative AI Library:** + ```bash + pip install google-generativeai + ``` + +3. **Set Environment Variables:** + ```bash + # Unix/Linux/macOS + export GOOGLE_API_KEY="your-google-api-key" + export MODEL_PROVIDER="gemini" + + # Windows + $env:GOOGLE_API_KEY="your-google-api-key" + $env:MODEL_PROVIDER="gemini" + ``` + +4. **Run ChatDev:** + ```bash + python3 run.py --task "Your task" --name "Project" --model "GEMINI_1_5_PRO" + ``` + +### Advantages + +- **Free Tier:** Generous free tier for testing +- **Large Context:** Up to 2M tokens context window +- **Multimodal:** Support for text and images (with vision models) +- **Global Availability:** Available in many regions + +### Limitations + +- May have different response format than OpenAI +- Some features may vary from OpenAI models + +--- + +## DeepSeek Models + +### Supported Models + +- `DEEPSEEK_CHAT` - General purpose chat model +- `DEEPSEEK_CODER` - Specialized for code generation +- `DEEPSEEK_CHAT_V2` - Latest version with improved performance + +### Setup + +1. **Get API Key:** + - Visit [DeepSeek Platform](https://platform.deepseek.com/) + - Sign up or log in + - Navigate to API section + - Create an API key + +2. **Set Environment Variables:** + ```bash + # Unix/Linux/macOS + export DEEPSEEK_API_KEY="your-deepseek-key" + export DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" + export MODEL_PROVIDER="deepseek" + + # Windows + $env:DEEPSEEK_API_KEY="your-deepseek-key" + $env:DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" + $env:MODEL_PROVIDER="deepseek" + ``` + +3. **Run ChatDev:** + ```bash + python3 run.py --task "Your task" --name "Project" --model "DEEPSEEK_CODER" + ``` + +### Advantages + +- **Cost-Effective:** Lower pricing than OpenAI +- **Code-Focused:** DeepSeek Coder excels at code generation +- **Regional Availability:** Good availability in Asia +- **OpenAI-Compatible:** Uses OpenAI-compatible API format + +### Best Use Cases + +- Code generation and software development +- Cost-sensitive projects +- Projects requiring frequent API calls + +--- + +## OpenAI-Compatible APIs + +Many providers offer OpenAI-compatible APIs, allowing you to use ChatDev with various models through a unified interface. + +### Supported Models + +- `CLAUDE_3_OPUS` - Anthropic's most capable model +- `CLAUDE_3_SONNET` - Balanced performance model +- `CLAUDE_3_HAIKU` - Fast and cost-effective +- `CLAUDE_3_5_SONNET` - Latest Claude model +- `LLAMA_3_70B` - Meta's Llama 3 (via compatible API) +- `LLAMA_3_8B` - Smaller Llama 3 model +- `MISTRAL_LARGE` - Mistral AI's large model +- `MISTRAL_MEDIUM` - Medium-sized Mistral model +- `MISTRAL_SMALL` - Small, fast Mistral model + +### Setup for OpenAI-Compatible APIs + +1. **Get API Key from Provider:** + - Each provider has its own signup process + - Obtain your API key from the provider's dashboard + +2. **Set Environment Variables:** + ```bash + # Use OPENAI_API_KEY with your provider's key + export OPENAI_API_KEY="your-provider-key" + + # Set BASE_URL to your provider's endpoint + export BASE_URL="https://api.provider.com/v1" + + # Keep provider as "openai" (uses OpenAI-compatible interface) + export MODEL_PROVIDER="openai" + ``` + +3. **Run ChatDev:** + ```bash + python3 run.py --task "Your task" --name "Project" --model "CLAUDE_3_SONNET" + ``` + +### Example Providers + +**Anthropic Claude (via proxy):** +```bash +export OPENAI_API_KEY="your-claude-key" +export BASE_URL="https://api.anthropic.com/v1" # If using proxy +export MODEL_PROVIDER="openai" +``` + +**Local Models (Ollama, vLLM, etc.):** +```bash +export OPENAI_API_KEY="ollama" # Not always required +export BASE_URL="http://localhost:11434/v1" # Ollama default +export MODEL_PROVIDER="openai" +``` + +**Regional Providers:** +```bash +export OPENAI_API_KEY="your-regional-key" +export BASE_URL="https://api.regional-provider.com/v1" +export MODEL_PROVIDER="openai" +``` + +--- + +## Environment Variables Reference + +### Common Variables + +| Variable | Description | Required | Default | +|----------|-------------|----------|---------| +| `OPENAI_API_KEY` | API key for OpenAI or compatible APIs | Yes* | - | +| `BASE_URL` | Custom API endpoint URL | No | OpenAI default | +| `MODEL_PROVIDER` | Provider type: "openai", "gemini", "deepseek" | No | "openai" | + +### Provider-Specific Variables + +#### Google Gemini +| Variable | Description | Required | +|----------|-------------|----------| +| `GOOGLE_API_KEY` | Google AI API key | Yes | + +#### DeepSeek +| Variable | Description | Required | +|----------|-------------|----------| +| `DEEPSEEK_API_KEY` | DeepSeek API key | Yes | +| `DEEPSEEK_BASE_URL` | DeepSeek API endpoint | No (default: https://api.deepseek.com/v1) | + +### Setting Variables Permanently + +**Unix/Linux/macOS (.bashrc/.zshrc):** +```bash +echo 'export OPENAI_API_KEY="your-key"' >> ~/.bashrc +source ~/.bashrc +``` + +**Windows (System Properties):** +1. Open System Properties → Environment Variables +2. Add new variable under User variables +3. Restart terminal + +**Using .env file:** +Create `.env` in ChatDev root: +``` +OPENAI_API_KEY=your-key +BASE_URL=https://api.openai.com/v1 +MODEL_PROVIDER=openai +``` + +Then load with: +```bash +export $(cat .env | xargs) +``` + +--- + +## Model Comparison + +### Performance Comparison + +| Model | Speed | Quality | Context | Cost | Best For | +|-------|-------|---------|---------|------|----------| +| GPT-3.5-turbo | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | 16K | $ | Simple projects, testing | +| GPT-4 | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 8K | $$$$ | Complex projects | +| GPT-4 Turbo | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 128K | $$$ | Large projects | +| GPT-4o | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 128K | $$$ | Balanced performance | +| GPT-4o-mini | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 128K | $ | Cost-effective | +| Gemini Pro | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 32K | Free/$ | General purpose | +| Gemini 1.5 Pro | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 2M | $$ | Large context | +| Gemini 1.5 Flash | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 1M | $ | Fast, large context | +| DeepSeek Chat | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 16K | $ | Cost-effective | +| DeepSeek Coder | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 16K | $ | Code generation | +| Claude 3 Sonnet | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 200K | $$$ | High quality | +| Claude 3 Haiku | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 200K | $ | Fast, quality | + +### Regional Availability + +| Provider | Americas | Europe | Asia | Other | +|----------|----------|--------|------|-------| +| OpenAI | ✅ | ✅ | ⚠️ | ✅ | +| Google Gemini | ✅ | ✅ | ✅ | ✅ | +| DeepSeek | ⚠️ | ⚠️ | ✅ | ⚠️ | +| Anthropic Claude | ✅ | ✅ | ⚠️ | ⚠️ | + +### Cost Comparison (Approximate) + +| Model | Input (per 1M tokens) | Output (per 1M tokens) | +|-------|----------------------|------------------------| +| GPT-3.5-turbo | $1.50 | $2.00 | +| GPT-4 | $30.00 | $60.00 | +| GPT-4 Turbo | $10.00 | $30.00 | +| GPT-4o | $5.00 | $15.00 | +| GPT-4o-mini | $0.15 | $0.60 | +| Gemini Pro | Free tier available | Free tier available | +| DeepSeek Chat | ~$0.14 | ~$0.28 | +| Claude 3 Sonnet | $3.00 | $15.00 | +| Claude 3 Haiku | $0.25 | $1.25 | + +--- + +## Troubleshooting + +### Common Issues + +**1. API Key Not Found:** +```bash +# Verify key is set +echo $OPENAI_API_KEY # or $GOOGLE_API_KEY, etc. + +# Re-export if missing +export OPENAI_API_KEY="your-key" +``` + +**2. Model Not Supported:** +- Check model name spelling (case-sensitive) +- Verify model is in supported list +- Check if provider is correctly configured + +**3. Rate Limits:** +- Use models with higher rate limits +- Add delays between requests +- Upgrade API plan +- Switch to different provider + +**4. Connection Issues:** +- Check internet connection +- Verify BASE_URL is correct +- Try different provider/region +- Check firewall settings + +**5. Import Errors:** +```bash +# Install missing dependencies +pip install google-generativeai # For Gemini +pip install -r requirements.txt # For all dependencies +``` + +--- + +## Best Practices + +1. **Start with Free/Low-Cost Models:** + - Use GPT-3.5-turbo or Gemini for testing + - Switch to premium models for production + +2. **Monitor Usage:** + - Set up usage alerts with your provider + - Track costs regularly + - Use cost-effective models when possible + +3. **Regional Considerations:** + - Choose providers with servers near you + - Consider latency for real-time applications + - Use regional endpoints when available + +4. **Model Selection:** + - Simple projects: GPT-3.5-turbo, Gemini Flash + - Complex projects: GPT-4, Gemini Pro, Claude + - Code-focused: DeepSeek Coder + - Large context: Gemini 1.5 Pro, Claude + +5. **Fallback Strategy:** + - Have multiple API keys ready + - Configure fallback models + - Test with different providers + +--- + +## Quick Reference + +### Command Examples + +```bash +# OpenAI +python3 run.py --task "Build app" --name "App" --model "GPT_4O" + +# Gemini +export GOOGLE_API_KEY="key" +python3 run.py --task "Build app" --name "App" --model "GEMINI_1_5_PRO" + +# DeepSeek +export DEEPSEEK_API_KEY="key" +python3 run.py --task "Build app" --name "App" --model "DEEPSEEK_CODER" +``` + +### Environment Setup Script + +Create `setup_env.sh`: +```bash +#!/bin/bash +# OpenAI +export OPENAI_API_KEY="your-key" + +# Or Gemini +# export GOOGLE_API_KEY="your-key" +# export MODEL_PROVIDER="gemini" + +# Or DeepSeek +# export DEEPSEEK_API_KEY="your-key" +# export DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" +# export MODEL_PROVIDER="deepseek" +``` + +Run: `source setup_env.sh` + +--- + +For more information, see the [TUTORIAL.md](TUTORIAL.md) or [Wiki](wiki.md). + diff --git a/README.md b/README.md index 15e405b73..4cba1a728 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,17 @@ To get started, follow these steps: - We thank [ManindraDeMel](https://github.com/ManindraDeMel) for providing Docker support. Please see [Docker Start Guide](wiki.md#docker-start). +## 📚 Complete Tutorial + +**New to ChatDev?** Start with our comprehensive [TUTORIAL.md](TUTORIAL.md) guide that covers: +- Step-by-step installation for all platforms +- Model configuration for OpenAI, Gemini, DeepSeek, and more +- Global accessibility setup +- Troubleshooting common issues +- Best practices and tips + +For model-specific configuration, see [MODEL_CONFIGURATION.md](MODEL_CONFIGURATION.md). + ## ✨️ Advanced Skills For more detailed information, please refer to our [Wiki](wiki.md), where you can find: diff --git a/TUTORIAL.md b/TUTORIAL.md new file mode 100644 index 000000000..078a1c83d --- /dev/null +++ b/TUTORIAL.md @@ -0,0 +1,633 @@ +# ChatDev Complete Tutorial: Build Software with AI Agents + +Welcome to the comprehensive tutorial for ChatDev! This guide will help you get started, configure different AI models, and build amazing software with AI agents, regardless of where you are in the world. + +## Table of Contents + +1. [Introduction](#introduction) +2. [Quick Start](#quick-start) +3. [Installation Guide](#installation-guide) +4. [Model Configuration](#model-configuration) +5. [Running Your First Project](#running-your-first-project) +6. [Advanced Configuration](#advanced-configuration) +7. [Troubleshooting](#troubleshooting) +8. [Best Practices](#best-practices) + +--- + +## Introduction + +ChatDev is a virtual software company powered by multiple AI agents that collaborate to build software. Each agent has a specific role (CEO, CTO, Programmer, Reviewer, Tester, etc.) and works together through specialized phases to create complete software projects. + +### What You Can Build + +- Desktop applications (with GUI) +- Web applications +- Command-line tools +- Games +- Data processing scripts +- And much more! + +--- + +## Quick Start + +### Prerequisites + +- **Python 3.9 or higher** (Python 3.10+ recommended) +- **An API key** from one of the supported AI providers: + - OpenAI (GPT models) + - Google (Gemini models) + - DeepSeek + - Or any OpenAI-compatible API endpoint + +### 5-Minute Setup + +1. **Clone the repository:** + ```bash + git clone https://github.com/OpenBMB/ChatDev.git + cd ChatDev + ``` + +2. **Create a virtual environment:** + ```bash + # Using conda (recommended) + conda create -n ChatDev python=3.9 -y + conda activate ChatDev + + # Or using venv + python3 -m venv ChatDev_env + source ChatDev_env/bin/activate # On Windows: ChatDev_env\Scripts\activate + ``` + +3. **Install dependencies:** + ```bash + pip install -r requirements.txt + ``` + +4. **Set your API key:** + ```bash + # For OpenAI (default) + export OPENAI_API_KEY="your-api-key-here" + + # For other providers, see Model Configuration section below + ``` + +5. **Run your first project:** + ```bash + python3 run.py --task "Create a simple calculator" --name "Calculator" + ``` + +That's it! Your software will be generated in the `WareHouse/` directory. + +--- + +## Installation Guide + +### Step-by-Step Installation + +#### 1. System Requirements + +- **Operating System:** Windows, macOS, or Linux +- **Python:** 3.9 or higher +- **RAM:** At least 4GB (8GB+ recommended) +- **Disk Space:** At least 2GB free space +- **Internet Connection:** Required for API calls + +#### 2. Python Installation + +**Windows:** +- Download Python from [python.org](https://www.python.org/downloads/) +- During installation, check "Add Python to PATH" +- Verify installation: `python --version` + +**macOS:** +- Python 3.9+ is usually pre-installed +- Verify: `python3 --version` +- If not installed, use Homebrew: `brew install python@3.9` + +**Linux:** +```bash +# Ubuntu/Debian +sudo apt update +sudo apt install python3.9 python3-pip python3-venv + +# Fedora/CentOS +sudo dnf install python3.9 python3-pip +``` + +#### 3. Install ChatDev + +```bash +# Clone the repository +git clone https://github.com/OpenBMB/ChatDev.git +cd ChatDev + +# Create virtual environment +python3 -m venv venv +source venv/bin/activate # Windows: venv\Scripts\activate + +# Install dependencies +pip install --upgrade pip +pip install -r requirements.txt +``` + +#### 4. Verify Installation + +```bash +python3 run.py --help +``` + +You should see the help message with all available options. + +--- + +## Model Configuration + +ChatDev supports multiple AI model providers. Choose the one that works best for you based on availability, cost, and performance in your region. + +### Supported Models + +| Provider | Models | API Key Variable | Base URL Variable | +|----------|--------|------------------|-------------------| +| **OpenAI** | GPT-3.5, GPT-4, GPT-4 Turbo, GPT-4o, GPT-4o-mini | `OPENAI_API_KEY` | `BASE_URL` (optional) | +| **Google Gemini** | gemini-pro, gemini-pro-vision | `GOOGLE_API_KEY` | - | +| **DeepSeek** | deepseek-chat, deepseek-coder | `DEEPSEEK_API_KEY` | `DEEPSEEK_BASE_URL` | +| **OpenAI-Compatible** | Any OpenAI-compatible API | `OPENAI_API_KEY` | `BASE_URL` | + +### Configuration Methods + +#### Method 1: Environment Variables (Recommended) + +**For OpenAI:** +```bash +# Unix/Linux/macOS +export OPENAI_API_KEY="sk-your-key-here" +export BASE_URL="https://api.openai.com/v1" # Optional, for custom endpoints + +# Windows (PowerShell) +$env:OPENAI_API_KEY="sk-your-key-here" +$env:BASE_URL="https://api.openai.com/v1" + +# Windows (Command Prompt) +set OPENAI_API_KEY=sk-your-key-here +set BASE_URL=https://api.openai.com/v1 +``` + +**For Google Gemini:** +```bash +# Unix/Linux/macOS +export GOOGLE_API_KEY="your-google-api-key" +export MODEL_PROVIDER="gemini" + +# Windows +$env:GOOGLE_API_KEY="your-google-api-key" +$env:MODEL_PROVIDER="gemini" +``` + +**For DeepSeek:** +```bash +# Unix/Linux/macOS +export DEEPSEEK_API_KEY="your-deepseek-key" +export DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" +export MODEL_PROVIDER="deepseek" + +# Windows +$env:DEEPSEEK_API_KEY="your-deepseek-key" +$env:DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" +$env:MODEL_PROVIDER="deepseek" +``` + +#### Method 2: Using .env File (Alternative) + +Create a `.env` file in the ChatDev root directory: + +```bash +# .env file +OPENAI_API_KEY=sk-your-key-here +BASE_URL=https://api.openai.com/v1 +MODEL_PROVIDER=openai +``` + +Then load it before running: +```bash +# Unix/Linux/macOS +export $(cat .env | xargs) + +# Or use python-dotenv (install: pip install python-dotenv) +``` + +#### Method 3: Command Line Arguments + +```bash +python3 run.py \ + --task "Your task description" \ + --name "ProjectName" \ + --model "GPT_4" \ + --config "Default" +``` + +### Model Selection Guide + +#### OpenAI Models + +| Model | Best For | Cost | Speed | +|-------|----------|------|-------| +| `GPT_3_5_TURBO` | Simple projects, testing | Low | Fast | +| `GPT_4` | Complex projects, high quality | High | Medium | +| `GPT_4_TURBO` | Large projects, best quality | Very High | Medium | +| `GPT_4O` | Latest features, balanced | High | Fast | +| `GPT_4O_MINI` | Cost-effective, good quality | Low | Very Fast | + +**Usage:** +```bash +python3 run.py --task "Build a web app" --name "WebApp" --model "GPT_4O" +``` + +#### Google Gemini Models + +**Setup:** +1. Get API key from [Google AI Studio](https://makersuite.google.com/app/apikey) +2. Set environment variables: + ```bash + export GOOGLE_API_KEY="your-key" + export MODEL_PROVIDER="gemini" + ``` +3. Use model name: `GEMINI_PRO` or `GEMINI_PRO_VISION` + +**Usage:** +```bash +python3 run.py --task "Build a game" --name "Game" --model "GEMINI_PRO" +``` + +#### DeepSeek Models + +**Setup:** +1. Get API key from [DeepSeek Platform](https://platform.deepseek.com/) +2. Set environment variables: + ```bash + export DEEPSEEK_API_KEY="your-key" + export DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" + export MODEL_PROVIDER="deepseek" + ``` +3. Use model name: `DEEPSEEK_CHAT` or `DEEPSEEK_CODER` + +**Usage:** +```bash +python3 run.py --task "Build a CLI tool" --name "CLITool" --model "DEEPSEEK_CHAT" +``` + +#### Using OpenAI-Compatible APIs + +Many providers offer OpenAI-compatible APIs. To use them: + +```bash +export OPENAI_API_KEY="your-provider-key" +export BASE_URL="https://api.your-provider.com/v1" +export MODEL_PROVIDER="openai" # Use OpenAI provider with custom base URL +``` + +Examples: +- **Anthropic Claude** (via proxy) +- **Local models** (via Ollama, vLLM, etc.) +- **Regional providers** (for better latency) + +--- + +## Running Your First Project + +### Basic Command + +```bash +python3 run.py --task "Your project description" --name "ProjectName" +``` + +### Command Options + +```bash +python3 run.py \ + --task "Create a todo list application with GUI" \ + --name "TodoApp" \ + --org "MyCompany" \ + --model "GPT_4O" \ + --config "Default" +``` + +**Parameters:** +- `--task`: Description of what you want to build (required) +- `--name`: Name of your project (required) +- `--org`: Organization name (default: "DefaultOrganization") +- `--model`: AI model to use (default: "GPT_3_5_TURBO") +- `--config`: Configuration preset (default: "Default") +- `--path`: Path to existing code for incremental development (optional) + +### Example Projects + +**1. Simple Calculator:** +```bash +python3 run.py --task "Create a calculator with GUI that can do basic math operations" --name "Calculator" +``` + +**2. Todo List App:** +```bash +python3 run.py --task "Build a todo list application with add, delete, and mark complete features" --name "TodoList" +``` + +**3. Game:** +```bash +python3 run.py --task "Create a simple snake game with score tracking" --name "SnakeGame" +``` + +**4. Web Scraper:** +```bash +python3 run.py --task "Build a web scraper that extracts article titles from a news website" --name "NewsScraper" +``` + +### Finding Your Generated Software + +After running, your software will be in: +``` +WareHouse/ProjectName_OrganizationName_Timestamp/ +``` + +Example: +``` +WareHouse/Calculator_DefaultOrganization_20240101120000/ +├── main.py +├── requirements.txt +├── manual.md +└── ... +``` + +### Running Generated Software + +```bash +cd WareHouse/ProjectName_OrganizationName_Timestamp +pip install -r requirements.txt +python3 main.py +``` + +--- + +## Advanced Configuration + +### Custom Company Configuration + +Create your own configuration in `CompanyConfig/YourConfig/`: + +```bash +mkdir -p CompanyConfig/MyConfig +cp CompanyConfig/Default/* CompanyConfig/MyConfig/ +``` + +Then edit the JSON files: +- `ChatChainConfig.json`: Development workflow +- `PhaseConfig.json`: Phase configurations +- `RoleConfig.json`: Agent role definitions + +Use your config: +```bash +python3 run.py --task "Your task" --name "Project" --config "MyConfig" +``` + +### Available Configurations + +- **Default**: Standard software development workflow +- **Art**: Includes image generation capabilities +- **Human**: Allows human interaction during code review +- **Incremental**: Build upon existing code + +### Incremental Development + +Build upon existing code: + +```bash +python3 run.py \ + --task "Add user authentication to the existing app" \ + --name "MyApp" \ + --path "/path/to/existing/code" +``` + +### Git Integration + +Enable Git version control in `CompanyConfig/Default/ChatChainConfig.json`: + +```json +{ + "git_management": "True" +} +``` + +### Memory/Experience Pool + +Enable experience-based learning: + +1. Set in `ChatChainConfig.json`: + ```json + { + "with_memory": "True" + } + ``` + +2. Prepare memory file at `ecl/memory/MemoryCards.json` + +--- + +## Troubleshooting + +### Common Issues + +#### 1. API Key Not Found + +**Error:** `KeyError: 'OPENAI_API_KEY'` + +**Solution:** +```bash +# Verify your API key is set +echo $OPENAI_API_KEY # Unix/Linux/macOS +echo %OPENAI_API_KEY% # Windows + +# Set it if missing +export OPENAI_API_KEY="your-key-here" +``` + +#### 2. Module Not Found + +**Error:** `ModuleNotFoundError: No module named 'xxx'` + +**Solution:** +```bash +# Reinstall dependencies +pip install -r requirements.txt --upgrade + +# Or install specific missing package +pip install package-name +``` + +#### 3. Model Not Supported + +**Error:** `ValueError: Unknown model` + +**Solution:** +- Check available models: `python3 run.py --help` +- Use supported model names (see Model Configuration section) +- For new providers, check if model backend is implemented + +#### 4. Rate Limit Errors + +**Error:** `Rate limit exceeded` or `429 Too Many Requests` + +**Solution:** +- Use a model with higher rate limits (e.g., GPT-3.5-turbo) +- Add delays between requests +- Upgrade your API plan +- Use a different provider + +#### 5. Connection Timeout + +**Error:** `Connection timeout` or network errors + +**Solution:** +- Check internet connection +- Use a provider with servers closer to your region +- Set custom BASE_URL for regional endpoints +- Increase timeout settings + +#### 6. Out of Memory + +**Error:** `Out of memory` or system crashes + +**Solution:** +- Use smaller models (GPT-3.5 instead of GPT-4) +- Reduce `max_turn_step` in configuration +- Close other applications +- Use cloud-based execution + +### Getting Help + +1. **Check Logs:** Look in `WareHouse/ProjectName_*/timestamp.log` +2. **GitHub Issues:** [Open an issue](https://github.com/OpenBMB/ChatDev/issues) +3. **Discord:** Join the [Discord community](https://discord.gg/bn4t2Jy6TT) +4. **Documentation:** Check [Wiki](wiki.md) for detailed guides + +--- + +## Best Practices + +### 1. Task Description Tips + +**Good:** +- "Create a calculator with GUI that supports addition, subtraction, multiplication, and division" +- "Build a todo list app with add, delete, edit, and mark complete features" +- "Develop a simple web scraper that extracts product names and prices from an e-commerce site" + +**Avoid:** +- "Make an app" (too vague) +- "Build something cool" (no specific requirements) +- Extremely complex multi-feature requests in one go + +### 2. Model Selection + +- **Start with GPT-3.5-turbo** for testing and simple projects +- **Use GPT-4 or GPT-4o** for complex projects requiring high quality +- **Try Gemini or DeepSeek** if OpenAI is unavailable in your region +- **Use GPT-4o-mini** for cost-effective development + +### 3. Project Organization + +- Use descriptive project names +- Set meaningful organization names +- Keep track of generated projects in `WareHouse/` +- Use Git integration for version control + +### 4. Cost Management + +- Monitor API usage and costs +- Use cheaper models for testing +- Set up usage alerts with your API provider +- Consider using local models for development + +### 5. Iterative Development + +- Start with simple features +- Use incremental mode to add features gradually +- Test generated code before adding complexity +- Use Human mode for manual review + +### 6. Regional Considerations + +- **China/Asia:** Consider DeepSeek or regional OpenAI proxies +- **Europe:** OpenAI or local providers +- **Americas:** OpenAI, Anthropic, or Google +- **Other regions:** Check provider availability and latency + +--- + +## Next Steps + +1. **Explore Examples:** Check `WareHouse/` for example projects +2. **Customize Workflows:** Create your own company configurations +3. **Join Community:** Share your projects and get help +4. **Read Wiki:** Deep dive into [advanced features](wiki.md) +5. **Contribute:** Help improve ChatDev for everyone + +--- + +## Quick Reference + +### Essential Commands + +```bash +# Basic usage +python3 run.py --task "description" --name "ProjectName" + +# With specific model +python3 run.py --task "description" --name "Project" --model "GPT_4O" + +# With custom config +python3 run.py --task "description" --name "Project" --config "Art" + +# Incremental development +python3 run.py --task "add feature" --name "Project" --path "/existing/code" +``` + +### Environment Variables + +```bash +# OpenAI +export OPENAI_API_KEY="sk-..." +export BASE_URL="https://api.openai.com/v1" # Optional + +# Google Gemini +export GOOGLE_API_KEY="..." +export MODEL_PROVIDER="gemini" + +# DeepSeek +export DEEPSEEK_API_KEY="..." +export DEEPSEEK_BASE_URL="https://api.deepseek.com/v1" +export MODEL_PROVIDER="deepseek" +``` + +### File Locations + +- **Generated Software:** `WareHouse/ProjectName_Org_Timestamp/` +- **Configurations:** `CompanyConfig/ConfigName/` +- **Logs:** `WareHouse/ProjectName_Org_Timestamp/timestamp.log` +- **Memory/Experience:** `ecl/memory/MemoryCards.json` + +--- + +## Support and Resources + +- **Documentation:** [Wiki](wiki.md) +- **GitHub:** [Repository](https://github.com/OpenBMB/ChatDev) +- **Discord:** [Community](https://discord.gg/bn4t2Jy6TT) +- **Issues:** [GitHub Issues](https://github.com/OpenBMB/ChatDev/issues) +- **Email:** qianc62@gmail.com + +--- + +**Happy Coding with ChatDev! 🚀** + +*Last Updated: 2024* + diff --git a/camel/model_backend.py b/camel/model_backend.py index c4b6b5879..da6359690 100644 --- a/camel/model_backend.py +++ b/camel/model_backend.py @@ -29,13 +29,19 @@ openai_new_api = False # old openai api version import os +import json -OPENAI_API_KEY = os.environ['OPENAI_API_KEY'] +OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY', '') if 'BASE_URL' in os.environ: BASE_URL = os.environ['BASE_URL'] else: BASE_URL = None +GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY', '') +DEEPSEEK_API_KEY = os.environ.get('DEEPSEEK_API_KEY', '') +DEEPSEEK_BASE_URL = os.environ.get('DEEPSEEK_BASE_URL', 'https://api.deepseek.com/v1') +MODEL_PROVIDER = os.environ.get('MODEL_PROVIDER', 'openai').lower() + class ModelBackend(ABC): r"""Base class for different model backends. @@ -65,21 +71,32 @@ def __init__(self, model_type: ModelType, model_config_dict: Dict) -> None: def run(self, *args, **kwargs): string = "\n".join([message["content"] for message in kwargs["messages"]]) - encoding = tiktoken.encoding_for_model(self.model_type.value) - num_prompt_tokens = len(encoding.encode(string)) + try: + encoding = tiktoken.encoding_for_model(self.model_type.value_for_tiktoken) + num_prompt_tokens = len(encoding.encode(string)) + except: + num_prompt_tokens = len(string.split()) * 1.3 gap_between_send_receive = 15 * len(kwargs["messages"]) num_prompt_tokens += gap_between_send_receive if openai_new_api: # Experimental, add base_url - if BASE_URL: + api_key = OPENAI_API_KEY + base_url = BASE_URL + + # Handle provider-specific configurations + if MODEL_PROVIDER == "deepseek" and DEEPSEEK_API_KEY: + api_key = DEEPSEEK_API_KEY + base_url = DEEPSEEK_BASE_URL + + if base_url: client = openai.OpenAI( - api_key=OPENAI_API_KEY, - base_url=BASE_URL, + api_key=api_key, + base_url=base_url, ) else: client = openai.OpenAI( - api_key=OPENAI_API_KEY + api_key=api_key ) num_max_token_map = { @@ -91,12 +108,26 @@ def run(self, *args, **kwargs): "gpt-4-0613": 8192, "gpt-4-32k": 32768, "gpt-4-turbo": 100000, - "gpt-4o": 4096, #100000 - "gpt-4o-mini": 16384, #100000 + "gpt-4o": 128000, + "gpt-4o-mini": 128000, + "gemini-pro": 32768, + "gemini-pro-vision": 16384, + "gemini-1.5-pro": 2097152, + "gemini-1.5-flash": 1048576, + "deepseek-chat": 16384, + "deepseek-coder": 16384, + "deepseek-chat-v2": 64000, + "claude-3-opus-20240229": 200000, + "claude-3-sonnet-20240229": 200000, + "claude-3-haiku-20240307": 200000, + "claude-3-5-sonnet-20241022": 200000, } - num_max_token = num_max_token_map[self.model_type.value] + num_max_token = num_max_token_map.get(self.model_type.value, 16384) num_max_completion_tokens = num_max_token - num_prompt_tokens - self.model_config_dict['max_tokens'] = num_max_completion_tokens + if num_max_completion_tokens > 0: + self.model_config_dict['max_tokens'] = num_max_completion_tokens + else: + self.model_config_dict['max_tokens'] = num_max_token response = client.chat.completions.create(*args, **kwargs, model=self.model_type.value, **self.model_config_dict) @@ -124,12 +155,26 @@ def run(self, *args, **kwargs): "gpt-4-0613": 8192, "gpt-4-32k": 32768, "gpt-4-turbo": 100000, - "gpt-4o": 4096, #100000 - "gpt-4o-mini": 16384, #100000 + "gpt-4o": 128000, + "gpt-4o-mini": 128000, + "gemini-pro": 32768, + "gemini-pro-vision": 16384, + "gemini-1.5-pro": 2097152, + "gemini-1.5-flash": 1048576, + "deepseek-chat": 16384, + "deepseek-coder": 16384, + "deepseek-chat-v2": 64000, + "claude-3-opus-20240229": 200000, + "claude-3-sonnet-20240229": 200000, + "claude-3-haiku-20240307": 200000, + "claude-3-5-sonnet-20241022": 200000, } - num_max_token = num_max_token_map[self.model_type.value] + num_max_token = num_max_token_map.get(self.model_type.value, 16384) num_max_completion_tokens = num_max_token - num_prompt_tokens - self.model_config_dict['max_tokens'] = num_max_completion_tokens + if num_max_completion_tokens > 0: + self.model_config_dict['max_tokens'] = num_max_completion_tokens + else: + self.model_config_dict['max_tokens'] = num_max_token response = openai.ChatCompletion.create(*args, **kwargs, model=self.model_type.value, **self.model_config_dict) @@ -149,6 +194,174 @@ def run(self, *args, **kwargs): return response +class GeminiModel(ModelBackend): + r"""Google Gemini API in a unified ModelBackend interface.""" + + def __init__(self, model_type: ModelType, model_config_dict: Dict) -> None: + super().__init__() + self.model_type = model_type + self.model_config_dict = model_config_dict + if not GOOGLE_API_KEY: + raise ValueError("GOOGLE_API_KEY environment variable is not set") + try: + import google.generativeai as genai + self.genai = genai + genai.configure(api_key=GOOGLE_API_KEY) + except ImportError: + raise ImportError("Please install google-generativeai: pip install google-generativeai") + + def run(self, *args, **kwargs): + try: + import google.generativeai as genai + except ImportError: + raise ImportError("Please install google-generativeai: pip install google-generativeai") + + if not GOOGLE_API_KEY: + raise ValueError("GOOGLE_API_KEY environment variable is not set") + + model = genai.GenerativeModel(self.model_type.value) + + messages = kwargs.get("messages", []) + # Build conversation history for Gemini + chat = model.start_chat(history=[]) + prompt_parts = [] + for msg in messages: + role = msg.get("role", "user") + content = msg.get("content", "") + if role == "user": + prompt_parts.append(content) + elif role == "assistant": + # For multi-turn, we'd need to maintain history + pass + + prompt = "\n".join(prompt_parts) if prompt_parts else "\n".join([msg.get("content", "") for msg in messages]) + + generation_config = { + "temperature": self.model_config_dict.get("temperature", 0.2), + "top_p": self.model_config_dict.get("top_p", 1.0), + "max_output_tokens": self.model_config_dict.get("max_tokens", 8192), + } + + try: + response = model.generate_content( + prompt, + generation_config=generation_config + ) + content = response.text if hasattr(response, 'text') and response.text else str(response) + except Exception as e: + log_visualize(f"**[Gemini_Error]** {str(e)}") + raise RuntimeError(f"Gemini API error: {str(e)}") + + # Estimate token usage (Gemini doesn't provide exact counts in free tier) + prompt_tokens = len(prompt.split()) * 1.3 + completion_tokens = len(content.split()) * 1.3 + + log_visualize( + "**[Gemini_Usage_Info Receive]**\nModel: {}\nprompt_tokens: ~{}\ncompletion_tokens: ~{}\ntotal_tokens: ~{}\n".format( + self.model_type.value, int(prompt_tokens), int(completion_tokens), int(prompt_tokens + completion_tokens))) + + # Return in OpenAI-compatible format + if openai_new_api: + from openai.types.chat import ChatCompletion + from openai.types.chat.chat_completion import Choice + from openai.types.chat.chat_completion_message import ChatCompletionMessage + from openai.types.completion_usage import CompletionUsage + + return ChatCompletion( + id=f"gemini-{self.model_type.value}", + object="chat.completion", + created=0, + model=self.model_type.value, + choices=[Choice( + index=0, + message=ChatCompletionMessage( + role="assistant", + content=content + ), + finish_reason="stop" + )], + usage=CompletionUsage( + prompt_tokens=int(prompt_tokens), + completion_tokens=int(completion_tokens), + total_tokens=int(prompt_tokens + completion_tokens) + ) + ) + else: + return { + "id": f"gemini-{self.model_type.value}", + "object": "chat.completion", + "created": 0, + "model": self.model_type.value, + "choices": [{ + "index": 0, + "message": { + "role": "assistant", + "content": content + }, + "finish_reason": "stop" + }], + "usage": { + "prompt_tokens": int(prompt_tokens), + "completion_tokens": int(completion_tokens), + "total_tokens": int(prompt_tokens + completion_tokens) + } + } + + +class DeepSeekModel(ModelBackend): + r"""DeepSeek API in a unified ModelBackend interface (OpenAI-compatible).""" + + def __init__(self, model_type: ModelType, model_config_dict: Dict) -> None: + super().__init__() + self.model_type = model_type + self.model_config_dict = model_config_dict + + def run(self, *args, **kwargs): + if not DEEPSEEK_API_KEY: + raise ValueError("DEEPSEEK_API_KEY environment variable is not set") + + string = "\n".join([message["content"] for message in kwargs["messages"]]) + try: + encoding = tiktoken.encoding_for_model("gpt-3.5-turbo") + num_prompt_tokens = len(encoding.encode(string)) + except: + num_prompt_tokens = len(string.split()) * 1.3 + + gap_between_send_receive = 15 * len(kwargs["messages"]) + num_prompt_tokens += gap_between_send_receive + + if openai_new_api: + client = openai.OpenAI( + api_key=DEEPSEEK_API_KEY, + base_url=DEEPSEEK_BASE_URL, + ) + + num_max_token_map = { + "deepseek-chat": 16384, + "deepseek-coder": 16384, + "deepseek-chat-v2": 64000, + } + num_max_token = num_max_token_map.get(self.model_type.value, 16384) + num_max_completion_tokens = num_max_token - num_prompt_tokens + if num_max_completion_tokens > 0: + self.model_config_dict['max_tokens'] = num_max_completion_tokens + else: + self.model_config_dict['max_tokens'] = num_max_token + + response = client.chat.completions.create(*args, **kwargs, model=self.model_type.value, + **self.model_config_dict) + + log_visualize( + "**[DeepSeek_Usage_Info Receive]**\nprompt_tokens: {}\ncompletion_tokens: {}\ntotal_tokens: {}\n".format( + response.usage.prompt_tokens, response.usage.completion_tokens, + response.usage.total_tokens)) + if not isinstance(response, ChatCompletion): + raise RuntimeError("Unexpected return from DeepSeek API") + return response + else: + raise RuntimeError("DeepSeek requires OpenAI API version 1.0.0 or higher") + + class StubModel(ModelBackend): r"""A dummy model used for unit tests.""" @@ -179,6 +392,10 @@ class ModelFactory: def create(model_type: ModelType, model_config_dict: Dict) -> ModelBackend: default_model_type = ModelType.GPT_3_5_TURBO + if model_type is None: + model_type = default_model_type + + # OpenAI models if model_type in { ModelType.GPT_3_5_TURBO, ModelType.GPT_3_5_TURBO_NEW, @@ -188,16 +405,40 @@ def create(model_type: ModelType, model_config_dict: Dict) -> ModelBackend: ModelType.GPT_4_TURBO_V, ModelType.GPT_4O, ModelType.GPT_4O_MINI, - None + }: + model_class = OpenAIModel + # Google Gemini models + elif model_type in { + ModelType.GEMINI_PRO, + ModelType.GEMINI_PRO_VISION, + ModelType.GEMINI_1_5_PRO, + ModelType.GEMINI_1_5_FLASH, + }: + model_class = GeminiModel + # DeepSeek models + elif model_type in { + ModelType.DEEPSEEK_CHAT, + ModelType.DEEPSEEK_CODER, + ModelType.DEEPSEEK_CHAT_V2, + }: + model_class = DeepSeekModel + # OpenAI-compatible models (Claude, Llama, Mistral, etc.) + elif model_type in { + ModelType.CLAUDE_3_OPUS, + ModelType.CLAUDE_3_SONNET, + ModelType.CLAUDE_3_HAIKU, + ModelType.CLAUDE_3_5_SONNET, + ModelType.LLAMA_3_70B, + ModelType.LLAMA_3_8B, + ModelType.MISTRAL_LARGE, + ModelType.MISTRAL_MEDIUM, + ModelType.MISTRAL_SMALL, }: model_class = OpenAIModel elif model_type == ModelType.STUB: model_class = StubModel else: - raise ValueError("Unknown model") - - if model_type is None: - model_type = default_model_type + raise ValueError(f"Unknown model: {model_type}") # log_visualize("Model Type: {}".format(model_type)) inst = model_class(model_type, model_config_dict) diff --git a/camel/typing.py b/camel/typing.py index e94987811..243ffbd65 100644 --- a/camel/typing.py +++ b/camel/typing.py @@ -44,6 +44,7 @@ class RoleType(Enum): class ModelType(Enum): + # OpenAI Models GPT_3_5_TURBO = "gpt-3.5-turbo-16k-0613" GPT_3_5_TURBO_NEW = "gpt-3.5-turbo-16k" GPT_4 = "gpt-4" @@ -52,12 +53,41 @@ class ModelType(Enum): GPT_4_TURBO_V = "gpt-4-turbo" GPT_4O = "gpt-4o" GPT_4O_MINI = "gpt-4o-mini" + + # Google Gemini Models + GEMINI_PRO = "gemini-pro" + GEMINI_PRO_VISION = "gemini-pro-vision" + GEMINI_1_5_PRO = "gemini-1.5-pro" + GEMINI_1_5_FLASH = "gemini-1.5-flash" + + # DeepSeek Models + DEEPSEEK_CHAT = "deepseek-chat" + DEEPSEEK_CODER = "deepseek-coder" + DEEPSEEK_CHAT_V2 = "deepseek-chat-v2" + + # Anthropic Claude (via OpenAI-compatible API) + CLAUDE_3_OPUS = "claude-3-opus-20240229" + CLAUDE_3_SONNET = "claude-3-sonnet-20240229" + CLAUDE_3_HAIKU = "claude-3-haiku-20240307" + CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022" + + # Other OpenAI-compatible models + LLAMA_3_70B = "llama-3-70b" + LLAMA_3_8B = "llama-3-8b" + MISTRAL_LARGE = "mistral-large" + MISTRAL_MEDIUM = "mistral-medium" + MISTRAL_SMALL = "mistral-small" STUB = "stub" @property def value_for_tiktoken(self): - return self.value if self.name != "STUB" else "gpt-3.5-turbo-16k-0613" + if self.name == "STUB": + return "gpt-3.5-turbo-16k-0613" + # For non-OpenAI models, use a default encoding + if self.value.startswith("gemini") or self.value.startswith("deepseek") or self.value.startswith("claude"): + return "gpt-3.5-turbo-16k-0613" # Fallback encoding + return self.value class PhaseType(Enum): diff --git a/requirements.txt b/requirements.txt index e7d65f408..f10ab9fff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,3 +17,4 @@ beautifulsoup4==4.12.2 faiss-cpu==1.7.4 pyyaml==6.0 easydict==1.10 +google-generativeai>=0.3.0 diff --git a/run.py b/run.py index 29293a758..bf618032a 100644 --- a/run.py +++ b/run.py @@ -79,7 +79,10 @@ def get_config(company): parser.add_argument('--name', type=str, default="Gomoku", help="Name of software, your software will be generated in WareHouse/name_org_timestamp") parser.add_argument('--model', type=str, default="GPT_3_5_TURBO", - help="GPT Model, choose from {'GPT_3_5_TURBO', 'GPT_4', 'GPT_4_TURBO', 'GPT_4O', 'GPT_4O_MINI'}") + help="AI Model, choose from OpenAI: {'GPT_3_5_TURBO', 'GPT_4', 'GPT_4_TURBO', 'GPT_4O', 'GPT_4O_MINI'}, " + "Gemini: {'GEMINI_PRO', 'GEMINI_1_5_PRO', 'GEMINI_1_5_FLASH'}, " + "DeepSeek: {'DEEPSEEK_CHAT', 'DEEPSEEK_CODER', 'DEEPSEEK_CHAT_V2'}, " + "or other OpenAI-compatible models") parser.add_argument('--path', type=str, default="", help="Your file directory, ChatDev will build upon your software in the Incremental mode") args = parser.parse_args() @@ -90,17 +93,36 @@ def get_config(company): # Init ChatChain # ---------------------------------------- config_path, config_phase_path, config_role_path = get_config(args.config) -args2type = {'GPT_3_5_TURBO': ModelType.GPT_3_5_TURBO, - 'GPT_4': ModelType.GPT_4, - # 'GPT_4_32K': ModelType.GPT_4_32k, - 'GPT_4_TURBO': ModelType.GPT_4_TURBO, - # 'GPT_4_TURBO_V': ModelType.GPT_4_TURBO_V - 'GPT_4O': ModelType.GPT_4O, - 'GPT_4O_MINI': ModelType.GPT_4O_MINI, - } +args2type = { + # OpenAI Models + 'GPT_3_5_TURBO': ModelType.GPT_3_5_TURBO, + 'GPT_4': ModelType.GPT_4, + 'GPT_4_TURBO': ModelType.GPT_4_TURBO, + 'GPT_4O': ModelType.GPT_4O, + 'GPT_4O_MINI': ModelType.GPT_4O_MINI, + # Google Gemini Models + 'GEMINI_PRO': ModelType.GEMINI_PRO, + 'GEMINI_PRO_VISION': ModelType.GEMINI_PRO_VISION, + 'GEMINI_1_5_PRO': ModelType.GEMINI_1_5_PRO, + 'GEMINI_1_5_FLASH': ModelType.GEMINI_1_5_FLASH, + # DeepSeek Models + 'DEEPSEEK_CHAT': ModelType.DEEPSEEK_CHAT, + 'DEEPSEEK_CODER': ModelType.DEEPSEEK_CODER, + 'DEEPSEEK_CHAT_V2': ModelType.DEEPSEEK_CHAT_V2, + # Anthropic Claude (via OpenAI-compatible API) + 'CLAUDE_3_OPUS': ModelType.CLAUDE_3_OPUS, + 'CLAUDE_3_SONNET': ModelType.CLAUDE_3_SONNET, + 'CLAUDE_3_HAIKU': ModelType.CLAUDE_3_HAIKU, + 'CLAUDE_3_5_SONNET': ModelType.CLAUDE_3_5_SONNET, +} if openai_new_api: args2type['GPT_3_5_TURBO'] = ModelType.GPT_3_5_TURBO_NEW +if args.model not in args2type: + print(f"Warning: Model '{args.model}' not found in supported models. Using GPT_3_5_TURBO as default.") + print(f"Supported models: {', '.join(args2type.keys())}") + args.model = 'GPT_3_5_TURBO' + chat_chain = ChatChain(config_path=config_path, config_phase_path=config_phase_path, config_role_path=config_role_path,