Welcome to NovelAI, an interactive Retrieval-Augmented Generation (RAG) system designed to bring your fantasy worldbuilding notes to life.
With NovelAI, you can chat directly with your character sheets, magic systems, lore documents, and maps. The AI uses advanced retrieval techniques to find exact chunks from your database and synthesizes accurate, conversational responses without ever hallucinating lore.
- Blazing Fast Embeddings: Local
sentence-transformersautomatically encode your documents. - ChromaDB Vector Store: A robust database that stores and searches your lore history instantaneously.
- Cross-Encoder Reranking: Industry-standard two-stage retrieval.
ChromaDBacts as a fast initial filter, and a highly accurate Cross-Encoder re-ranks the top results for maximum precision. - Universal LLM Support: Designed strictly with an agnostic layer, you can swap between Google Gemini, Anthropic Claude, OpenAI, or local alternatives (Ollama/LMStudio) with a single line of code!
- Premium Chat Interface: Built on Streamlit, the custom UI features dark glassmorphism, transparent chat bubbles, and instant source expanders.
Ensure you have Python 3.10+ installed. It is highly recommended to create an isolated virtual environment (.venv) for this project so you don't conflict with other Python packages on your computer.
On Windows:
python -m venv .venv
.venv\Scripts\activateOn Mac/Linux:
python3 -m venv .venv
source .venv/bin/activateIf PowerShell blocks the activation script
If you see an error saying that script execution is disabled, run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy BypassThen activate the environment again:
.\.venv\Scripts\Activate.ps1This changes the execution policy only for the current PowerShell session. It does not permanently change your Windows security settings.
Then continue with:
On Mac/Linux:
python3 -m venv .venv
source .venv/bin/activateOnce your environment is active, install everything you need:
pip install -r requirements.txtCreate a file named .env in the root directory. Inside, paste the following (depending on your choice of LLM):
# Required for retrieving HuggingFace models without rate limiting
HF_TOKEN=your_huggingface_read_token_here
# LLM Providers (add whichever you plan on using)
GEMINI_API_KEY=your_gemini_key
# ANTHROPIC_API_KEY=your_anthropic_key
# OPENAI_API_KEY=your_openai_key(You can generate a free HF token at Hugging Face Settings).
For a simple command-line interface testing:
python chat.pyTo launch the interactive and immersive web UI:
streamlit run streamlit_app.pyThis UI will boot into a stunning environment where you can query your knowledge base and physically read exactly which "chunks" of lore the AI used to build its answer by clicking the View Retrieved Lore Sources expander.
You can adjust how smart/creative the AI is by tweaking the configuration in streamlit_app.py or chat.py.
GeneratorConfig(
provider="gemini", # options: "gemini", "anthropic", "openai", "local"
model="gemini-3.6-flash", # or "claude-3-5-sonnet-20240620", "gpt-4o", etc.
temperature=0.3, # 0.0 (Strict Lore) to 0.7 (Creative storytelling)
max_tokens=1024,
)Enjoy writing your novel!