|
| 1 | +# Court Table AI - Multi-Agent Debate System |
| 2 | + |
| 3 | +A web-based application for managing AI agents and facilitating automatic debates/discussions between agents using a "Round Robin with Timeout" schema to generate the best answers for users. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Multi-Agent Management**: Configure and manage AI agents with different providers (Ollama, OpenAI, Anthropic, Google Gemini) |
| 8 | +- **Debate Engine**: Orchestrates discussions between multiple AI agents in a round-robin format |
| 9 | +- **Moderator Support**: Optional AI moderator to guide discussions, provide opening/closing remarks, and maintain discourse quality |
| 10 | +- **Multi-Provider Support**: Native support for OpenAI, Anthropic Claude, Google Gemini, Ollama, and custom OpenAI-compatible APIs |
| 11 | +- **Real-time Updates**: Server-Sent Events (SSE) for live debate updates |
| 12 | +- **Web Dashboard**: Clean, responsive UI built with HTML, HTMX, and Tailwind CSS |
| 13 | +- **History Tracking**: Complete discussion history with agent responses and timestamps |
| 14 | +- **Agent Health Checks**: Ping agents to verify connectivity |
| 15 | + |
| 16 | +## Technology Stack |
| 17 | + |
| 18 | +- **Backend**: Go (Golang) with Echo framework |
| 19 | +- **Frontend**: HTML5/HTMX, Tailwind CSS, Vanilla JavaScript |
| 20 | +- **Database**: SQLite for lightweight, local data storage |
| 21 | +- **AI Integration**: REST API supporting OpenAI format and Ollama API |
| 22 | + |
| 23 | +## Quick Start |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +- Go 1.24+ installed |
| 28 | +- An AI provider (Ollama, OpenAI, or OpenAI-compatible API) |
| 29 | + |
| 30 | +### Installation |
| 31 | + |
| 32 | +1. Clone the repository: |
| 33 | +```bash |
| 34 | +git clone <repository-url> |
| 35 | +cd CourtTableAI |
| 36 | +``` |
| 37 | + |
| 38 | +2. Install dependencies: |
| 39 | +```bash |
| 40 | +go mod tidy |
| 41 | +``` |
| 42 | + |
| 43 | +3. Build and run: |
| 44 | +```bash |
| 45 | +go build cmd/main.go cmd/renderer.go |
| 46 | +./main.exe # on Windows |
| 47 | +# or |
| 48 | +./main # on Unix systems |
| 49 | +``` |
| 50 | + |
| 51 | +4. Open your browser and navigate to `http://localhost:8080` |
| 52 | + |
| 53 | +## Usage |
| 54 | + |
| 55 | +### 1. Add AI Agents |
| 56 | + |
| 57 | +1. Go to the **Agents** page |
| 58 | +2. Click **Add New Agent** |
| 59 | +3. Fill in the agent details: |
| 60 | + - **Name**: Display name for the agent |
| 61 | + - **Provider URL**: API endpoint (e.g., `http://localhost:11434` for Ollama) |
| 62 | + - **API Token**: Authentication token (if required) |
| 63 | + - **Model Name**: Model to use (e.g., `llama2`, `gpt-3.5-turbo`) |
| 64 | + - **Timeout**: Response timeout in seconds |
| 65 | + |
| 66 | +4. Test the connection with **Test Connection** |
| 67 | + |
| 68 | +### 2. Start a Discussion |
| 69 | + |
| 70 | +1. Go to the **Discussions** page |
| 71 | +2. Click **Start New Discussion** |
| 72 | +3. Enter the discussion topic |
| 73 | +4. Select the agents to participate |
| 74 | +5. Optionally select a **Moderator** to guide the discussion |
| 75 | +6. Click **Start Discussion** |
| 76 | + |
| 77 | +The debate engine will: |
| 78 | +- Send the topic to the first agent |
| 79 | +- If a moderator is selected, they will provide opening remarks |
| 80 | +- Pass responses from one agent to the next as context |
| 81 | +- Moderator provides interim commentary between agent responses |
| 82 | +- Moderator summarizes each round and provides closing remarks |
| 83 | +- Handle timeouts and errors gracefully |
| 84 | +- Generate a final summary |
| 85 | + |
| 86 | +### 3. Monitor Discussions |
| 87 | + |
| 88 | +- View real-time updates on the discussion detail page |
| 89 | +- See agent responses, timestamps, and response times |
| 90 | +- Retry failed agent responses |
| 91 | +- Stop running discussions |
| 92 | +- View discussion history |
| 93 | + |
| 94 | +## API Endpoints |
| 95 | + |
| 96 | +### Agents |
| 97 | +- `GET /api/agents` - List all agents |
| 98 | +- `POST /api/agents` - Create new agent |
| 99 | +- `GET /api/agents/:id` - Get agent details |
| 100 | +- `PUT /api/agents/:id` - Update agent |
| 101 | +- `DELETE /api/agents/:id` - Delete agent |
| 102 | +- `POST /api/agents/:id/ping` - Test agent connectivity |
| 103 | + |
| 104 | +### Discussions |
| 105 | +- `GET /api/discussions` - List all discussions |
| 106 | +- `POST /api/discussions` - Create new discussion |
| 107 | +- `GET /api/discussions/:id` - Get discussion details with logs |
| 108 | +- `POST /api/discussions/:id/stop` - Stop running discussion |
| 109 | +- `POST /api/discussions/:id/retry/:agentId` - Retry failed agent response |
| 110 | + |
| 111 | +### Real-time Updates |
| 112 | +- `GET /api/discussions/:id/stream` - Server-Sent Events stream |
| 113 | + |
| 114 | +## Database Schema |
| 115 | + |
| 116 | +### Agents Table |
| 117 | +```sql |
| 118 | +CREATE TABLE agents ( |
| 119 | + id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 120 | + name TEXT NOT NULL UNIQUE, |
| 121 | + provider_url TEXT NOT NULL, |
| 122 | + api_token TEXT NOT NULL, |
| 123 | + model_name TEXT NOT NULL, |
| 124 | + timeout_seconds INTEGER DEFAULT 30, |
| 125 | + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
| 126 | + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP |
| 127 | +); |
| 128 | +``` |
| 129 | + |
| 130 | +### Discussions Table |
| 131 | +```sql |
| 132 | +CREATE TABLE discussions ( |
| 133 | + id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 134 | + topic TEXT NOT NULL, |
| 135 | + final_summary TEXT, |
| 136 | + status TEXT DEFAULT 'running', |
| 137 | + agent_ids TEXT NOT NULL, |
| 138 | + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
| 139 | + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP |
| 140 | +); |
| 141 | +``` |
| 142 | + |
| 143 | +### Discussion Logs Table |
| 144 | +```sql |
| 145 | +CREATE TABLE discussion_logs ( |
| 146 | + id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 147 | + discussion_id INTEGER NOT NULL, |
| 148 | + agent_id INTEGER NOT NULL, |
| 149 | + content TEXT, |
| 150 | + status TEXT NOT NULL, |
| 151 | + response_time INTEGER DEFAULT 0, |
| 152 | + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, |
| 153 | + FOREIGN KEY (discussion_id) REFERENCES discussions(id) ON DELETE CASCADE, |
| 154 | + FOREIGN KEY (agent_id) REFERENCES agents(id) ON DELETE CASCADE |
| 155 | +); |
| 156 | +``` |
| 157 | + |
| 158 | +## Supported AI Providers |
| 159 | + |
| 160 | +### Ollama |
| 161 | +- **Provider URL**: `http://localhost:11434` |
| 162 | +- **Model Name**: Any model available in Ollama (e.g., `llama2`, `mistral`) |
| 163 | + |
| 164 | +### OpenAI Compatible APIs |
| 165 | +- **Provider URL**: API endpoint (e.g., `https://api.openai.com/v1`) |
| 166 | +- **API Token**: Your API key |
| 167 | +- **Model Name**: `gpt-3.5-turbo`, `gpt-4`, etc. |
| 168 | + |
| 169 | +## Configuration |
| 170 | + |
| 171 | +The application uses a SQLite database file (`court_table_ai.db`) that will be created automatically on first run. |
| 172 | + |
| 173 | +## Development |
| 174 | + |
| 175 | +### Project Structure |
| 176 | + |
| 177 | +``` |
| 178 | +CourtTableAI/ |
| 179 | +├── cmd/ |
| 180 | +│ ├── main.go # Application entry point |
| 181 | +│ └── renderer.go # Template renderer |
| 182 | +├── pkg/ |
| 183 | +│ ├── database/ # Database operations |
| 184 | +│ ├── handlers/ # HTTP handlers |
| 185 | +│ ├── models/ # Data models |
| 186 | +│ └── orchestrator/ # Debate engine and agent client |
| 187 | +├── static/ # Static files (CSS, JS) |
| 188 | +├── templates/ # HTML templates |
| 189 | +├── go.mod # Go module file |
| 190 | +└── go.sum # Go dependencies |
| 191 | +``` |
| 192 | + |
| 193 | +### Running in Development Mode |
| 194 | + |
| 195 | +```bash |
| 196 | +go run cmd/main.go cmd/renderer.go |
| 197 | +``` |
| 198 | + |
| 199 | +## License |
| 200 | + |
| 201 | +This project is open source and available under the [MIT License](LICENSE). |
| 202 | + |
| 203 | +## Contributing |
| 204 | + |
| 205 | +1. Fork the repository |
| 206 | +2. Create a feature branch |
| 207 | +3. Make your changes |
| 208 | +4. Add tests if applicable |
| 209 | +5. Submit a pull request |
| 210 | + |
| 211 | +## Support |
| 212 | + |
| 213 | +For issues and questions: |
| 214 | +1. Check the existing issues |
| 215 | +2. Create a new issue with detailed information |
| 216 | +3. Include logs and configuration details |
0 commit comments