ThanhNguyenDuc commited on
Commit
4f91750
·
verified ·
1 Parent(s): 791f6a6
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -73,6 +73,23 @@ def find_non_commutative_elements_from_table(table_markdown: str) -> str:
73
 
74
  # Định nghĩa các tools dùng
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  tools = [
77
  multiply,
78
  divide,
 
73
 
74
  # Định nghĩa các tools dùng
75
 
76
+ @tool
77
+ def wiki_search(query: str) -> str:
78
+ """Searches Wikipedia for a given query and returns a summary of the content."""
79
+ import wikipedia
80
+ try:
81
+ summary = wikipedia.summary(query, sentences=3, auto_suggest=False, redirect=True)
82
+ return summary
83
+ except wikipedia.exceptions.PageError:
84
+ return f"No Wikipedia page found for '{{query}}'."
85
+ except wikipedia.exceptions.DisambiguationError as e:
86
+ if e.options:
87
+ return f"Wikipedia search for '{{query}}' is ambiguous. Options include: {{', '.join(e.options[:3])}}..."
88
+ return f"Wikipedia search for '{{query}}' led to a disambiguation page with no clear options."
89
+ except Exception as e:
90
+ return f"An error occurred during Wikipedia search: {{str(e)}}"
91
+
92
+
93
  tools = [
94
  multiply,
95
  divide,