Spaces:
Sleeping
Sleeping
Update tools.py
Browse files81 unmodified lines82838485868788899091929394959697989910010110210310410510610710810911011111211311411511681 unmodified lines# =========================def create_rag_tool():@tooldef rag_search(query: str) -> str:"""Retrieve relevant information from the uploaded document.Use this tool when the user asks questions related to the uploaded PDFor any document-based knowledge. If no document is available or norelevant information is found, return an appropriate message."""global retrieverif retriever is None:return "No document uploaded yet."docs = retriever.invoke(query)if not docs:return "No relevant information found in the uploaded document."# 🔥 FIXED: Just return the content, NOT the prompt templatecontext = "\n\n".join(d.page_content for d in docs)# Return clean context for the LLM to usereturn contextreturn rag_search# =========================# EXTERNAL TOOLS# =========================81 unmodified lines82838485868788899091929394959697989910010110210310410510681 unmodified lines# =========================def create_rag_tool():@tooldef rag_search(query: str) -> str:"""Retrieve information from uploaded document."""global retrieverif retriever is None:return "No document uploaded yet."docs = retriever.invoke(query)if not docs:return "No relevant information found."context = "\n\n".join(d.page_content for d in docs)# 🔥 Add instruction for LLM to process thisreturn f"[DOCUMENT CONTEXT - Summarize this clearly for the user]:\n{context}"return rag_search# =========================# EXTERNAL TOOLS# =========================
tools.py+4-14