Update app.py
Browse filesTry to make tool for wikipedia search
app.py
CHANGED
|
@@ -1,5 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
"""
|
| 5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
+
from smolagents import CodeAgent, HfApiModel, tool
|
| 4 |
+
|
| 5 |
+
@tool
|
| 6 |
+
def search_wikipedia_pages(search_string: str) -> str:
|
| 7 |
+
"""This tool helps to search for wikipedia pages related to a search string.
|
| 8 |
+
The output are the first 10 pages related to the search string.
|
| 9 |
+
Args:
|
| 10 |
+
arg1: the search string
|
| 11 |
+
"""
|
| 12 |
+
try:
|
| 13 |
+
page_titles = wikipedia.search(search_string, results=10)
|
| 14 |
+
return page_titles
|
| 15 |
+
except (
|
| 16 |
+
self.wiki_client.exceptions.PageError,
|
| 17 |
+
self.wiki_client.exceptions.DisambiguationError,
|
| 18 |
+
):
|
| 19 |
+
print ("An error occured")
|
| 20 |
|
| 21 |
"""
|
| 22 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|