Add rag_agent
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
from langchain.agents import create_openai_functions_agent, AgentExecutor
|
||||||
|
from rag_tools import search_knowledge_base, add_to_knowledge_base
|
||||||
|
from langchain.schema import HumanMessage
|
||||||
|
|
||||||
|
def run_agent():
|
||||||
|
tools=[search_knowledge_base,add_to_knowledge_base]
|
||||||
|
agent=create_openai_functions_agent(tools=tools, llm=None)
|
||||||
|
executor=AgentExecutor(agent=agent, tools=tools, verbose=True)
|
||||||
|
while True:
|
||||||
|
inp=input("> ")
|
||||||
|
if inp.strip().lower()=="/quit":
|
||||||
|
break
|
||||||
|
response=executor.invoke({"input":inp})
|
||||||
|
print(response["output"])
|
||||||
|
if __name__=="__main__":
|
||||||
|
run_agent()
|
||||||
Reference in New Issue
Block a user