@trace
def basic_function_calling():
"""
Demonstrate basic function calling with Azure OpenAI API.
The model will decide when to call the function based on the user query.
"""
# Define the tools (functions) the model can use
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a specified location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and country, e.g., 'San Francisco, CA' or 'Paris, France'"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Default is celsius."
}
},
"required": ["location"]
}
}
}
]
# Make a request to the Azure OpenAI API
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What's the weather like in Paris today?"}
]
# This API call will be traced by HoneyHive
response = client.chat.completions.create(
model="deployment-name", # Replace with your actual deployment name
messages=messages,
tools=tools,
tool_choice="auto"
)
# Continue processing the response...