Skip to content

Commit aa5dc5b

Browse files
committed
Merge branch 'main' of https://github.com/MicrosoftDocs/azure-docs-pr into postRel
2 parents c84109e + a4f9866 commit aa5dc5b

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

articles/ai-services/openai/how-to/function-calling.md

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: mrbullwinkle #dereklegenzoff
66
ms.author: mbullwin #delegenz
77
ms.service: azure-ai-openai
88
ms.topic: how-to
9-
ms.date: 07/20/2023
9+
ms.date: 11/06/2023
1010
manager: nitinme
1111
---
1212

@@ -29,8 +29,10 @@ To use function calling with the Chat Completions API, you need to include two n
2929

3030
When functions are provided, by default the `function_call` will be set to `"auto"` and the model will decide whether or not a function should be called. Alternatively, you can set the `function_call` parameter to `{"name": "<insert-function-name>"}` to force the API to call a specific function or you can set the parameter to `"none"` to prevent the model from calling any functions.
3131

32+
# [OpenAI Python 0.28.1](#tab/python)
33+
3234
```python
33-
# Note: The openai-python library support for Azure OpenAI is in preview.
35+
3436
import os
3537
import openai
3638

@@ -69,7 +71,7 @@ functions= [
6971
]
7072

7173
response = openai.ChatCompletion.create(
72-
engine="gpt-35-turbo-0613",
74+
engine="gpt-35-turbo-0613", # engine = "deployment_name"
7375
messages=messages,
7476
functions=functions,
7577
function_call="auto",
@@ -92,6 +94,74 @@ The response from the API includes a `function_call` property if the model deter
9294

9395
In some cases, the model may generate both `content` and a `function_call`. For example, for the prompt above the content could say something like "Sure, I can help you find some hotels in San Diego that match your criteria" along with the function_call.
9496

97+
# [OpenAI Python 1.x](#tab/python-new)
98+
99+
```python
100+
import os
101+
from openai import AzureOpenAI
102+
103+
client = AzureOpenAI(
104+
api_key=os.getenv("AZURE_OPENAI_KEY"),
105+
api_version="2023-10-01-preview",
106+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"
107+
)
108+
109+
messages= [
110+
{"role": "user", "content": "Find beachfront hotels in San Diego for less than $300 a month with free breakfast."}
111+
]
112+
113+
functions= [
114+
{
115+
"name": "search_hotels",
116+
"description": "Retrieves hotels from the search index based on the parameters provided",
117+
"parameters": {
118+
"type": "object",
119+
"properties": {
120+
"location": {
121+
"type": "string",
122+
"description": "The location of the hotel (i.e. Seattle, WA)"
123+
},
124+
"max_price": {
125+
"type": "number",
126+
"description": "The maximum price for the hotel"
127+
},
128+
"features": {
129+
"type": "string",
130+
"description": "A comma separated list of features (i.e. beachfront, free wifi, etc.)"
131+
}
132+
},
133+
"required": ["location"]
134+
}
135+
}
136+
]
137+
138+
response = client.chat.completions.create(
139+
model="gpt-35-turbo-0613", # model = "deployment_name"
140+
messages= messages,
141+
functions = functions,
142+
function_call="auto",
143+
)
144+
145+
print(response.choices[0].message.model_dump_json(indent=2))
146+
```
147+
148+
The response from the API includes a `function_call` property if the model determines that a function should be called. The `function_call` property includes the name of the function to call and the arguments to pass to the function. The arguments are a JSON string that you can parse and use to call your function.
149+
150+
```json
151+
{
152+
"content": null,
153+
"role": "assistant",
154+
"function_call": {
155+
"arguments": "{\n \"location\": \"San Diego\",\n \"max_price\": 300,\n \"features\": \"beachfront, free breakfast\"\n}",
156+
"name": "search_hotels"
157+
}
158+
}
159+
```
160+
161+
In some cases, the model may generate both `content` and a `function_call`. For example, for the prompt above the content could say something like "Sure, I can help you find some hotels in San Diego that match your criteria" along with the function_call.
162+
163+
---
164+
95165
## Working with function calling
96166

97167
The following section goes into additional detail on how to effectively use functions with the Chat Completions API.
@@ -107,6 +177,7 @@ If you want to describe a function that doesn't accept any parameters, use `{"ty
107177
### Managing the flow with functions
108178

109179
```python
180+
110181
response = openai.ChatCompletion.create(
111182
deployment_id="gpt-35-turbo-0613",
112183
messages=messages,

articles/azure-vmware/configure-vmware-hcx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ For an end-to-end overview of this procedure, view the [Azure VMware Solution: C
169169
The selections define the resources where VMs can consume VMware HCX services.
170170

171171
> [!NOTE]
172-
> If you have a mixed mode SDDC with a fleet cluster, deployment of service mesh appliances for fleet cluster is not viable/supported.
172+
> If you have a mixed mode SDDC with a AV64 cluster, deployment of service mesh appliances on AV64 cluster is not viable/supported. However, this would't prevent you from having HCX migration or network extention directly on to AV64 clusters with service appliances hosted on cluster-1.
173173
174174
:::image type="content" source="media/tutorial-vmware-hcx/select-compute-profile-source.png" alt-text="Screenshot that shows selecting the source compute profile." lightbox="media/tutorial-vmware-hcx/select-compute-profile-source.png":::
175175

articles/postgresql/flexible-server/overview.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ One advantage of running your workload in Azure is global reach. The flexible se
9797
| East US 2 | :heavy_check_mark: (v3/v4 only) | :x: $ | :heavy_check_mark: | :heavy_check_mark: |
9898
| France Central | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
9999
| France South | :heavy_check_mark: (v3/v4 only) | :x: | :heavy_check_mark: | :heavy_check_mark: |
100-
| Germany West Central | :heavy_check_mark: (v3/v4 only) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
100+
| Germany West Central | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
101+
| Italy North | :heavy_check_mark: (v3/v4 only) | :heavy_check_mark: | :heavy_check_mark: | :x: |
101102
| Japan East | :heavy_check_mark: (v3/v4 only) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
102103
| Japan West | :heavy_check_mark: (v3/v4 only) | :x: | :heavy_check_mark: | :heavy_check_mark: |
103104
| Jio India West | :heavy_check_mark: (v3 only) | :x: | :heavy_check_mark: | :x: |

0 commit comments

Comments
 (0)