You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CortexaAI is an advanced multi-agent system that automatically classifies, optimizes, and evaluates prompts using domain-specific expert agents powered by LangChain and LangGraph. It supports 6 LLM providers, real-time SSE streaming, batch processing, a prompt marketplace, and exposes 79 REST API endpoints — all orchestrated through a 7-node LangGraph workflow with cancellation support, per-node timing, and adaptive iteration.
✨ Key Features
Multi-Agent Architecture
Domain Classifier — Automatically detects the domain of any prompt (software engineering, data science, education, business strategy, creative writing, report writing) using keyword heuristics + LLM reasoning
Expert Agents — Dynamically spawned, domain-specialized prompt engineers with structured output and multi-angle reasoning (Executor / Critic / Expert perspectives)
Evaluator — Rigorous 6-criteria scoring engine (clarity, specificity, structure, completeness, actionability, domain alignment) with calibration anchors and evidence-based assessment
Coordinator — Orchestrates the full classify → improve → evaluate loop with security, caching, rate limiting, and memory context support
Interactive refinement — AI asks clarifying questions before optimizing your prompt
Context retention — Maintains chat history across conversation turns
Seamless transition — Automatically switches to full optimization when enough context is gathered
Synchronous responses — Instant replies without polling delays
Batch Processing
Process multiple prompts in a single API call
Configurable concurrency (1–10 parallel workers)
Progress tracking and result aggregation
Additional Features
Prompt Templates Library — Curated, domain-specific templates with variable substitution, real-time collaborative editing, and privacy controls (public/private templates)
Prompt Marketplace — Publish, search, download, and rate community prompt templates with complete user isolation and live updates across all active sessions
# Required: At least one providerGOOGLE_API_KEY=your_google_api_key_here# Optional: Additional providersOPENAI_API_KEY=your_openai_api_key_hereANTHROPIC_API_KEY=your_anthropic_api_key_hereGROQ_API_KEY=your_groq_api_key_hereDEEPSEEK_API_KEY=your_deepseek_api_key_hereOPENROUTER_API_KEY=your_openrouter_api_key_here# Optional: LangSmith tracingLANGSMITH_API_KEY=your_langsmith_api_key_hereLANGSMITH_PROJECT=cortexaai# Model configurationDEFAULT_MODEL_PROVIDER=googleDEFAULT_MODEL_NAME=gemma-3-27b-it# ServerHOST=0.0.0.0PORT=8000LOG_LEVEL=INFO# Prompt optimizationEVALUATION_THRESHOLD=0.82MAX_EVALUATION_ITERATIONS=1# CORS (comma-separated)CORS_ORIGINS=http://localhost:3000,http://localhost:5173
4. Frontend Setup
cd frontend-react
npm install
npm run build # Production build# OR
npm run dev # Development server (hot reload on port 5173)
5. Start the Application
# From project root
python src/main.py
The server starts at http://localhost:8000:
Web UI: http://localhost:8000 (serves the built React SPA)
API Docs (Swagger): http://localhost:8000/docs
API Docs (ReDoc): http://localhost:8000/redoc
📖 Usage
Web Interface
The React frontend provides three main pages:
Prompt Processor (/) — Submit prompts for optimization, view real-time progress, compare original vs. optimized output
Dashboard (/dashboard) — System statistics, workflow history, provider health status, domain distribution charts
Templates (/templates) — Browse, create, and manage prompt templates with variable substitution
API Usage
Process a Prompt (Synchronous)
curl -X POST http://localhost:8000/api/process-prompt \
-H "Content-Type: application/json" \
-d '{ "prompt": "Write a Python function to sort a list", "prompt_type": "auto", "synchronous": true, "return_comparison": true }'
Process a Prompt (Async with Status Polling)
# Start workflow
curl -X POST http://localhost:8000/api/process-prompt \
-H "Content-Type: application/json" \
-d '{ "prompt": "Create a marketing strategy for a SaaS product", "prompt_type": "auto" }'# Returns: { "workflow_id": "workflow_...", "status": "running", ... }# Poll status
curl http://localhost:8000/api/workflow-status/{workflow_id}
Stream Processing (SSE)
curl -X POST http://localhost:8000/api/process-prompt/stream \
-H "Content-Type: application/json" \
-d '{"prompt": "Design a REST API for a todo app", "prompt_type": "auto"}'
curl -X POST http://localhost:8000/api/batch \
-H "Content-Type: application/json" \
-d '{ "prompts": [ {"prompt": "Write a unit test for authentication"}, {"prompt": "Create a data visualization dashboard"}, {"prompt": "Draft a quarterly business report"} ], "concurrency": 3 }'
LangGraph Studio
Visualize and debug the workflow graph interactively:
The project uses pytest with async support for the backend and Vitest for the frontend.
Run Backend Tests
# Run all tests
python -m pytest tests/
# Run with coverage report
python -m pytest tests/ --cov=agents --cov=config --cov=core --cov=src --cov-report=html
# Run specific test categories
python -m pytest tests/ -m unit # Unit tests only
python -m pytest tests/ -m "not slow"# Skip slow tests# Run a specific test file
python -m pytest tests/test_main.py -v
Run Frontend Tests
cd frontend-react
npm test# Run tests
npm run test:ui # Run with Vitest UI
Code Quality
# Lint and auto-fix
ruff check . --fix
# Format code
ruff format .# Security audit
safety check -r requirements.txt
# Type checking (optional)
mypy src/ agents/ config/ core/
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for detailed guidelines covering:
Development environment setup
Code style (Ruff enforced — PEP 8, import sorting, type checking)
Pull request process
Issue reporting templates
Testing requirements
Quick Start for Contributors
# Fork & clone
git clone https://github.com/YOUR_USERNAME/CortexaAI.git
cd CortexaAI
# Setup
python -m venv venv &&source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # Add at least one API key# Verify
python -m pytest tests/
ruff check .# Create feature branch
git checkout -b feature/your-feature
📄 License
This project is licensed under the MIT License — see the LICENSE file for details.