CoolFace
Apppublic

NLarchive/Qagents-workflows

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

VIDEO: https://youtu.be/skqbaI25G7g

SOCIAL: https://www.linkedin.com/posts/nicolas-larenasqagents-quantum-circuit-orchestrator-a-activity-7401019630393118720-ofPA?utmsource=share&utmmedium=memberdesktop&rcm=ACoAADmu0wIBjvA0DVdHvqncNUVTEW72gbiGUps

QAgents-Workflows: Quantum Circuit Optimization Agent System

A professional multi-agent system for autonomous quantum circuit optimization, featuring multiple architectural approaches and model-agnostic LLM support (Gemini, OpenAI, Anthropic, Groq, Ollama, and any LiteLLM provider).

๐Ÿ—๏ธ Architectures

1. Blackboard System (Free/Emergent)

  • โ€”Agents communicate through a shared blackboard
  • โ€”Decoupled, event-driven activation
  • โ€”Emergent workflow based on data availability
  • โ€”Maximum flexibility and adaptability

2. Guided System (Strict Orchestration)

  • โ€”Explicit state machine with defined transitions
  • โ€”Central orchestrator controls workflow
  • โ€”Predictable, auditable execution path
  • โ€”Maximum reliability and control

3. Naked System (Baseline)

  • โ€”Single agent with direct MCP access
  • โ€”No framework overhead
  • โ€”Baseline for comparison

๐Ÿค– Model-Agnostic LLM Support

The system works with any LLM provider:

ProviderSetupModels
Gemini (Default)GOOGLE_API_KEYgemini-2.5-flash-lite
OpenAIOPENAI_API_KEYgpt-4o, gpt-4o-mini
AnthropicANTHROPIC_API_KEYclaude-3-opus, claude-3-sonnet
GroqGROQ_API_KEYllama-3-70b, mixtral-8x7b
Ollama (Local)No key neededAny local model

See [SETUP.md](SETUP.md) for detailed configuration.

๐Ÿ“Š Evaluation Metrics

MetricDescription
TimeTotal execution time in seconds
QualityCircuit depth, gate count, hardware fitness score
EffectivenessDid the circuit achieve the goal?
ReliabilitySuccess rate across multiple runs

๐Ÿš€ Quick Start

bash
# 1. Ensure QuantumArchitect-MCP is running
python QuantumArchitect-MCP/app.py

# 2. Set your API key (for Gemini by default)
set GOOGLE_API_KEY=your-key-here
# OR for OpenAI:
set OPENAI_API_KEY=your-key-here

# 3. Run the evaluation
python QAgents-workflos/run_evaluation.py

# For quick test (no LLM needed):
python QAgents-workflos/run_evaluation.py --quick

# Test specific mode:
python QAgents-workflos/run_evaluation.py --mode guided
python QAgents-workflos/run_evaluation.py --mode blackboard
python QAgents-workflos/run_evaluation.py --mode naked

๐Ÿ”ง Switching LLM Providers

Using Gemini (Default)

bash
set GOOGLE_API_KEY=your-gemini-key
# Models: gemini-2.5-flash-lite, gemini-2.5-pro

Using OpenAI

Edit config.py:

python
provider: str = "openai"
model: str = "gpt-4o-mini"
bash
set OPENAI_API_KEY=sk-...

Using Anthropic

python
provider: str = "anthropic"
model: str = "claude-3-sonnet-20240229"
bash
set ANTHROPIC_API_KEY=your-key

Using Groq

python
provider: str = "groq"
model: str = "llama-3-70b-versatile"
bash
set GROQ_API_KEY=your-key

Using Local Ollama

python
provider: str = "ollama"
model: str = "mistral"

No API key needed - runs locally on http://localhost:11434

๐Ÿ“ Project Structure

QAgents-workflos/
โ”œโ”€โ”€ agents/                    # Agent implementations (Architect, Builder, etc.)
โ”œโ”€โ”€ client/                    # MCP client for QuantumArchitect-MCP
โ”œโ”€โ”€ database/                  # Storage layer (logs, memory, circuits)
โ”œโ”€โ”€ orchestrators/             # Orchestration modes (Naked, Guided, Blackboard, QUASAR, Hybrid)
โ”œโ”€โ”€ prompts/                   # System prompts for agents and optimized LLM prompts
โ”œโ”€โ”€ tools/                     # Tool registry and MCP endpoint wrappers
โ”œโ”€โ”€ workflows/                 # Workflow definitions
โ”œโ”€โ”€ tests/                     # Evaluation harnesses and test problems
โ”œโ”€โ”€ app.py                     # Gradio UI entry point (Hugging Face Space)
โ”œโ”€โ”€ config.py                  # Configuration with env var support
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”œโ”€โ”€ .env.example               # Environment variable template
โ””โ”€โ”€ README.md                  # This file

๐Ÿš€ Deployment to Hugging Face Spaces

Prerequisites

  1. 1.Create a Hugging Face Space: https://huggingface.co/new-space
  2. 2.Select Gradio as the SDK
  3. 3.Push this repository to your Space

Environment Variables Configuration

The system reads configuration from environment variables, making it compatible with Hugging Face Spaces.

Critical Variables
VariablePurposeDefaultExample
LLM_PROVIDERLLM provider to usegeminigemini, openai, anthropic
LLM_MODELModel identifiergemini-2.5-flash-litegpt-4o-mini, claude-3-sonnet
GOOGLE_API_KEYGemini API key(none)Your API key from aistudio.google.com
MCP_SERVER_URLBackend URLhttp://127.0.0.1:7861https://your-backend.ngrok.io
Setting Variables in Hugging Face Space

Option 1: Via Space Settings (Recommended)

  1. 1.Go to your Space settings
  2. 2.Click "Secrets and variables" > "New secret"
  3. 3.Add each variable:
  4. 4.Secret Name: GOOGLE_API_KEY | Value: Your API key
  5. 5.Secret Name: MCP_SERVER_URL | Value: Backend URL
  6. 6.Add variables (non-sensitive):
  7. 7.Variable Name: LLM_PROVIDER | Value: gemini
  8. 8.Variable Name: LLM_MODEL | Value: gemini-2.5-flash-lite

Option 2: Via .env File

bash
# Copy .env.example to .env and fill in values
cp .env.example .env

# Commit and push to your Space
git add .env
git commit -m "Add environment configuration"
git push

โš ๏ธ Important: Never commit sensitive API keys directly. Use Space Secrets instead.

LLM Provider Configuration

Using Gemini (Default)
LLM_PROVIDER=gemini
LLM_MODEL=gemini-2.5-flash-lite
GOOGLE_API_KEY=your-key-from-https://aistudio.google.com/app/apikey
Using OpenAI
LLM_PROVIDER=openai
LLM_MODEL=gpt-4o-mini
OPENAI_API_KEY=sk-...
Using Anthropic
LLM_PROVIDER=anthropic
LLM_MODEL=claude-3-sonnet-20240229
ANTHROPIC_API_KEY=sk-ant-...
Using Groq
LLM_PROVIDER=groq
LLM_MODEL=llama-3-70b-versatile
GROQ_API_KEY=gsk_...
Using Local Ollama
LLM_PROVIDER=ollama
LLM_MODEL=mistral
# No API key needed - runs locally on http://localhost:11434

Backend Connection (MCP Server)

The Space communicates with the QuantumArchitect-MCP backend via MCP_SERVER_URL.

Options:

  1. 1.Local Development (both running on your machine):
   MCP_SERVER_URL=http://127.0.0.1:7861
  1. 1.Public Backend with ngrok (tunnel remote server):
bash
   # On your backend server:
   ngrok http 7861

Then set:

   MCP_SERVER_URL=https://your-ngrok-url.ngrok.io
  1. 1.Deployed Backend (your own server):
   MCP_SERVER_URL=https://your-quantum-api.example.com

If MCP_SERVER_URL is not set or unreachable, the Space will still work but with local-only features.

๐Ÿ“ Project Structure (Previous)

โ”œโ”€โ”€ agents/ # Agent definitions (types, behaviors) โ”œโ”€โ”€ prompts/ # System prompts for each agent โ”œโ”€โ”€ tools/ # MCP tool wrappers โ”œโ”€โ”€ workflows/ # Workflow definitions โ”œโ”€โ”€ orchestrators/ # Workflow orchestration logic โ”œโ”€โ”€ client/ # MCP client connection โ”œโ”€โ”€ database/ # Memory, logs, results storage โ”œโ”€โ”€ tests/ # Evaluation framework โ””โ”€โ”€ config.py # Global configuration