def get_city_uuid(city: str) -> str:
"""Just a fake tool to return a fake UUID"""
uuid = str(uuid4())
return f"{city} ID: {uuid}"
# The tool schema that we will pass to the model
tools = [
{
"type": "function",
"name": "get_city_uuid",
"description": "Retrieve the internal ID for a city from the internal database. Only invoke this function if the user needs to know the internal ID for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "The name of the city to get information about"}
},
"required": ["city"]
}
}
]
# This is a general practice - we need a mapping of the tool names we tell the model about, and the functions that implement them.
tool_mapping = {
"get_city_uuid": get_city_uuid
}
# Let's add this to our defaults so we don't have to pass it every time
MODEL_DEFAULTS["tools"] = tools
response = client.responses.create(
input="What's the internal ID for the lowest-temperature city?",
previous_response_id=response.id,
**MODEL_DEFAULTS)
print(response.output_text)