junaid17 commited on
Commit
b786d75
·
verified ·
1 Parent(s): 7f8e290

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +4 -14
tools.py CHANGED
@@ -82,35 +82,25 @@ def get_retriever():
82
  # =========================
83
 
84
  def create_rag_tool():
85
-
86
  @tool
87
  def rag_search(query: str) -> str:
88
- """
89
- Retrieve relevant information from the uploaded document.
90
-
91
- Use this tool when the user asks questions related to the uploaded PDF
92
- or any document-based knowledge. If no document is available or no
93
- relevant information is found, return an appropriate message.
94
- """
95
  global retriever
96
 
97
  if retriever is None:
98
  return "No document uploaded yet."
99
 
100
  docs = retriever.invoke(query)
101
-
102
  if not docs:
103
- return "No relevant information found in the uploaded document."
104
 
105
- # 🔥 FIXED: Just return the content, NOT the prompt template
106
  context = "\n\n".join(d.page_content for d in docs)
107
 
108
- # Return clean context for the LLM to use
109
- return context
110
 
111
  return rag_search
112
 
113
-
114
  # =========================
115
  # EXTERNAL TOOLS
116
  # =========================
 
82
  # =========================
83
 
84
  def create_rag_tool():
 
85
  @tool
86
  def rag_search(query: str) -> str:
87
+ """Retrieve information from uploaded document."""
 
 
 
 
 
 
88
  global retriever
89
 
90
  if retriever is None:
91
  return "No document uploaded yet."
92
 
93
  docs = retriever.invoke(query)
 
94
  if not docs:
95
+ return "No relevant information found."
96
 
 
97
  context = "\n\n".join(d.page_content for d in docs)
98
 
99
+ # 🔥 Add instruction for LLM to process this
100
+ return f"[DOCUMENT CONTEXT - Summarize this clearly for the user]:\n{context}"
101
 
102
  return rag_search
103
 
 
104
  # =========================
105
  # EXTERNAL TOOLS
106
  # =========================