Companion to
do_recife_embedder, which builds the MongoDB Atlas vector store this flow reads from.
A minimal crewAI Flow wrapping a single conversational RAG
agent that answers questions about the Diário Oficial do Recife, grounding
every answer in the embeddings produced by do_recife_embedder.
The agent is transparent about tool use, stays strictly on the topic of the Diário Oficial, and always replies in the same language as the user.
main.py–DoRecifeChatFlow, aFlow[Conversation]that appends the user message, calls the agent, and stores the reply.agents/–DoRecifeAgent, a streaming LiteAgent (agent.kickoff()).tools/–DoRecifeVectorSearchTool, a pre-configuredMongoDBVectorSearchTool.types/–ConversationandMessagestate models.
- Python >=3.10, <3.14 and uv
- Access to the same MongoDB Atlas cluster the embedder wrote to
- An Anthropic API key (agent) and an OpenAI API key (query embeddings)
Install dependencies:
crewai installAdd the required variables to .env:
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
MONGODB_CONNECTION_STRING=mongodb+srv://...ANTHROPIC_API_KEY runs the agent (anthropic/claude-haiku-4-5).
OPENAI_API_KEY embeds the query (text-embedding-3-large, 3072-dim) and must
match the embedder's settings or vector search returns irrelevant results.
crewai runChange the question by editing the user_message input in
src/do_recife_chat_flow/main.py.