Skip to main content

Flexible Voice RAG Agent

A reusable, domain-neutral LangChain agent core extracted into a separate project. It supports custom system/user prompts, multiple RAG documents, custom tools, custom models, embeddings, and vector stores. The original application outside this directory is not imported or modified.

Install

Core only:

pip install flexible-voice-rag-agent

With the default Gemini embeddings and Chroma implementation:

pip install "flexible-voice-rag-agent[google-rag]"

During local development:

python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[google-rag,dev]"

Quick start

import asyncio

from flexible_voice_agent import FlexibleAgent, VoiceAgentConfig

config = VoiceAgentConfig.from_file("examples/customer_support/config.toml")
agent = FlexibleAgent(config)

async def main():
    answer = await agent.ainvoke(
        "How do I return an item?",
        thread_id="conversation-123",
    )
    print(answer)

asyncio.run(main())

For a TTS pipeline, stream text chunks:

async for text in agent.astream_text(user_text, thread_id=session_id):
    await tts.send_text(text)

Customize a domain

Each deployment has a TOML or JSON profile. Paths are resolved relative to the profile file, so a profile and its documents can move together.

domain = "customer_support"

[agent]
model = "google_genai:gemini-3.1-flash-lite"
language_instruction = "Reply in the user's language. Keep responses concise."

[prompt]
system_path = "prompts/system.txt"
user_path = "prompts/user.txt"

[prompt.variables]
company_name = "Example Shop"
tone = "warm and direct"

[rag]
enabled = true
document_paths = ["documents", "../shared/legal.md"]
persist_directory = ".chroma/customer_support"
collection_name = "customer_support_docs"
embedding_model = "gemini-embedding-001"
top_k = 4
relevance_threshold = 0.55
chunk_size = 900
chunk_overlap = 120

Prompt files use Python-style placeholders. The package supplies {user_input}, {rag_context}, {domain}, and {language_instruction}. Any value in [prompt.variables] is also available:

You are the {company_name} assistant for the {domain} domain.
Tone: {tone}.
{language_instruction}
Only use approved context for company-specific facts.
<approved_context>
{rag_context}
</approved_context>

<user_message>
{user_input}
</user_message>

document_paths accepts individual UTF-8 .md/.txt files or directories. Directories are scanned recursively. Document content and paths are hashed, so the persistent collection is rebuilt when the configured knowledge base changes.

Custom tools and RAG backends

Pass any LangChain-compatible tools without changing the package:

agent = FlexibleAgent(config, tools=[create_ticket, lookup_order])

The defaults use Gemini embeddings and Chroma. Other providers can be injected:

retriever = RAGRetriever(
    config.rag,
    embeddings=my_embeddings,
    vector_store_factory=my_vector_store_factory,
)
agent = FlexibleAgent(config, retriever=retriever, model=my_chat_model)

The retriever is also available as a tool when agent-controlled retrieval is preferred:

rag_tool = retriever.as_tool(
    name="search_product_docs",
    description="Search approved product documentation.",
)

Validate, test, and build

flexible-voice-agent validate examples/customer_support/config.toml
pytest
python -m build
python -m twine check dist/*

Publish to PyPI

Before publishing, replace the placeholder author in pyproject.toml, add your real project URLs if available, confirm the distribution name is available, and increment the version for every release.

TestPyPI first:

python -m twine upload --repository testpypi dist/*

Then publish the same checked artifacts to PyPI:

python -m twine upload dist/*

Use a PyPI API token when Twine prompts for credentials. Do not store the token in this repository.

Metadata

Release files for flexible-voice-rag-agent 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flexible-voice-rag-agent 0.1.0
File Size Uploaded
flexible_voice_rag_agent-0.1.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flexible-voice-rag-agent 0.1.0
File Interpreter ABI Platform
flexible_voice_rag_agent-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / flexible_voice_rag_agent-0.1.0.tar.gz

Download URL flexible_voice_rag_agent-0.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
58a6d47be795e71a24adad06df7867a6adae49737103f8292822614bcc086c9a
BLAKE2b-256 checksum
How to use checksums
9fd309d14c5a6989efeffe59fce3b5bdf9e7928c3ea69752df670608cc736cbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / flexible_voice_rag_agent-0.1.0-py3-none-any.whl

Download URL flexible_voice_rag_agent-0.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ff60dcbd6de0ba62fa29b9da120207cb75e997b4536c2d5979cecf52fd9b3d0
BLAKE2b-256 checksum
How to use checksums
8fa6c0bed365acb9d40cb658af4f4c9dda5db2401f8c05b82f1b518865bf578f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page