From 0cea962c33aad2d613fbfbc1bd98a8c7c8683f76 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=9A=D1=83=D1=82?= =?UTF-8?q?=D0=BB=D0=B0=D1=85=D0=BC=D0=B5=D1=82=D0=BE=D0=B2?= Date: Thu, 28 May 2026 13:32:57 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20to?= =?UTF-8?q?ols.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 tools.py diff --git a/tools.py b/tools.py deleted file mode 100644 index 1967392..0000000 --- a/tools.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Tools for the RAG agent. - -search_knowledge_base and add_to_knowledge_base are implemented using VectorStore. -""" -from typing import List, Dict -from langchain.tools import tool -from vector_store import VectorStore - -# Instantiate a global store -store = VectorStore() - -@tool -def search_knowledge_base(query: str, max_results: int = 5) -> str: - """Semantic search in the knowledge base.""" - results = store.similarity_search(query, k=max_results) - if not results: - return "No relevant documents found." - out_lines = [] - for i, r in enumerate(results, 1): - out_lines.append(f"{i}. {r['content'][:200]}... (source: {r['metadata'].get('title', 'unknown')})") - return "\n".join(out_lines) - -@tool -def add_to_knowledge_base(content: str, title: str = "document") -> str: - """Add a document to the knowledge base. - - The content is split into chunks and stored with metadata. - """ - store.add_documents([content], [{"title": title}]) - return f"Document '{title}' added to knowledge base."