Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,15 +8,29 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
|
|
|
|
|
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -35,6 +49,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 35 |
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
|
|
|
| 38 |
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
@@ -55,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
+
import requests
|
| 12 |
+
import json
|
| 13 |
+
|
| 14 |
@tool
|
| 15 |
+
def extract_crypto_data(crypto_name: str) -> str:
|
| 16 |
+
"""
|
| 17 |
+
Fetches current cryptocurrency data for a given crypto id.
|
| 18 |
+
|
| 19 |
Args:
|
| 20 |
+
crypto_name: The crypto currency id (e.g., 'bitcoin')
|
| 21 |
+
|
| 22 |
+
Returns:
|
| 23 |
+
A JSON-formatted string containing the crypto data if successful,
|
| 24 |
+
otherwise an error message.
|
| 25 |
"""
|
| 26 |
+
url = f"https://api.coincap.io/v2/assets/{crypto_name}"
|
| 27 |
+
try:
|
| 28 |
+
response = requests.get(url)
|
| 29 |
+
response.raise_for_status() # Raises HTTPError for bad responses (4xx, 5xx)
|
| 30 |
+
data = response.json()
|
| 31 |
+
return json.dumps(data) # Return the data as a JSON string
|
| 32 |
+
except requests.exceptions.RequestException as e:
|
| 33 |
+
return f"Error: {str(e)}"
|
| 34 |
|
| 35 |
@tool
|
| 36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
final_answer = FinalAnswerTool()
|
| 52 |
+
web_search = DuckDuckGoSearchTool()
|
| 53 |
|
| 54 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 55 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
+
tools=[create_markdown,get_current_time_in_timezone,web_search,final_answer], ## add your tools here (don't remove final answer)
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|