Skip to content

quinnhasse/TribunalAI

Repository files navigation

TribunalAI

An AI Council Decision Engine where multiple AI models answer your questions independently, critique each other's responses, and produce a consensus output.

What It Does

  1. Independent Analysis - Multiple AI models independently answer your question
  2. Cross-Critique - Each model critiques the others' claims, assumptions, and confidence levels
  3. Revision (thorough mode) - Models revise their answers based on critiques received
  4. Consensus - Agreements, disagreements, and a verification checklist are synthesized

MVP Capabilities

  • Submit prompts to a 3-model council (GPT-4o, Claude Sonnet, Gemini Flash)
  • Choose between concise/detailed response modes
  • Choose between fast (2 rounds) and thorough (3 rounds) depth
  • Real-time streaming of debate progress via NDJSON
  • Consensus panel with agreements, disagreements, and verification checklist
  • Works entirely with mock providers - no API keys needed
  • Optional real provider support when API keys are configured

Tech Stack

Next.js 15 (App Router) | TypeScript | Tailwind CSS | shadcn/ui | Zod | Zustand | Vitest | Playwright

Setup

# Install dependencies
pnpm install

# (Optional) Copy env file and add API keys for real providers
cp .env.example .env.local

# Start development server
pnpm dev

Open http://localhost:3000 to use the app.

Environment Variables

Variable Required Description
OPENAI_API_KEY No OpenAI API key for GPT-4o / GPT-4o Mini
ANTHROPIC_API_KEY No Anthropic API key for Claude Sonnet / Haiku
GOOGLE_API_KEY No Google AI API key for Gemini Flash

All keys are optional. When absent, deterministic mock providers are used instead.

Commands

pnpm dev        # Start dev server with Turbopack
pnpm build      # Production build
pnpm start      # Start production server
pnpm lint       # Run ESLint
pnpm test       # Run Vitest unit + UI tests
pnpm test:watch # Run Vitest in watch mode
pnpm test:e2e   # Run Playwright E2E tests

Project Structure

src/
  app/
    api/council/route.ts    # POST endpoint - streams NDJSON events
    layout.tsx              # Root layout (dark mode, Inter font)
    page.tsx                # Main page composing all UI
    globals.css             # Tailwind + shadcn CSS variables
  components/
    council/                # PromptComposer, RunControls, ModelCard,
                            # DebateTimeline, ConsensusPanel
    layout/                 # AppShell, Topbar, Sidebar
    ui/                     # shadcn/ui primitives
  lib/
    council/
      types.ts              # All TypeScript types
      schema.ts             # Zod validation schemas
      prompts.ts            # System/user prompt templates
      claimExtract.ts       # Heuristic claim extraction
      consensus.ts          # Agreement/disagreement detection
      engine.ts             # Async generator orchestration
    providers/
      mock.ts               # Deterministic mock (FNV-1a + Mulberry32)
      openai.ts             # OpenAI adapter
      anthropic.ts          # Anthropic adapter
      google.ts             # Google AI adapter
      index.ts              # Provider factory
    utils/
      stream.ts             # Async generator -> NDJSON ReadableStream
      format.ts             # Duration/confidence formatting
      logger.ts             # Console logger
  store/
    councilStore.ts         # Zustand store with NDJSON stream consumer
tests/
  unit/                     # Vitest unit tests
  ui/                       # Vitest component tests
  e2e/                      # Playwright E2E tests
  setup.ts                  # Test setup

Architecture

  • Engine: Async generator that yields typed events as the council deliberates
  • Transport: NDJSON over ReadableStream (POST-compatible, unlike SSE)
  • State: Zustand store consumes the stream and updates UI reactively
  • Providers: Minimal generate() interface - mock fallback when no API keys
  • Mock seeding: FNV-1a hash + Mulberry32 PRNG for deterministic but varied outputs

About

AI council engine — three LLMs answer independently, critique each other, then synthesize a consensus. GPT-4o, Claude Sonnet, Gemini Flash with mock fallback.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors