A multi-agent system that converts natural language optimization problems into validated Linear Programs using Pydantic AI agents with self-healing capabilities.
- 🤖 Pydantic AI Agents - Generate Linear Programs from natural language
- 🔧 Self-Healing - If LP validation fails, a fixer agent automatically corrects it
- 🎨 ChatGPT-style UI - Clean HTML/CSS/JS frontend with Bootstrap modals
- 🔄 Model Selection - Switch between GPT-4o, GPT-4o-mini, GPT-4-turbo, GPT-3.5-turbo
- 📝 LaTeX & Python Output - Get mathematical formulations and working code
- 🔐 User Authentication - Register/login with persistent sessions
- 💬 Chat History - Save and load previous conversations
- 🔑 Custom API Keys - Add your own API keys for OpenAI, Anthropic, Google, Groq, and more
- 📊 Usage Logging - Track model communication, tokens used, and response times
- 🗄️ PostgreSQL Database - Neon PostgreSQL for data persistence
- ☁️ Vercel Ready - Deploy to Vercel with serverless functions
The application uses PostgreSQL with the following tables:
- Users - User accounts (ID, username, password)
- Chat - Chat conversations (ID, userId, Name, originalPrompt, lastMessageId)
- Messages - Chat messages (ID, chatID, message, order, origin)
- Models - User's custom API keys (ID, userId, Name, API-key, provider, base_url)
- Logs - Model communication logs (ID, messageId, log, model_used, tokens_used, response_time_ms, was_healed)
git add .
git commit -m "Add database and auth support"
git pushAdd these environment variables in Vercel dashboard:
OPENAI_API_KEY=sk-your-key-here
PGHOST=your-neon-host.neon.tech
PGDATABASE=neondb
PGUSER=neondb_owner
PGPASSWORD=your-password
PGSSLMODE=require
SECRET_KEY=your-secret-key
- Go to vercel.com and import your GitHub repo
- Add the environment variables above
- Click Deploy
This repository is organized around the Vercel deployment path only:
api/contains the serverless Python handlerspublic/contains the static frontend assets served by Vercelvercel.jsondefines routing between the frontend and API handlersrequirements.txtandapi/requirements.txtdefine Python dependencies for deployment
The older local Flask server path has been removed to keep the workspace aligned with production.
POST /api/auth- Login or register (action: 'login'or'register')GET /api/auth- Validate token and get user infoDELETE /api/auth- Logout
POST /api/chat- Generate LP from promptGET /api/chats- Get user's chat historyGET /api/chats/:id- Get specific chat with messagesPOST /api/chats- Create new chatDELETE /api/chats/:id- Delete chat
GET /api/models- Get available default modelsGET /api/user-models- Get user's custom modelsPOST /api/user-models- Add custom model/API keyPUT /api/user-models/:id- Update custom modelDELETE /api/user-models/:id- Delete custom model
GET /api/logs- Get user's usage logs with summary
Users can add their own API keys for various providers:
| Provider | Base URL |
|---|---|
| OpenAI | https://api.openai.com/v1 |
| Anthropic | https://api.anthropic.com/v1 |
| Google AI | https://generativelanguage.googleapis.com/v1beta |
| Groq | https://api.groq.com/openai/v1 |
| Together AI | https://api.together.xyz/v1 |
| Custom | User-provided |
Signal-Mine-Senior-Project/
├── api/
│ ├── auth.py # Authentication API
│ ├── chat.py # LP generation API
│ ├── chats.py # Chat management API
│ ├── database.py # Database connection & models
│ ├── health.py # Health check API
│ ├── logs.py # Usage logs API
│ ├── models.py # Available models API
│ ├── user_models.py # Custom API keys API
│ └── requirements.txt
├── public/
│ ├── app.js # Frontend JavaScript
│ ├── index.html # Main HTML page
│ └── styles.css # Styles
├── .env # Environment variables
├── requirements.txt # Python dependencies
└── vercel.json # Vercel configuration
MIT