File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
articles/ai-services/openai/how-to Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ services: cognitive-services
6
6
manager : nitinme
7
7
ms.service : azure-ai-openai
8
8
ms.topic : how-to
9
- ms.date : 11/02 /2023
9
+ ms.date : 11/06 /2023
10
10
author : mrbullwinkle
11
11
ms.author : mbullwin
12
12
recommendations : false
@@ -30,7 +30,8 @@ curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYM
30
30
-d '{"input": "Sample Document goes here"}'
31
31
```
32
32
33
- # [ python] ( #tab/python )
33
+ # [ OpenAI Python 0.28.1] ( #tab/python )
34
+
34
35
``` python
35
36
import openai
36
37
@@ -47,6 +48,26 @@ embeddings = response['data'][0]['embedding']
47
48
print (embeddings)
48
49
```
49
50
51
+ # [ OpenAI Python 1.0] ( #tab/python-new )
52
+
53
+ ``` python
54
+ import os
55
+ from openai import AzureOpenAI
56
+
57
+ client = AzureOpenAI(
58
+ api_key = os.getenv(" AZURE_OPENAI_KEY" ),
59
+ api_version = " 2023-05-15" ,
60
+ azure_endpoint = os.getenv(" AZURE_OPENAI_ENDPOINT" )
61
+ )
62
+
63
+ response = client.embeddings.create(
64
+ input = " Your text string goes here" ,
65
+ model = " text-embedding-ada-002"
66
+ )
67
+
68
+ print (response.model_dump_json(indent = 2 ))
69
+ ```
70
+
50
71
# [ C#] ( #tab/csharp )
51
72
``` csharp
52
73
using Azure ;
You can’t perform that action at this time.
0 commit comments