Skip to content

Commit 538ce67

Browse files
committed
rest example
1 parent 74f69b4 commit 538ce67

File tree

1 file changed

+19
-45
lines changed

1 file changed

+19
-45
lines changed

articles/ai-services/openai/how-to/assistant-functions.md

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -76,40 +76,25 @@ assistant = client.beta.assistants.create(
7676
> With Azure OpenAI the `model` parameter requires model deployment name. If your model deployment name is different than the underlying model name then you would adjust your code to ` "model": "{your-custom-model-deployment-name}"`.
7777
7878
```console
79-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2024-02-15-preview \
79+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/assistants?api-version=2024-07-01-preview \
8080
-H "api-key: $AZURE_OPENAI_API_KEY" \
8181
-H "Content-Type: application/json" \
8282
-d '{
8383
"instructions": "You are a weather bot. Use the provided functions to answer questions.",
84-
"tools": [{
84+
tools=[{
8585
"type": "function",
86-
"function": {
87-
"name": "getCurrentWeather",
88-
"description": "Get the weather in location",
89-
"parameters": {
90-
"type": "object",
91-
"properties": {
92-
"location": {"type": "string", "description": "The city and state e.g. San Francisco, CA"},
93-
"unit": {"type": "string", "enum": ["c", "f"]}
94-
},
95-
"required": ["location"]
96-
}
97-
}
98-
},
99-
{
100-
"type": "function",
101-
"function": {
102-
"name": "getNickname",
103-
"description": "Get the nickname of a city",
104-
"parameters": {
105-
"type": "object",
106-
"properties": {
107-
"location": {"type": "string", "description": "The city and state e.g. San Francisco, CA"}
108-
},
109-
"required": ["location"]
110-
}
111-
}
112-
}],
86+
"function": {
87+
"name": "get_weather",
88+
"description": "Get the weather in location",
89+
"parameters": {
90+
"type": "object",
91+
"properties": {
92+
"location": {"type": "string", "description": "The city name, for example San Francisco"}
93+
},
94+
"required": ["location"]
95+
}
96+
}
97+
}],
11398
"model": "gpt-4-1106-preview"
11499
}'
115100
```
@@ -135,18 +120,10 @@ When you initiate a **Run** with a user Message that triggers the function, the
135120
"id": "call_abc123",
136121
"type": "function",
137122
"function": {
138-
"name": "getCurrentWeather",
123+
"name": "get_weather",
139124
"arguments": "{\"location\":\"San Francisco\"}"
140125
}
141126
},
142-
{
143-
"id": "call_abc456",
144-
"type": "function",
145-
"function": {
146-
"name": "getNickname",
147-
"arguments": "{\"location\":\"Los Angeles\"}"
148-
}
149-
}
150127
]
151128
}
152129
},
@@ -222,16 +199,13 @@ else:
222199
# [REST](#tab/rest)
223200

224201
```console
225-
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/thread_abc123/runs/run_123/submit_tool_outputs?api-version=2024-02-15-preview \
202+
curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/threads/thread_abc123/runs/run_123/submit_tool_outputs?api-version=2024-07-01-preview \
226203
-H "Content-Type: application/json" \
227-
-H "api-key: $AZURE_OPENAI_API_KEY" \
204+
-H "api-key: 851c6e0b83744d8c8fc2a07eab098376" \
228205
-d '{
229206
"tool_outputs": [{
230-
"tool_call_id": "call_abc123",
231-
"output": "{"temperature": "22", "unit": "celsius"}"
232-
}, {
233-
"tool_call_id": "call_abc456",
234-
"output": "{"nickname": "LA"}"
207+
"tool_call_id": "call_123",
208+
"output": "{\"60 degrees F and raining\"}"
235209
}]
236210
}'
237211
```

0 commit comments

Comments
 (0)