mafzaal commited on
Commit
48ec46f
·
1 Parent(s): 4dc95d7

refactor: Update URLs in RSS feed tool example for relevance

Browse files
py-src/lets_talk/models/agent.py CHANGED
@@ -183,7 +183,7 @@ def parse_output(input_state: Dict[str, Any]) -> str:
183
  return "I encountered an error while processing your request."
184
 
185
 
186
- def build_agent_chain(tools, retriever=None):
187
  """
188
  Constructs and returns the research agent execution chain.
189
 
@@ -204,17 +204,17 @@ def build_agent_chain(tools, retriever=None):
204
  model = model.bind_tools(tools)
205
 
206
  # Create document search tool if retriever is provided
207
- if retriever:
208
- doc_search_tool = Tool(
209
- name="DocumentSearch",
210
- description="Search within the user's uploaded document. Use this tool when you need information from the specific document that was uploaded.",
211
- func=lambda query: document_search_tool(retriever, query),
212
- args_schema=RAGQueryInput
213
- )
214
-
215
- # Add document search tool to the tool belt if we have upload capability
216
- tools = tools.copy()
217
- tools.append(doc_search_tool)
218
 
219
  # Create a node for tool execution
220
  tool_node = ToolNode(tools)
@@ -227,16 +227,14 @@ def build_agent_chain(tools, retriever=None):
227
  return call_model(model, state)
228
 
229
  # Add nodes
230
- if retriever:
231
- # Define retrieval node factory with bound retriever
232
- def retrieve_node(state):
233
- return retrieve_from_documents(state, retriever)
234
-
235
- uncompiled_graph.add_node("retrieve", retrieve_node)
236
- uncompiled_graph.set_entry_point("retrieve")
237
- uncompiled_graph.add_edge("retrieve", "agent")
238
- else:
239
- uncompiled_graph.set_entry_point("agent")
240
 
241
  uncompiled_graph.add_node("agent", call_model_node)
242
  uncompiled_graph.add_node("action", tool_node)
 
183
  return "I encountered an error while processing your request."
184
 
185
 
186
+ def build_agent_chain(tools, retriever) -> StateGraph:
187
  """
188
  Constructs and returns the research agent execution chain.
189
 
 
204
  model = model.bind_tools(tools)
205
 
206
  # Create document search tool if retriever is provided
207
+
208
+ doc_search_tool = Tool(
209
+ name="DocumentSearch",
210
+ description="Search within the user's uploaded document. Use this tool when you need information from the specific document that was uploaded.",
211
+ func=lambda query: document_search_tool(retriever, query),
212
+ args_schema=RAGQueryInput
213
+ )
214
+
215
+ # Add document search tool to the tool belt if we have upload capability
216
+ tools = tools.copy()
217
+ tools.append(doc_search_tool)
218
 
219
  # Create a node for tool execution
220
  tool_node = ToolNode(tools)
 
227
  return call_model(model, state)
228
 
229
  # Add nodes
230
+
231
+ # Define retrieval node factory with bound retriever
232
+ def retrieve_node(state):
233
+ return retrieve_from_documents(state, retriever)
234
+
235
+ uncompiled_graph.add_node("retrieve", retrieve_node)
236
+ uncompiled_graph.set_entry_point("retrieve")
237
+ uncompiled_graph.add_edge("retrieve", "agent")
 
 
238
 
239
  uncompiled_graph.add_node("agent", call_model_node)
240
  uncompiled_graph.add_node("action", tool_node)
py-src/lets_talk/models/research_tools.py CHANGED
@@ -183,7 +183,7 @@ def create_rss_feed_tool() -> Tool:
183
 
184
  if __name__ == "__main__":
185
  # Example usage of the RSS feed tool
186
- urls = ["https://news.ycombinator.com/rss","http://fox13now.com/2013/12/30/new-year-new-laws-obamacare-pot-guns-and-drones/"]
187
  query = "latest research"
188
  max_results = 5
189
  nlp = True
 
183
 
184
  if __name__ == "__main__":
185
  # Example usage of the RSS feed tool
186
+ urls = ["https://thedataguy.pro/rss.xml","https://news.ycombinator.com/rss"]
187
  query = "latest research"
188
  max_results = 5
189
  nlp = True