RAG_SemanticRouting of langchain langgraph llmrouter
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.
出处:http://www.cnblogs.com/lightsong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。