Skip to content

feat: add colony_retriever_rag cookbook example (closes #30)#36

Open
prudhvirapeti wants to merge 1 commit into
TheColonyCC:mainfrom
prudhvirapeti:feat/colony-retriever-rag-cookbook
Open

feat: add colony_retriever_rag cookbook example (closes #30)#36
prudhvirapeti wants to merge 1 commit into
TheColonyCC:mainfrom
prudhvirapeti:feat/colony-retriever-rag-cookbook

Conversation

@prudhvirapeti
Copy link
Copy Markdown

Summary

  • Adds examples/colony_retriever_rag.py — a ~60 line cookbook example showing ColonyRetriever plugged into a full LCEL RAG chain
  • Uses ChatOllama (llama3.2) as the default LLM — no paid API key required, runs entirely local
  • Supports --openai flag to swap in gpt-4o-mini for higher quality responses
  • Updates README examples table with a link and description

What the example does

Colony posts (via ColonyRetriever)
  → format_docs()        # formats title, author, score + content
  → ChatPromptTemplate   # system prompt enforces grounded answers
  → ChatOllama/OpenAI    # generates the answer
  → StrOutputParser      # extracts plain text

Usage

pip install langchain-colony langchain-ollama ollama
ollama pull llama3.2

export COLONY_API_KEY=col_YOUR_KEY
python examples/colony_retriever_rag.py "What's emerging about MCP?"

# or with OpenAI
export OPENAI_API_KEY=sk-...
python examples/colony_retriever_rag.py "What's emerging about MCP?" --openai

Test plan

  • Runs end-to-end with a valid COLONY_API_KEY and local Ollama
  • --openai flag correctly switches to gpt-4o-mini
  • Prints grounded answer with post titles and authors cited
  • README examples table renders correctly

Closes #30

🤖 Generated with Claude Code

Adds examples/colony_retriever_rag.py — a self-contained RAG chain
using ColonyRetriever with ChatOllama (local, no API key needed) as
the default LLM. Supports OpenAI via --openai flag. Updates README
examples table with a link and description.

Closes TheColonyCC#30

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a cookbook example for ColonyRetriever in a RAG chain

1 participant