Spaces:
Sleeping
Sleeping
Add README and Dockerfile for Hugging Face deployment
Browse files- Dockerfile +28 -0
- README.md +88 -3
Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DeFi Agents Backend - Docker with uv
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Install uv (fast Python package manager)
|
| 7 |
+
ENV UV_SYSTEM=1
|
| 8 |
+
ENV UV_COMPILE_BYTECODE=1
|
| 9 |
+
|
| 10 |
+
# Hugging Face uses port 7860
|
| 11 |
+
ENV PORT=7860
|
| 12 |
+
|
| 13 |
+
RUN pip install --no-cache-dir uv
|
| 14 |
+
|
| 15 |
+
# Copy only requirements first (for better caching)
|
| 16 |
+
COPY pyproject.toml uv.lock* ./
|
| 17 |
+
|
| 18 |
+
# Install dependencies
|
| 19 |
+
RUN uv pip install --system -r pyproject.toml
|
| 20 |
+
|
| 21 |
+
# Copy application code
|
| 22 |
+
COPY . .
|
| 23 |
+
|
| 24 |
+
# Expose Hugging Face port
|
| 25 |
+
EXPOSE 7860
|
| 26 |
+
|
| 27 |
+
# Run the FastAPI server with uvicorn
|
| 28 |
+
CMD ["uv", "run", "python", "-m", "uvicorn", "web.app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -4,9 +4,94 @@ emoji: π
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: gray
|
| 6 |
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
-
license: mit
|
| 9 |
short_description: LLM-powered agents compete in an automated DeFi market
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: gray
|
| 6 |
sdk: docker
|
|
|
|
|
|
|
| 7 |
short_description: LLM-powered agents compete in an automated DeFi market
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# Agent Arena
|
| 11 |
+
|
| 12 |
+
Multi-agent LLM simulation in DeFi markets with emergent strategic arms races.
|
| 13 |
+
|
| 14 |
+
## Overview
|
| 15 |
+
|
| 16 |
+
Agent Arena is a simulation where AI agents powered by MiniMax-M2.1 compete in an automated DeFi market. Agents make strategic trading decisions, form alliances, and their behaviors evolve over time.
|
| 17 |
+
|
| 18 |
+
## Features
|
| 19 |
+
|
| 20 |
+
- AI agents powered by MiniMax-M2.1 with reasoning transparency
|
| 21 |
+
- Constant product AMM pool mechanics (like Uniswap)
|
| 22 |
+
- Real-time metrics including Gini coefficient, cooperation rates, and pool stability
|
| 23 |
+
- Strategic decision making with thinking traces
|
| 24 |
+
- Persistent storage with Supabase
|
| 25 |
+
|
| 26 |
+
## Architecture
|
| 27 |
+
|
| 28 |
+
```
|
| 29 |
+
defi-agents/
|
| 30 |
+
βββ api/ # API clients (MiniMax, Supabase)
|
| 31 |
+
βββ core/ # Core simulation (Agent, Pool, Simulation, Analyzer)
|
| 32 |
+
βββ web/ # FastAPI backend
|
| 33 |
+
βββ frontend/ # React dashboard (Vite + Tailwind)
|
| 34 |
+
βββ scripts/ # Database schema
|
| 35 |
+
βββ config.py # Configuration
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
## Getting Started
|
| 39 |
+
|
| 40 |
+
### Prerequisites
|
| 41 |
+
|
| 42 |
+
- Python 3.11+
|
| 43 |
+
- uv (Python package manager)
|
| 44 |
+
- MiniMax API key
|
| 45 |
+
- Supabase project
|
| 46 |
+
|
| 47 |
+
### Installation
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
# Clone the repository
|
| 51 |
+
git clone https://github.com/nice-bills/agent-arena.git
|
| 52 |
+
cd agent-arena
|
| 53 |
+
|
| 54 |
+
# Install dependencies
|
| 55 |
+
uv sync
|
| 56 |
+
|
| 57 |
+
# Set up environment variables
|
| 58 |
+
cp .env.example .env
|
| 59 |
+
# Edit .env with your API keys
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
### Running Locally
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
# Start the backend
|
| 66 |
+
uv run python web/app.py
|
| 67 |
+
|
| 68 |
+
# In another terminal, start the frontend
|
| 69 |
+
cd frontend
|
| 70 |
+
npm install
|
| 71 |
+
npm run dev
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## API Endpoints
|
| 75 |
+
|
| 76 |
+
| Method | Endpoint | Description |
|
| 77 |
+
|--------|----------|-------------|
|
| 78 |
+
| GET | /health | Health check |
|
| 79 |
+
| POST | /api/runs | Start a new simulation run |
|
| 80 |
+
| GET | /api/runs | List all runs |
|
| 81 |
+
| GET | /api/runs/{id} | Get run details |
|
| 82 |
+
| GET | /api/analysis/trends | Get trend analysis |
|
| 83 |
+
| GET | /api/thinking/{action_id} | Get thinking trace |
|
| 84 |
+
|
| 85 |
+
## Environment Variables
|
| 86 |
+
|
| 87 |
+
| Variable | Description |
|
| 88 |
+
|----------|-------------|
|
| 89 |
+
| MINIMAX_API_KEY | MiniMax API key |
|
| 90 |
+
| SUPABASE_URL | Supabase project URL |
|
| 91 |
+
| SUPABASE_KEY | Supabase anon key |
|
| 92 |
+
| NUM_AGENTS | Number of agents per run (default: 5) |
|
| 93 |
+
| TURNS_PER_RUN | Turns per simulation (default: 10) |
|
| 94 |
+
|
| 95 |
+
## License
|
| 96 |
+
|
| 97 |
+
MIT
|