diff --git a/rag_tools.py b/rag_tools.py new file mode 100644 index 0000000..dd1e622 --- /dev/null +++ b/rag_tools.py @@ -0,0 +1,18 @@ +from langchain.tools import tool +from vector_store import QdrantStore +from chunker import get_chunks + +store = QdrantStore() + +@tool +def search_knowledge_base(query: str, max_results: int = 5) -> str: + """Semantic search in knowledge base.""" + results = store.search(query, limit=max_results) + return "\n".join([f"{i+1}. {r.metadata.get('title', 'no title')}" for i,r in enumerate(results)]) + +@tool +def add_to_knowledge_base(content: str, title: str) -> str: + """Add document to knowledge base.""" + chunks = get_chunks(content, title) + store.add_documents(chunks) + return f"Added {len(chunks)} chunks for title '{title}'."