From 70b8d4aed4faf0b6e6453891f09be6455a0b3e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B0=D1=82=20=D0=A4=D0=B0=D0=B7=D1=8B?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2?= Date: Tue, 12 May 2026 20:00:47 +0000 Subject: [PATCH] add agent --- agent.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 agent.py diff --git a/agent.py b/agent.py new file mode 100644 index 0000000..de0a7d8 --- /dev/null +++ b/agent.py @@ -0,0 +1,17 @@ +from langchain.agents import create_openai_functions_agent, AgentExecutor +from langchain.llms import Ollama +from rag_tools import search_knowledge_base, add_to_knowledge_base + +llm = Ollama(model="llama3") + +tools = [search_knowledge_base, add_to_knowledge_base] + +agent = create_openai_functions_agent(llm=llm, tools=tools, system_prompt="You are an assistant that can search and add knowledge.") +executor = AgentExecutor(agent=agent, tools=tools, verbose=True) + +if __name__ == "__main__": + while True: + inp = input("> ") + if inp.lower() in ("quit", "exit"): + break + print(executor.invoke({"input": inp}))