Update rag_tools.py
This commit is contained in:
+1
-35
@@ -1,35 +1 @@
|
|||||||
"""Tools for the RAG agent.
|
# Deprecated module – kept for backward compatibility
|
||||||
|
|
||||||
Two tools are exposed via the ``@tool`` decorator:
|
|
||||||
* ``search_knowledge_base`` – semantic search in the Qdrant vector store.
|
|
||||||
* ``add_to_knowledge_base`` – add a document to the vector store.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from typing import List, Dict
|
|
||||||
|
|
||||||
from langchain.tools import tool
|
|
||||||
|
|
||||||
from .vector_store import add_document, search_text
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Tool definitions
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@tool("search_knowledge_base")
|
|
||||||
async def search_knowledge_base(query: str, max_results: int = 5) -> List[str]:
|
|
||||||
"""Return the top *max_results* relevant chunks for *query*.
|
|
||||||
|
|
||||||
The function is asynchronous because LangChain expects async tools when
|
|
||||||
the agent runs in an async context. The underlying vector store calls
|
|
||||||
are synchronous, so we simply wrap the result.
|
|
||||||
"""
|
|
||||||
return search_text(query, k=max_results)
|
|
||||||
|
|
||||||
@tool("add_to_knowledge_base")
|
|
||||||
async def add_to_knowledge_base(content: str, title: str) -> str:
|
|
||||||
"""Add *content* under *title* to the knowledge base.
|
|
||||||
|
|
||||||
Returns a confirmation string.
|
|
||||||
"""
|
|
||||||
add_document(title, content)
|
|
||||||
return f"Document '{title}' added to knowledge base."
|
|
||||||
Reference in New Issue
Block a user