add rag_agent

This commit is contained in:
2026-05-28 14:30:35 +00:00
parent fea5edd9df
commit 3eadd50001
+9
View File
@@ -0,0 +1,9 @@
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain.llms import Ollama
from tools import search_knowledge_base, add_to_knowledge_base
def get_agent():
llm = Ollama(model="llama3")
tools_list = [search_knowledge_base, add_to_knowledge_base]
agent = create_openai_functions_agent(llm=llm, tools=tools_list, system_prompt="You are an assistant that uses a knowledge base.")
return AgentExecutor(agent=agent, tools=tools_list)