File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
articles/ai-services/openai/how-to Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,32 @@ foreach (float item in returnValue.Value.Data[0].Embedding.ToArray())
94
94
}
95
95
```
96
96
97
+ # [ PowerShell] ( #tab/PowerShell )
98
+ ``` powershell-interactive
99
+ # Azure OpenAI metadata variables
100
+ $openai = @{
101
+ api_key = $Env:AZURE_OPENAI_KEY
102
+ api_base = $Env:AZURE_OPENAI_ENDPOINT # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
103
+ api_version = '2023-05-15' # this may change in the future
104
+ name = 'YOUR-DEPLOYMENT-NAME-HERE' #This will correspond to the custom name you chose for your deployment when you deployed a model.
105
+ }
106
+
107
+ $headers = [ordered]@{
108
+ 'api-key' = $openai.api_key
109
+ }
110
+
111
+ $text = 'Your text string goes here'
112
+
113
+ $body = [ordered]@{
114
+ input = $text
115
+ } | ConvertTo-Json
116
+
117
+ $url = "$($openai.api_base)/openai/deployments/$($openai.name)/embeddings?api-version=$($openai.api_version)"
118
+
119
+ $response = Invoke-RestMethod -Uri $url -Headers $headers -Body $body -Method Post -ContentType 'application/json'
120
+ return $response.data.embedding
121
+ ```
122
+
97
123
---
98
124
99
125
## Best practices
You can’t perform that action at this time.
0 commit comments