forked from Ashfaqbs/TinyLLM-usecases
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
61 lines (43 loc) · 1.32 KB
/
Copy pathtools.py
File metadata and controls
61 lines (43 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Tool definitions for Qwen3 tool calling examples.
Single source of truth - imported by both main.py and server.py.
Same tools as functionGemma for direct comparison.
"""
from langchain_core.tools import tool
# --- Simulated Data ---
WEATHER_DATA = {
"london": "15C, cloudy",
"tokyo": "22C, sunny",
"new york": "18C, partly cloudy",
"mumbai": "32C, humid",
}
CONTACTS = {
"alice": "alice@example.com | +1-555-0101",
"bob": "bob@example.com | +1-555-0102",
"charlie": "charlie@example.com | +1-555-0103",
}
# --- Tool Definitions ---
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a given city.
Args:
city: Name of the city to get weather for.
"""
return WEATHER_DATA.get(city.lower(), f"No weather data available for {city}")
@tool
def add_numbers(a: int, b: int) -> int:
"""Add two numbers together and return the result.
Args:
a: First number.
b: Second number.
"""
return a + b
@tool
def search_contacts(name: str) -> str:
"""Search for a contact by name in the address book.
Args:
name: Name of the contact to search for.
"""
return CONTACTS.get(name.lower(), f"No contact found for '{name}'")
ALL_TOOLS = [get_weather, add_numbers, search_contacts]
TOOL_MAP = {t.name: t for t in ALL_TOOLS}