maeser.graphs.simple_rag module#
Module for creating a simple Retrieval-Augmented Generation (RAG) graph using LangChain.
This RAG Graph accepts only one vector store, forcing the chatbot to stick to one topic per conversation.
- maeser.graphs.simple_rag.get_simple_rag(vectorstore_path: str, vectorstore_index: str, memory_filepath: str, api_key: str | None = None, system_prompt_text: str = 'You are a helpful teacher helping a student with course material.\nYou will answer a question based on the context provided.\nIf the question is unrelated to the topic or the context, politely inform the user that their question is outside the context of your resources.\n\n{context}\n', model: str = 'gpt-4o-mini') langgraph.graph.graph.CompiledGraph [source]#
Creates a simple Retrieval-Augmented Generation (RAG) graph.
This RAG Graph accepts only one vector store, forcing the chatbot to stick to one topic per conversation.
The following system prompt is used if none is provided:
“””You are a helpful teacher helping a student with course material. You will answer a question based on the context provided. If the question is unrelated to the topic or the context, politely inform the user that their question is outside the context of your resources.
{context} “””
- Parameters:
vectorstore_path (str) – Path to the vector store.
vectorstore_index (str) – Index name for the vector store.
memory_filepath (str) – Filepath for the memory checkpoint.
api_key (str | None) – API key for the language model. Defaults to None, in which case it will use the
OPENAI_API_KEY
environment variable.system_prompt_text (str) – Prompt text for the system message. Defaults to a helpful teacher prompt.
model (str) – Model name for the language model. Defaults to ‘gpt-4o-mini’.
- Returns:
The compiled state graph.
- Return type:
CompiledGraph