Skip to content

Sheet 01 / 06

LLM Chat Platform

An extensible LLM interaction platform: multiple providers, hybrid RAG, streaming, persistence, evaluation and observability.

Status
In development
Type
Independent project · Applied AI platform engineering · since December 2025

Architecture

LLM Chat Platform architectureLayered architecture. API: tenant, CORS and logging middleware, FastAPI with REST and Server-Sent Events, and the POST /chat endpoint. Conversation: PostgreSQL with SQLAlchemy, conversational state and Redis as cache. Hybrid RAG in four stages. In POST /chat, RAG augmentation and conversation history are opt-in and off by default. Routing and models: a routing layer with a static default policy, a resilient provider with single-hop fallback, OpenAI and Amazon Bedrock; dynamic routing is prepared but not enabled. Observability: OpenTelemetry, request tracking and evaluation evidence.APIMiddlewaretenant · CORSstructured logsFastAPIREST · Server-Sent EventsPOST /chatinteraction andusage loggingCONVERSATIONPostgreSQLSQLAlchemy · conversationsConversational statemessage sequencesRedisresponse cachenon-stream onlyHYBRID RAGBM25 + denseembeddingstext-embedding-3-small1Candidateretrievaltop_k=20 evaluated2Ranking /selectiontop_n=5 evaluated3Contextassemblyin /chat: opt-in4ROUTING & MODELSRoutinglayerstatic policyby defaultResilientprovidersingle-hop fallbackbefore 1st tokenOpenAIGPT-4o-miniAmazonBedrockNemotron Nano12B v2Dynamic routing: prepared, not enabledOBSERVABILITYOpenTelemetryusage eventsRequesttrackingEvaluationevidence
Swipe horizontally to see the full diagram. Component map based on what is documented. Arrows show stage order or fallback, not an execution sequence.

Problem

Putting LLMs into an application takes more than one API call: you need more than one provider with fallback, persisted conversations, context retrieval whose quality you can measure, streamed responses, and visibility into what happens on every request.

Architecture

  • Multi-provider layer: an abstraction that integrates different model providers and manages their execution. Providers used: OpenAI (including GPT-4o-mini) and Amazon Bedrock (including Nemotron Nano 12B v2). Cross-provider fallback has been tested.
  • Streaming and persistence: responses over Server-Sent Events; conversations persisted in PostgreSQL with message sequencing and conversational state; endpoints for interaction and usage logging.
  • Routing and fallback: a routing layer with a static default policy and a resilient provider with single-hop fallback, only before the first token. The dynamic routing policy is prepared and not enabled.
  • Hybrid RAG: BM25 combined with dense embeddings (OpenAI text-embedding-3-small), candidate retrieval, ranking and context assembly. Evaluated configurations include top_k=20 and top_n=5.
  • Observability: OpenTelemetry, instrumentation, usage events, request tracking and evaluation evidence.

Evaluation

Evaluations of retrieval quality, ranking behavior, query variations, English/Spanish retrieval differences, regressions, RAG correctness, model and provider behavior, and conversational history. The test suite has grown past 200 tests.

Status

In development. It is an independent project, not a product deployed at scale: some evaluations and acceptance criteria remain open.

Stack

  • Python
  • FastAPI
  • PostgreSQL
  • SQLAlchemy
  • Redis
  • Docker
  • pytest
  • OpenTelemetry
  • SSE
  • OpenAI API
  • Amazon Bedrock
  • BM25
  • Embeddings