tools = [
{
'type': 'function',
'function': {
'name': 'get_weather',
'description': 'Get weather for a location',
'parameters': {
'type': 'object',
'properties': {
'location': {'type': 'string'}
},
'required': ['location']
}
}
}
]
wrapped_client = foil.wrap_openai(client)
response = wrapped_client.chat.completions.create(
model='gpt-4o',
messages=[{'role': 'user', 'content': 'What is the weather in Paris?'}],
tools=tools
)
# Tool calls are captured in the trace
if response.choices[0].message.tool_calls:
for tool_call in response.choices[0].message.tool_calls:
print(f'Tool: {tool_call.function.name}')
print(f'Args: {tool_call.function.arguments}')