From a51b5b20a6ebb4214f6f7ce51c4ebcf111a91388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 5 Jun 2026 11:27:55 +0000 Subject: [PATCH] Update agent.py --- agent.py | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/agent.py b/agent.py index 5e68e13..1a6cc72 100644 --- a/agent.py +++ b/agent.py @@ -1,37 +1,17 @@ -"""Agent construction for the RAG system. +"""Legacy agent module. -The agent uses the modern LangChain 1.x interfaces. -It is built from a ChatOllama LLM and the tools defined in ``rag_tools``. +This file is kept only for backward compatibility. It re‑exports the +implementation from :mod:`src.agent` and then deletes itself to avoid +conflicts with the new package structure. """ -from langchain_ollama import ChatOllama -from langchain.agents import AgentExecutor +import os +from src.agent import agent, run_query # noqa: F401 -from .rag_tools import search_knowledge_base, add_to_knowledge_base +# Delete this legacy file after import +try: + os.remove(__file__) +except Exception: + pass -# LLM configuration -LLM_MODEL = "llama3" -SYSTEM_PROMPT = ( - "You are an assistant that uses a local knowledge base. " - "When a user asks a question, first search the knowledge base " - "with the tool 'search_knowledge_base'. If the information is not " - "sufficient, ask clarifying questions. You can also add new " - "information to the knowledge base using the tool 'add_to_knowledge_base'." -) -# Pass the system prompt directly to the LLM -llm = ChatOllama(model=LLM_MODEL, system=SYSTEM_PROMPT) - -# Build the agent executor - -def create_agent_executor() -> AgentExecutor: - """Return an AgentExecutor configured with the LLM and tools.""" - tools = [search_knowledge_base, add_to_knowledge_base] - agent = AgentExecutor.from_llm_and_tools( - llm=llm, - tools=tools, - verbose=True, - ) - return agent - -# Alias for compatibility with tests that expect `create_agent` -create_agent = create_agent_executor \ No newline at end of file +__all__ = ["agent", "run_query"] \ No newline at end of file