Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -18,6 +19,28 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -35,6 +58,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 +79,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,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from tools.cheapest_flight import get_flight, GetCheapestFlightTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
|
|
| 19 |
"""
|
| 20 |
return "What magic will you build ?"
|
| 21 |
|
| 22 |
+
@tool
|
| 23 |
+
def get_cheapset_flight(departureId:str, arrivalId:str, departureDate:str)-> str:
|
| 24 |
+
"""A tool that returns information about the cheapest flight given the departure, arrival and date
|
| 25 |
+
Args:
|
| 26 |
+
departureId: The ID in which the airport of the departure location is.
|
| 27 |
+
arrivalId: The ID in which the airport of the arrival location is.
|
| 28 |
+
departureDate: the date to look for the cheapest flight.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
try:
|
| 32 |
+
cheapest = get_flight(departureId, arrivalId, departureDate)
|
| 33 |
+
return f"""
|
| 34 |
+
Cheapest Flight Details:
|
| 35 |
+
Price: {cheapest['price']}
|
| 36 |
+
From: {cheapest['departure']['from']} at {cheapest['departure']['time']}
|
| 37 |
+
To: {cheapest['arrival']['to']} at {cheapest['arrival']['time']}
|
| 38 |
+
Airline: {cheapest['airline']}
|
| 39 |
+
"""
|
| 40 |
+
except Exception as e:
|
| 41 |
+
return f"Error fetching time for cheapest flight: {str(e)}"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
@tool
|
| 45 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 46 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
final_answer = FinalAnswerTool()
|
| 61 |
+
cheapest_flight_tool = GetCheapestFlightTool()
|
| 62 |
|
| 63 |
# 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:
|
| 64 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
| 79 |
|
| 80 |
agent = CodeAgent(
|
| 81 |
model=model,
|
| 82 |
+
tools=[final_answer, cheapest_flight_tool], ## add your tools here (don't remove final answer)
|
| 83 |
max_steps=6,
|
| 84 |
verbosity_level=1,
|
| 85 |
grammar=None,
|