CoolFace
Apppublic

Shrook21/Code-Assistant

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
tools.py18 linesDownload Raw Back to tools
1from langchain_core.tools import tool
2from vectorstore.retriever import get_retriever
3
4retriever_tool = get_retriever()
5
6@tool
7def retriever(query: str) -> str:
8    """
9    Searches the code vectorstore for examples similar to the query.
10    """
11    docs = retriever_tool.invoke(query)
12    if not docs:
13        return "No relevant code examples found."
14
15    return "\n\n".join(f"Document {i+1}:\n{doc.page_content}" for i, doc in enumerate(docs))
16
17tools = [retriever]
18