Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Prisma

One prompt in, a spectrum of model responses out.

AI Prisma is a Streamlit chat studio for working with multiple LLM providers (OpenAI, Anthropic, Groq, Mistral, Google) through a single interface, powered by aisuite. Its signature feature is Compare Mode: send the same prompt to 2–5 models in parallel and review their answers side by side, with per-branch latency, token counts, and failure isolation.

Features

  • Multi-provider chat — switch models from a dropdown loaded from config.yaml; model IDs use the provider:model format
  • Compare Mode — fan one prompt out to 2–5 models concurrently, view side-by-side result cards, and hand off your favorite response back into the main chat
  • Prompt templates & variables — reusable system prompts with {{variable}} substitution
  • Conversation persistence — chats stored locally in SQLite (WAL mode)
  • Streaming responses with graceful, run-id-tagged error messages
  • File & audio input — image uploads and audio recording in chat
  • Guardrails — provider key validation per selected model, prompt-size and upload-size limits
  • Optional Langfuse tracing — every completion traced automatically when Langfuse keys are configured, with sensitive-data redaction (see Observability with Langfuse)

Setup

1. Prerequisites

  • Python 3.10+

2. Install

python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # macOS/Linux
pip install -r requirements.txt

3. Configure API keys

cp .env.example .env

Edit .env and add the keys for the providers you plan to use. Only the key for the currently selected model's provider is required. Langfuse keys are optional — the app runs fine without tracing.

4. Run

streamlit run app.py

The app opens at http://localhost:8501. Compare Mode is available as a separate page in the sidebar.

Configuring models

The model dropdown is driven by config.yaml. Each entry supports:

- name: "Display name"        # shown in the dropdown
  provider: "openai"          # aisuite provider id
  model: "gpt-5.2"            # provider's model id
  capability: "chat"
  env: "OPENAI_API_KEY"       # env var holding the provider key

Add or remove entries to control which models appear in the UI.

Observability with Langfuse

AI Prisma ships with built-in Langfuse integration for LLM observability. It is entirely optional — without credentials the app runs normally and tracing is silently disabled.

When enabled, every chat completion (including each branch of a Compare Mode run) is traced automatically with the model used, request/response messages, latency, token usage, and a run_id you can use to correlate UI errors with traces.

To enable it, bring your own Langfuse credentials — traces are sent to your Langfuse project, not anyone else's:

  1. Create a free account at cloud.langfuse.com (or use your self-hosted Langfuse instance)
  2. Create a project and copy its API keys from Project Settings → API Keys
  3. Add them to your .env:
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
# Optional — defaults to the EU cloud endpoint.
# Use https://us.cloud.langfuse.com for US cloud, or your self-hosted URL.
LANGFUSE_BASE_URL=https://cloud.langfuse.com
  1. Restart the app — tracing starts automatically, no code changes needed.

Privacy note: before anything is sent to Langfuse, the tracing layer redacts sensitive patterns from traced content — API keys (e.g. sk-...), bearer tokens, inline KEY=value secrets, and email addresses.

Project structure

app.py                      # Main chat page (entry point)
pages/2_Compare_Mode.py     # Side-by-side multi-model comparison
services/                   # Model registry, guardrails, variable substitution, compare orchestrator
ui/                         # Streamlit session-state setup
data/                       # Repository layer over SQLite
observability/              # Langfuse tracing wrapper (with redaction)
db.py                       # SQLite utilities (WAL, pooling, transactions)
config.yaml                 # Model registry
docs/                       # PRD, sprint boards, and AI-assisted dev session logs

Troubleshooting

  • "Missing API key for selected model provider" — set the env var for the provider of the model selected in the dropdown (see config.yaml's env field).
  • "The request failed (run_id: ...)" — use the run id shown in the UI to correlate with logs/Langfuse traces.
  • Port 8501 already in usestreamlit run app.py --server.port 8502.

Development docs

The docs/ folder contains the PRD, milestone task boards, and session handoff notes from the AI-assisted development workflow used to build this project. Historical notes there reference the old entry point name demo_GPT.py (now app.py) and the original dev_chat-ui/ folder layout.

About

One prompt in, a spectrum of model responses out. Multi-provider LLM chat studio with side-by-side Compare Mode, built on Streamlit + aisuite.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages