Spaces:
Sleeping
Sleeping
Added get_stock_price tool
Browse files
app.py
CHANGED
|
@@ -33,7 +33,20 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 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:
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def get_stock_price(stock: str) -> str:
|
| 38 |
+
"""A tool that fetches the current stock price and trading volume.
|
| 39 |
+
Args:
|
| 40 |
+
stock: A string representing a valid stock name or stock code (e.g., 'DIALOG' or '7277').
|
| 41 |
+
"""
|
| 42 |
+
try:
|
| 43 |
+
# Create stock object
|
| 44 |
+
stk = DuckDuckGoSearchTool(f'What is the current price of {stock}?')
|
| 45 |
+
return f"The current price for {stock} is {stk}"
|
| 46 |
+
except Exception as e:
|
| 47 |
+
return f"Error fetching price for stock '{stock}': {str(e)}"
|
| 48 |
|
| 49 |
+
|
| 50 |
final_answer = FinalAnswerTool()
|
| 51 |
|
| 52 |
# 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:
|