lamhieu commited on
Commit
e0afec8
1 Parent(s): f6e9614

chore: update something

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -324,9 +324,7 @@ def search_with_wikipedia(
324
  all_results = []
325
  try:
326
  wikipedia.set_lang(language)
327
- page = wikipedia.page(query)
328
- content = page.content[:4096]
329
- all_results.append(content)
330
  except Exception as e:
331
  pass
332
  return all_results
@@ -404,7 +402,7 @@ def generate(
404
 
405
  def build_input_ids(
406
  apply_tools: bool = None,
407
- references = None,
408
  ):
409
  conversation = []
410
  if system_prompt:
@@ -481,6 +479,7 @@ def generate(
481
  keyword = scheduled_tools_runs["arguments"]["keyword"]
482
  search_type = scheduled_tools_runs["arguments"]["type"]
483
  language = scheduled_tools_runs["arguments"]["language"]
 
484
  if search_type == "wikipedia":
485
  gr.Info(
486
  "Searching for information on the Wikipedia.",
@@ -495,11 +494,13 @@ def generate(
495
  "Searching for information on the Google.", duration=5, visible=True
496
  )
497
  document_references.extend(
498
- search_with_google(query=keyword, language=language)
499
- )
500
- print(
501
- "scheduled_tools_runs:", scheduled_tools_runs, document_references
 
502
  )
 
503
 
504
  apply_tools = (
505
  True if allow_used_tools is True and previous_response is None else False
 
324
  all_results = []
325
  try:
326
  wikipedia.set_lang(language)
327
+ all_results.append(wikipedia.summary(query))
 
 
328
  except Exception as e:
329
  pass
330
  return all_results
 
402
 
403
  def build_input_ids(
404
  apply_tools: bool = None,
405
+ references=None,
406
  ):
407
  conversation = []
408
  if system_prompt:
 
479
  keyword = scheduled_tools_runs["arguments"]["keyword"]
480
  search_type = scheduled_tools_runs["arguments"]["type"]
481
  language = scheduled_tools_runs["arguments"]["language"]
482
+ print("scheduled_tools_runs:", scheduled_tools_runs)
483
  if search_type == "wikipedia":
484
  gr.Info(
485
  "Searching for information on the Wikipedia.",
 
494
  "Searching for information on the Google.", duration=5, visible=True
495
  )
496
  document_references.extend(
497
+ search_with_google(
498
+ query=keyword,
499
+ language=language,
500
+ num_results=2 if search_type == "wikipedia" else 3,
501
+ )
502
  )
503
+ print("document_references:", document_references)
504
 
505
  apply_tools = (
506
  True if allow_used_tools is True and previous_response is None else False