This post explains how the website assistant works.
Stack
- Streamlit for the responsive, embedded UI
- OpenRouter as the LLM backend (supporting 200+ models)
- Markdown files as the content source (scoped to
/contentdirectory only)
Overview
The website chat interface is a single-screen, embeddable chat widget designed to be integrated into static websites via an <iframe>. It provides an iMessage-style conversation UI with blue user bubbles and dark gray assistant bubbles, all styled with a modern dark theme.
What It Does
This is a secure, content-aware assistant that:
- Indexes all markdown files in the repository's
content/directory - Searches for relevant articles based on user questions using keyword matching
- Fetches full article content when needed to provide grounded, contextual answers
- Maintains conversation history to enable follow-up questions within the same session
- Never accesses source code, environment secrets, or files outside the
/contentboundary
Security & Scope
The chat interface enforces a strict content boundary:
- ✅ Accessible: All files matching
content/*/.md - ❌ Not accessible: Source code,
.envfiles, secrets, configuration files, or any path outsidecontent/ - ✅ Startup validation: If
CONTENT_DIRis misconfigured, the app fails fast with a clear error
This design ensures users can safely expose the chat widget publicly without revealing sensitive project information.
Interaction Model
The assistant can:
- Search relevant articles by keyword from user queries
- Retrieve full article content by file slug
- Answer questions grounded in the retrieved markdown files
- Remember context across multiple messages in a session
Features & Customization
- Iframe-ready: Embed via
https://YOUR-STREAMLIT-APP.streamlit.app/?embed=true - Configurable LLM: Switch models via
OPENROUTER_MODELenv var - Content limit controls: Set
MAX_ARTICLE_CONTEXT_CHARSto control context window - Safety modes: Optional content filtering with configurable blocked terms
- Message limits: User input and context are size-limited to prevent abuse
Learn More
For detailed documentation, implementation details, and deployment instructions, visit the GitHub repository:
→ streamlit-openrouter-chat-embed
The repo includes setup guides, environment configuration examples, embedding instructions, and contribution guidelines.