Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Personal Prompt Router (Experiment)

A weekend experiment to build a lightweight AI control plane that:

  1. Classifies incoming prompts
  2. Routes them to a model
  3. Toggles reasoning mode
  4. Logs every decision
  5. Analyzes behavior

🚀 Setup

1️⃣ Install dependencies

npm install

2️⃣ Configure environment variables

Copy the example file:

cp .env.example .env

Then edit .env and set your OpenRouter API key:

OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
CLASSIFIER_MODEL=openrouter/openai/gpt-5.2-chat
EXECUTION_MODEL_DEFAULT=openrouter/openai/gpt-5.2-chat

⚠️ Never commit your real .env file.


🧪 Running the Router

Start the CLI:

npm run dev

You’ll be prompted to enter a prompt.

The system will:

  • Classify it
  • Show routing decision
  • Execute via OpenRouter
  • Log the decision in logs/

🧪 Run Full Test Suite (Automated)

To benchmark the router against the 15 categorized prompts:

tsx src/runTestSuite.ts

(Optional) Add a script in package.json:

"test-suite": "tsx src/runTestSuite.ts"

Then run:

npm run test-suite

This will:

  • Parse prompts from test-suite.md
  • Classify each prompt
  • Execute via the router
  • Measure latency
  • Compute overall and per-category accuracy

📊 Analyze Logs

After running multiple prompts:

tsx src/analyzeLogs.ts

This prints:

  • Total runs
  • Average latency
  • Category distribution
  • Reasoning usage breakdown

🗂 Project Structure

src/
  classifierPrompt.ts   → Classification instructions
  routingTable.ts       → Static routing rules
  openrouter.ts         → OpenRouter API integration
  logger.ts             → JSONL logging
  analyzeLogs.ts        → Analytics script
  index.ts              → CLI entrypoint

test-suite.md           → 15-prompt evaluation set
logs/                   → Router decision logs

🎯 Experiment Goals

  • ≥80% classification accuracy
  • Measure reasoning usage
  • Measure latency impact
  • Evaluate subjective output quality

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages