Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,15 +11,19 @@ from Gradio_UI import GradioUI
|
|
| 11 |
@tool
|
| 12 |
def lingua_stats(language:str)->str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that retrieves the number of speakers for the language
|
| 15 |
Args:
|
| 16 |
language: Name of the language e.g. Tamil, Hindi, English
|
| 17 |
"""
|
| 18 |
try:
|
| 19 |
-
# Create
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
except Exception as e:
|
| 24 |
return f"Error: Search failed for {language}"
|
| 25 |
|
|
|
|
| 11 |
@tool
|
| 12 |
def lingua_stats(language:str)->str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
"""A tool that retrieves the number of speakers for the language as a percentage of the world population
|
| 15 |
Args:
|
| 16 |
language: Name of the language e.g. Tamil, Hindi, English
|
| 17 |
"""
|
| 18 |
try:
|
| 19 |
+
# Create agent web search object
|
| 20 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
| 21 |
+
|
| 22 |
+
model = HfApiModel()
|
| 23 |
+
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
| 24 |
+
world_population = agent.run("What is the world population?")
|
| 25 |
+
lang_spkrs = agent.run(f"How many people in the speak {language}?")
|
| 26 |
+
return f"The percentage of {language} speaking population in the world is : {lang_spkrs}/{world_population}"
|
| 27 |
except Exception as e:
|
| 28 |
return f"Error: Search failed for {language}"
|
| 29 |
|