nikhmr1235 commited on
Commit
684b359
·
verified ·
1 Parent(s): 037639f

Update helper.py

Browse files
Files changed (1) hide show
  1. helper.py +4 -11
helper.py CHANGED
@@ -232,23 +232,16 @@ from langchain_community.tools import WikipediaQueryRun
232
  from langchain_community.utilities import WikipediaAPIWrapper
233
  from langchain.tools import Tool # Ensure Tool is imported
234
 
 
235
  def get_wikipedia_tool() -> Tool:
236
  """
237
  Creates and returns a LangChain Tool for querying Wikipedia.
238
  """
239
- # Initialize the Wikipedia API Wrapper
240
- # Configure the wrapper to control how much content is returned.
241
- # 'top_k_results': Number of search results to return.
242
- # 'doc_content_chars_max': Maximum number of characters from the page content.
243
- # Setting this to a reasonable limit (e.g., 2000-4000)
244
- # is crucial for token management, as Wikipedia articles can be very long.
245
- # Adjust based on your LLM's context window and typical use cases.
246
  wikipedia_api_wrapper = WikipediaAPIWrapper(
247
- top_k_results=3, # Get up to 3 most relevant articles
248
- doc_content_chars_max=2000 # Limit content to 2000 characters per article
249
  )
250
 
251
- # Initialize the Wikipedia tool with the wrapper
252
  wikipedia_query_tool = WikipediaQueryRun(api_wrapper=wikipedia_api_wrapper)
253
 
254
  return Tool(
@@ -277,7 +270,7 @@ def get_wikipedia_tool() -> Tool:
277
  **Output:**
278
  The tool returns a string containing snippets of relevant Wikipedia articles.
279
  The output is limited in length to save tokens. If the answer is not found in the snippet,
280
- you might need to refine your query or consider using a broader search tool like 'tavily_search'.
281
  """,
282
  func=wikipedia_query_tool.run,
283
  )
 
232
  from langchain_community.utilities import WikipediaAPIWrapper
233
  from langchain.tools import Tool # Ensure Tool is imported
234
 
235
+
236
  def get_wikipedia_tool() -> Tool:
237
  """
238
  Creates and returns a LangChain Tool for querying Wikipedia.
239
  """
 
 
 
 
 
 
 
240
  wikipedia_api_wrapper = WikipediaAPIWrapper(
241
+ top_k_results=3,
242
+ doc_content_chars_max=2000
243
  )
244
 
 
245
  wikipedia_query_tool = WikipediaQueryRun(api_wrapper=wikipedia_api_wrapper)
246
 
247
  return Tool(
 
270
  **Output:**
271
  The tool returns a string containing snippets of relevant Wikipedia articles.
272
  The output is limited in length to save tokens. If the answer is not found in the snippet,
273
+ you might need to refine your query or **consider using 'tavily_search' or other available tools for a broader search.**
274
  """,
275
  func=wikipedia_query_tool.run,
276
  )