Zack Saadioui
4/24/2025
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
python
def get_weather(location):
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        functions=[
            {
                "name": "get_current_weather",
                "description": "Get current weather given location",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": {"type": "string"},
                        "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                    }
                }
            }
        ],
        messages=[{ "role": "user", "content": f"What's the weather like in {location}?"}]
    )
    return responseCopyright © Arsturn 2025