RAG_SemanticRouting
https://github.com/UribeAlejandro/RAG_SemanticRouting/tree/main
Chat Agent with semantic routing. The question is evaluated and routed to two possible paths: web search or RAG. This agent leverages Ollama, LangChain, LangGraph, LangSmith
The architecture of the system is shown below:
The system is composed of the following nodes, routes and edges:
Route Question
: The node evaluates whether the question should be routed to theVectorStore
orWeb Search
. To do so, uses the LLM model to classify the question. Thus, the output is a binary choice {yes
,no
}.
Yes
->VectorStore
: The question is routed to theVectorStore
to retrieve the most relevant documents.No
->Web Search
: The question is routed to theWeb Search
to include external information.Web Search
: The node uses the Tavily API to search information related to the question.Retrieve
: The node retrieves the most relevant documents from theVectorStore
.Grade Documents
: The node grades the documents using the LLM model. Thus, the output is a binary choice {yes
,no
}.
Yes
->Answer
: The node answers the question using the retrieved documents.No
->Web Search
: The question is routed to theWeb Search
to include external information.Answer
: The node answers the question using the retrieved documents.Hallucinations Detection
: The node uses the LLM to detect hallucinations in the answer.
not useful
->Web Search
: The question is routed to theWeb Search
to include external information.not supported
-> re-renerate
the answeruseful
->End
: The answer is returned.
标签:node,Web,Search,RAG,langgraph,question,llmrouter,routed From: https://www.cnblogs.com/lightsong/p/18547052