File size: 857 Bytes
c423b65 8aa9694 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from agents import IntentAgent, SearchAgent, QAAgent, FutureWorksAgent , SummarizationAgent
import streamlit as st
class Router:
def __init__(self):
self.intent_agent = IntentAgent()
self.agents = {
"search": SearchAgent(),
"qa": QAAgent(),
"future_works": FutureWorksAgent(),
"summarize": SummarizationAgent()
}
def route_query(self, query):
intent = self.intent_agent.get_intent(query)
agent = self.agents.get(intent)
st.write(f"Using {intent} agent...")
if agent:
if intent == "search":
ans , d = agent.solve(query)
return ans , d
return agent.solve(query) , None
else:
return ["Sorry, I couldn't understand your query. Please give valid question"] , None
|