Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,21 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
|
4 |
-
|
5 |
-
name = "get_travel_duration"
|
6 |
-
description = "Gets the travel time between two places."
|
7 |
-
inputs = {"start_location":{"type":"string","description":"the place from which you start your ride"},"destination_location":{"type":"string","description":"the place of arrival"},"transportation_mode":{"type":"string","nullable":True,"description":"The transportation mode, in 'driving', 'walking', 'bicycling', or 'transit'. Defaults to 'driving'."}}
|
8 |
-
output_type = "string"
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
""
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
try:
|
26 |
-
directions_result = gmaps.directions(
|
27 |
-
start_location,
|
28 |
-
destination_location,
|
29 |
-
mode=transportation_mode,
|
30 |
-
departure_time=datetime(2025, 12, 6, 11, 0), # At 11, date far in the future
|
31 |
-
)
|
32 |
-
if len(directions_result) == 0:
|
33 |
-
return "No way found between these places with the required transportation mode."
|
34 |
-
return directions_result[0]["legs"][0]["duration"]["text"]
|
35 |
-
except Exception as e:
|
36 |
-
print(e)
|
37 |
-
return e
|
|
|
1 |
+
import os
|
2 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
3 |
|
4 |
+
hf_token = os.getenv("HF_TOKEN")
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
def who_is_bot(person_name: str) -> str:
|
7 |
+
agent = CodeAgent(
|
8 |
+
tools=[DuckDuckGoSearchTool()],
|
9 |
+
model=HfApiModel(hf_token=hf_token)
|
10 |
+
)
|
11 |
+
prompt = (
|
12 |
+
f"Who is {person_name}? "
|
13 |
+
"Give a short 1-2 sentence summary."
|
14 |
+
)
|
15 |
+
result = agent.run(prompt)
|
16 |
+
return result.strip()
|
17 |
|
18 |
+
if __name__ == "__main__":
|
19 |
+
person = "Sundar Pichai"
|
20 |
+
summary = who_is_bot(person)
|
21 |
+
print(f"About {person}: {summary}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|