From 9da46f0532d33049b5672011aaee0cb03f05ad4a Mon Sep 17 00:00:00 2001 From: Shivam Kumar Singh Date: Tue, 18 Jul 2023 05:33:59 +0000 Subject: [PATCH 1/9] Add documentation for Azure OpenAI Signed-off-by: Shivam Kumar Singh --- .../supported-bindings/openai.md | 236 ++++++++++++++++++ daprdocs/data/components/bindings/azure.yaml | 8 + 2 files changed, 244 insertions(+) create mode 100644 daprdocs/content/en/reference/components-reference/supported-bindings/openai.md diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md new file mode 100644 index 00000000000..85ae37a5352 --- /dev/null +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md @@ -0,0 +1,236 @@ +--- +type: docs +title: "Azure OpenAI binding spec" +linkTitle: "Azure OpenAI" +description: "Detailed documentation on the Azure OpenAI binding component" +aliases: + - "/operations/components/setup-bindings/supported-bindings/openai/" +--- + +## Component format + +To setup OpenAI binding create a component of type `bindings.azure.openai`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration. +See [this](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/overview/) for the documentation for Azure OpenAI Service. + + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: +spec: + type: bindings.azure.openai + version: v1 + metadata: + - name: apiKey + value: "1234567890abcdef" + - name: endpoint # Required + value: "https://myopenai.openai.azure.com" + - name: deploymentId # Required + value: "my-model" +``` +{{% alert title="Warning" color="warning" %}} +The above example uses apiKey as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). +{{% /alert %}} + +## Spec metadata fields + +| Field | Required | Binding support | Details | Example | +|--------------------|:--------:|--------|---------|---------| +| `endpoint` | Y | Input/Output | Azure OpenAI service endpoint URL. | `"https://myopenai.openai.azure.com"` | +| `apiKey` | Y* | Input/Output | The access key of the Azure OpenAI service. Only required when not using Azure AD authentication. | `"1234567890abcdef"` | +| `deploymentId` | Y | Output | The name of the model deployment. | `"my-model"` | + +### Azure Active Directory (AAD) authentication + +The Azure OpenAI binding component supports authentication using all Azure Active Directory mechanisms. For further information and the relevant component metadata fields to provide depending on the choice of AAD authentication mechanism, see the [docs for authenticating to Azure]({{< ref authenticating-azure.md >}}). + +#### Example Configuration + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: component +metadata: + name: +spec: + type: bindings.azure.openai + version: v1 + metadata: + - name: endpoint + value: "https://myopenai.openai.azure.com" + - name: deploymentId + value: "my-model" + - name: azureTenantId + value: "***" + - name: azureClientId + value: "***" + - name: azureClientSecret + value: "***" +``` +## Binding support + +This component supports **output binding** with the following operations: + +- `completion` : [Completion API](#completion-api) +- `chat-completion` : [Chat Completion API](#chat-completion-api) + +### Completion API + +To call the completion API with a prompt, invoke the Azure OpenAI binding with a `POST` method and the following JSON body: + +```json +{ + "operation": "create", + "data": { + "prompt": "A dog is", + "maxTokens":5 + } +} +``` + +The data parameters are: + +- `prompt` - string that specifies the prompt to generate completions for. +- `maxTokens` - (optional) defines the max number of tokens to generate. Defaults to 16 for completion API. +- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Defaults to 1.0 for completion API. +- `topP` - (optional) defines the sampling temperature. Defaults to 1.0 for completion API. +- `n` - (optional) defines the number of completions to generate. Defaults to 1 for completion API. +- `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for completion API. +- `frequencyPenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.0 for completion API. + +Read more about the importance and usage of these parameters in the [Azure OpenAI API documentation](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference). +#### Examples + +{{< tabs Linux >}} + {{% codetab %}} + ```bash + curl -d '{ "data": {"prompt": "A dog is ", "maxTokens":15}, "operation": "completion" }' \ + http://localhost:/v1.0/bindings/ + ``` + {{% /codetab %}} + +{{< /tabs >}} + +#### Response + +The response body will contain the following JSON: + +```json +[ + { + "finish_reason": "length", + "index": 0, + "text": " a pig in a dress.\n\nSun, Oct 20, 2013" + }, + { + "finish_reason": "length", + "index": 1, + "text": " the only thing on earth that loves you\n\nmore than he loves himself.\"\n\n" + } +] + +``` + +### Chat Completion API + +To perform a chat-completion operation, invoke the Azure OpenAI binding with a `POST` method and the following JSON body: + +```json +{ + "operation": "chat-completion", + "data": { + "messages": [ + { + "role": "system", + "message": "You are a bot that gives really short replies" + }, + { + "role": "user", + "message": "Tell me a joke" + } + ], + "n": 2, + "maxTokens": 30, + "temperature": 1.2 + } +} +``` + +The data parameters are: + +- `messages` - array of messages that will be used to generate chat completions. +Each message is of the form: + - `role` - string that specifies the role of the message. Can be either `user`, `system` or `assistant`. + - `message` - string that specifies the conversation message for the role. +- `maxTokens` - (optional) defines the max number of tokens to generate. Defaults to 16 for the chat completion API. +- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Defaults to 1.0 for the chat completion API. +- `topP` - (optional) defines the sampling temperature. Defaults to 1.0 for the chat completion API. +- `n` - (optional) defines the number of completions to generate. Defaults to 1 for the chat completion API. +- `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for the chat completion API. +- `frequencyPenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.0 for the chat completion API. + +#### Example + +{{< tabs Linux >}} + + {{% codetab %}} + ```bash +curl -d '{ + "data": { + "messages": [ + { + "role": "system", + "message": "You are a bot that gives really short replies" + }, + { + "role": "user", + "message": "Tell me a joke" + } + ], + "n": 2, + "maxTokens": 30, + "temperature": 1.2 + }, + "operation": "chat-completion" +}' \ +http://localhost:/v1.0/bindings/ + ``` + {{% /codetab %}} + +{{< /tabs >}} + +#### Response + +The response body will contain the following JSON: + +```json +[ + { + "finish_reason": "stop", + "index": 0, + "message": { + "content": "Why was the math book sad? Because it had too many problems.", + "role": "assistant" + } + }, + { + "finish_reason": "stop", + "index": 1, + "message": { + "content": "Why did the tomato turn red? Because it saw the salad dressing!", + "role": "assistant" + } + } +] + +``` + + +## Related links + +- [Basic schema for a Dapr component]({{< ref component-schema >}}) +- [Bindings building block]({{< ref bindings >}}) +- [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}}) +- [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}}) +- [Bindings API reference]({{< ref bindings_api.md >}}) +- [Azure OpenAI Rest examples](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference) diff --git a/daprdocs/data/components/bindings/azure.yaml b/daprdocs/data/components/bindings/azure.yaml index b9ca1008e2f..7af5d118bca 100644 --- a/daprdocs/data/components/bindings/azure.yaml +++ b/daprdocs/data/components/bindings/azure.yaml @@ -62,3 +62,11 @@ features: input: true output: true +- component: Azure OpenAI + link: openai + state: Alpha + version: v1 + since: "1.12" + features: + input: false + output: true From f5c7f8b782f5fc4c82fcdd6fdff5536ce8b422f4 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Singh Date: Wed, 19 Jul 2023 04:07:02 +0000 Subject: [PATCH 2/9] Add documentation for Azure OpenAI output binding Signed-off-by: Shivam Kumar Singh Resolve comments Update daprdocs/content/en/reference/components-reference/supported-bindings/openai.md Co-authored-by: Mark Fussell Signed-off-by: Shivam Kumar Singh Update daprdocs/content/en/reference/components-reference/supported-bindings/openai.md Co-authored-by: Mark Fussell Signed-off-by: Shivam Kumar Singh Resolve comments Signed-off-by: Shivam Kumar Singh --- .../supported-bindings/openai.md | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md index 85ae37a5352..0483f7dfe20 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md @@ -9,8 +9,8 @@ aliases: ## Component format -To setup OpenAI binding create a component of type `bindings.azure.openai`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration. -See [this](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/overview/) for the documentation for Azure OpenAI Service. +To setup an Azure OpenAI binding create a component of type `bindings.azure.openai`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration. +See [this](https://learn.microsoft.com/azure/cognitive-services/openai/overview/) for the documentation for Azure OpenAI Service. ```yaml @@ -22,7 +22,7 @@ spec: type: bindings.azure.openai version: v1 metadata: - - name: apiKey + - name: apiKey # Required value: "1234567890abcdef" - name: endpoint # Required value: "https://myopenai.openai.azure.com" @@ -30,16 +30,19 @@ spec: value: "my-model" ``` {{% alert title="Warning" color="warning" %}} -The above example uses apiKey as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). +The above example uses `apiKey` as a plain string. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}} ## Spec metadata fields | Field | Required | Binding support | Details | Example | |--------------------|:--------:|--------|---------|---------| -| `endpoint` | Y | Input/Output | Azure OpenAI service endpoint URL. | `"https://myopenai.openai.azure.com"` | -| `apiKey` | Y* | Input/Output | The access key of the Azure OpenAI service. Only required when not using Azure AD authentication. | `"1234567890abcdef"` | +| `endpoint` | Y | Output | Azure OpenAI service endpoint URL. | `"https://myopenai.openai.azure.com"` | +| `apiKey` | Y* | Output | The access key of the Azure OpenAI service. Only required when not using Azure AD authentication. | `"1234567890abcdef"` | | `deploymentId` | Y | Output | The name of the model deployment. | `"my-model"` | +| `azureTenantId` | Y* | Input | The tenant ID of the Azure OpenAI resource. Only required when `apiKey` is not provided. | `"tenentID"` | +| `azureClientId` | Y* | Input | The client ID that should be used by the binding to create or update the Azure OpenAI Subscription and to authenticate incoming messages. Only required when `apiKey` is not provided.| `"clientId"` | +| `azureClientSecret` | Y* | Input | The client secret that should be used by the binding to create or update the Azure OpenAI Subscription and to authenticate incoming messages. Only required when `apiKey` is not provided. | `"clientSecret"` | ### Azure Active Directory (AAD) authentication @@ -92,7 +95,7 @@ The data parameters are: - `prompt` - string that specifies the prompt to generate completions for. - `maxTokens` - (optional) defines the max number of tokens to generate. Defaults to 16 for completion API. -- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Defaults to 1.0 for completion API. +- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 make the output more random, while lower values like 0.2 make it more focused and deterministic. Defaults to 1.0 for completion API. - `topP` - (optional) defines the sampling temperature. Defaults to 1.0 for completion API. - `n` - (optional) defines the number of completions to generate. Defaults to 1 for completion API. - `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for completion API. @@ -113,7 +116,7 @@ Read more about the importance and usage of these parameters in the [Azure OpenA #### Response -The response body will contain the following JSON: +The response body contains the following JSON: ```json [ @@ -163,7 +166,7 @@ Each message is of the form: - `role` - string that specifies the role of the message. Can be either `user`, `system` or `assistant`. - `message` - string that specifies the conversation message for the role. - `maxTokens` - (optional) defines the max number of tokens to generate. Defaults to 16 for the chat completion API. -- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Defaults to 1.0 for the chat completion API. +- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 make the output more random, while lower values like 0.2 make it more focused and deterministic. Defaults to 1.0 for the chat completion API. - `topP` - (optional) defines the sampling temperature. Defaults to 1.0 for the chat completion API. - `n` - (optional) defines the number of completions to generate. Defaults to 1 for the chat completion API. - `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for the chat completion API. @@ -201,7 +204,7 @@ http://localhost:/v1.0/bindings/ #### Response -The response body will contain the following JSON: +The response body contains the following JSON: ```json [ @@ -233,4 +236,4 @@ The response body will contain the following JSON: - [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}}) - [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}}) - [Bindings API reference]({{< ref bindings_api.md >}}) -- [Azure OpenAI Rest examples](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference) +- [Azure OpenAI Rest examples](https://learn.microsoft.com/azure/cognitive-services/openai/reference) From 07a04b0385f3e03c8bcf4405ae05392f93c57502 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:53:28 -0400 Subject: [PATCH 3/9] [bindings] Update `decodeBase64` to input (#3619) * update decodeBase64 value to input Signed-off-by: Hannah Hunter * typo Signed-off-by: Hannah Hunter --------- Signed-off-by: Hannah Hunter Co-authored-by: Mark Fussell --- .../components-reference/supported-bindings/storagequeues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md b/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md index e3296660123..41fe68c0447 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md @@ -54,7 +54,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr | `queueName` | Y | Input/Output | The name of the Azure Storage queue | `"myqueue"` | | `pollingInterval` | N | Output | Set the interval to poll Azure Storage Queues for new messages, as a Go duration value. Default: `"10s"` | `"30s"` | | `ttlInSeconds` | N | Output | Parameter to set the default message time to live. If this parameter is omitted, messages will expire after 10 minutes. See [also](#specifying-a-ttl-per-message) | `"60"` | -| `decodeBase64` | N | Output | Configuration to decode base64 file content before saving to Storage Queues. (In case of saving a file with binary content). Defaults to `false` | `true`, `false` | +| `decodeBase64` | N | Input | Configuration to decode base64 content received from the Storage Queue into a string. Defaults to `false` | `true`, `false` | | `encodeBase64` | N | Output | If enabled base64 encodes the data payload before uploading to Azure storage queues. Default `false`. | `true`, `false` | | `endpoint` | N | Input/Output | Optional custom endpoint URL. This is useful when using the [Azurite emulator](https://github.com/Azure/azurite) or when using custom domains for Azure Storage (although this is not officially supported). The endpoint must be the full base URL, including the protocol (`http://` or `https://`), the IP or FQDN, and optional port. | `"http://127.0.0.1:10001"` or `"https://accountName.queue.example.com"` | | `visibilityTimeout` | N | Input | Allows setting a custom queue visibility timeout to avoid immediate retrying of recently failed messages. Defaults to 30 seconds. | "100s" | From f75fcb09c1dd2bd1d642140fe6bb882da0e6ab61 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Singh Date: Mon, 24 Jul 2023 17:14:55 +0000 Subject: [PATCH 4/9] Update links --- .../components-reference/supported-bindings/openai.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md index 0483f7dfe20..ad025a755fe 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md @@ -101,7 +101,7 @@ The data parameters are: - `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for completion API. - `frequencyPenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.0 for completion API. -Read more about the importance and usage of these parameters in the [Azure OpenAI API documentation](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference). +Read more about the importance and usage of these parameters in the [Azure OpenAI API documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference). #### Examples {{< tabs Linux >}} @@ -236,4 +236,4 @@ The response body contains the following JSON: - [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}}) - [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}}) - [Bindings API reference]({{< ref bindings_api.md >}}) -- [Azure OpenAI Rest examples](https://learn.microsoft.com/azure/cognitive-services/openai/reference) +- [Azure OpenAI Rest examples](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) From 50a7e84fbcca58c9cca5f8f9a86bbb5ab5fb8390 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Mon, 24 Jul 2023 13:32:54 -0400 Subject: [PATCH 5/9] Update daprdocs/content/en/reference/components-reference/supported-bindings/openai.md Signed-off-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> --- .../reference/components-reference/supported-bindings/openai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md index ad025a755fe..39e63d07c99 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md @@ -236,4 +236,4 @@ The response body contains the following JSON: - [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}}) - [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}}) - [Bindings API reference]({{< ref bindings_api.md >}}) -- [Azure OpenAI Rest examples](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) +- [Azure OpenAI Rest examples](https://learn.microsoft.com/azure/ai-services/openai/reference) From 912cb27e96b0df5987872bcbb683a1086c503b0d Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Mon, 24 Jul 2023 13:33:03 -0400 Subject: [PATCH 6/9] Update daprdocs/content/en/reference/components-reference/supported-bindings/openai.md Signed-off-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> --- .../reference/components-reference/supported-bindings/openai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md index 39e63d07c99..08dd948fe91 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md @@ -101,7 +101,7 @@ The data parameters are: - `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for completion API. - `frequencyPenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.0 for completion API. -Read more about the importance and usage of these parameters in the [Azure OpenAI API documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference). +Read more about the importance and usage of these parameters in the [Azure OpenAI API documentation](https://learn.microsoft.com/azure/ai-services/openai/reference). #### Examples {{< tabs Linux >}} From 5f5ed758ca4efd9aa7610b85dfad2573ffbc682b Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Mon, 24 Jul 2023 15:00:13 -0400 Subject: [PATCH 7/9] remove azure openai docs from 1.11 Signed-off-by: Hannah Hunter --- .../supported-bindings/openai.md | 239 ------------------ daprdocs/data/components/bindings/azure.yaml | 10 +- 2 files changed, 1 insertion(+), 248 deletions(-) delete mode 100644 daprdocs/content/en/reference/components-reference/supported-bindings/openai.md diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md b/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md deleted file mode 100644 index 08dd948fe91..00000000000 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/openai.md +++ /dev/null @@ -1,239 +0,0 @@ ---- -type: docs -title: "Azure OpenAI binding spec" -linkTitle: "Azure OpenAI" -description: "Detailed documentation on the Azure OpenAI binding component" -aliases: - - "/operations/components/setup-bindings/supported-bindings/openai/" ---- - -## Component format - -To setup an Azure OpenAI binding create a component of type `bindings.azure.openai`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration. -See [this](https://learn.microsoft.com/azure/cognitive-services/openai/overview/) for the documentation for Azure OpenAI Service. - - -```yaml -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: -spec: - type: bindings.azure.openai - version: v1 - metadata: - - name: apiKey # Required - value: "1234567890abcdef" - - name: endpoint # Required - value: "https://myopenai.openai.azure.com" - - name: deploymentId # Required - value: "my-model" -``` -{{% alert title="Warning" color="warning" %}} -The above example uses `apiKey` as a plain string. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). -{{% /alert %}} - -## Spec metadata fields - -| Field | Required | Binding support | Details | Example | -|--------------------|:--------:|--------|---------|---------| -| `endpoint` | Y | Output | Azure OpenAI service endpoint URL. | `"https://myopenai.openai.azure.com"` | -| `apiKey` | Y* | Output | The access key of the Azure OpenAI service. Only required when not using Azure AD authentication. | `"1234567890abcdef"` | -| `deploymentId` | Y | Output | The name of the model deployment. | `"my-model"` | -| `azureTenantId` | Y* | Input | The tenant ID of the Azure OpenAI resource. Only required when `apiKey` is not provided. | `"tenentID"` | -| `azureClientId` | Y* | Input | The client ID that should be used by the binding to create or update the Azure OpenAI Subscription and to authenticate incoming messages. Only required when `apiKey` is not provided.| `"clientId"` | -| `azureClientSecret` | Y* | Input | The client secret that should be used by the binding to create or update the Azure OpenAI Subscription and to authenticate incoming messages. Only required when `apiKey` is not provided. | `"clientSecret"` | - -### Azure Active Directory (AAD) authentication - -The Azure OpenAI binding component supports authentication using all Azure Active Directory mechanisms. For further information and the relevant component metadata fields to provide depending on the choice of AAD authentication mechanism, see the [docs for authenticating to Azure]({{< ref authenticating-azure.md >}}). - -#### Example Configuration - -```yaml -apiVersion: dapr.io/v1alpha1 -kind: component -metadata: - name: -spec: - type: bindings.azure.openai - version: v1 - metadata: - - name: endpoint - value: "https://myopenai.openai.azure.com" - - name: deploymentId - value: "my-model" - - name: azureTenantId - value: "***" - - name: azureClientId - value: "***" - - name: azureClientSecret - value: "***" -``` -## Binding support - -This component supports **output binding** with the following operations: - -- `completion` : [Completion API](#completion-api) -- `chat-completion` : [Chat Completion API](#chat-completion-api) - -### Completion API - -To call the completion API with a prompt, invoke the Azure OpenAI binding with a `POST` method and the following JSON body: - -```json -{ - "operation": "create", - "data": { - "prompt": "A dog is", - "maxTokens":5 - } -} -``` - -The data parameters are: - -- `prompt` - string that specifies the prompt to generate completions for. -- `maxTokens` - (optional) defines the max number of tokens to generate. Defaults to 16 for completion API. -- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 make the output more random, while lower values like 0.2 make it more focused and deterministic. Defaults to 1.0 for completion API. -- `topP` - (optional) defines the sampling temperature. Defaults to 1.0 for completion API. -- `n` - (optional) defines the number of completions to generate. Defaults to 1 for completion API. -- `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for completion API. -- `frequencyPenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.0 for completion API. - -Read more about the importance and usage of these parameters in the [Azure OpenAI API documentation](https://learn.microsoft.com/azure/ai-services/openai/reference). -#### Examples - -{{< tabs Linux >}} - {{% codetab %}} - ```bash - curl -d '{ "data": {"prompt": "A dog is ", "maxTokens":15}, "operation": "completion" }' \ - http://localhost:/v1.0/bindings/ - ``` - {{% /codetab %}} - -{{< /tabs >}} - -#### Response - -The response body contains the following JSON: - -```json -[ - { - "finish_reason": "length", - "index": 0, - "text": " a pig in a dress.\n\nSun, Oct 20, 2013" - }, - { - "finish_reason": "length", - "index": 1, - "text": " the only thing on earth that loves you\n\nmore than he loves himself.\"\n\n" - } -] - -``` - -### Chat Completion API - -To perform a chat-completion operation, invoke the Azure OpenAI binding with a `POST` method and the following JSON body: - -```json -{ - "operation": "chat-completion", - "data": { - "messages": [ - { - "role": "system", - "message": "You are a bot that gives really short replies" - }, - { - "role": "user", - "message": "Tell me a joke" - } - ], - "n": 2, - "maxTokens": 30, - "temperature": 1.2 - } -} -``` - -The data parameters are: - -- `messages` - array of messages that will be used to generate chat completions. -Each message is of the form: - - `role` - string that specifies the role of the message. Can be either `user`, `system` or `assistant`. - - `message` - string that specifies the conversation message for the role. -- `maxTokens` - (optional) defines the max number of tokens to generate. Defaults to 16 for the chat completion API. -- `temperature` - (optional) defines the sampling temperature between 0 and 2. Higher values like 0.8 make the output more random, while lower values like 0.2 make it more focused and deterministic. Defaults to 1.0 for the chat completion API. -- `topP` - (optional) defines the sampling temperature. Defaults to 1.0 for the chat completion API. -- `n` - (optional) defines the number of completions to generate. Defaults to 1 for the chat completion API. -- `presencePenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.0 for the chat completion API. -- `frequencyPenalty` - (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.0 for the chat completion API. - -#### Example - -{{< tabs Linux >}} - - {{% codetab %}} - ```bash -curl -d '{ - "data": { - "messages": [ - { - "role": "system", - "message": "You are a bot that gives really short replies" - }, - { - "role": "user", - "message": "Tell me a joke" - } - ], - "n": 2, - "maxTokens": 30, - "temperature": 1.2 - }, - "operation": "chat-completion" -}' \ -http://localhost:/v1.0/bindings/ - ``` - {{% /codetab %}} - -{{< /tabs >}} - -#### Response - -The response body contains the following JSON: - -```json -[ - { - "finish_reason": "stop", - "index": 0, - "message": { - "content": "Why was the math book sad? Because it had too many problems.", - "role": "assistant" - } - }, - { - "finish_reason": "stop", - "index": 1, - "message": { - "content": "Why did the tomato turn red? Because it saw the salad dressing!", - "role": "assistant" - } - } -] - -``` - - -## Related links - -- [Basic schema for a Dapr component]({{< ref component-schema >}}) -- [Bindings building block]({{< ref bindings >}}) -- [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}}) -- [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}}) -- [Bindings API reference]({{< ref bindings_api.md >}}) -- [Azure OpenAI Rest examples](https://learn.microsoft.com/azure/ai-services/openai/reference) diff --git a/daprdocs/data/components/bindings/azure.yaml b/daprdocs/data/components/bindings/azure.yaml index 7af5d118bca..54d89da3ef1 100644 --- a/daprdocs/data/components/bindings/azure.yaml +++ b/daprdocs/data/components/bindings/azure.yaml @@ -61,12 +61,4 @@ since: "1.0" features: input: true - output: true -- component: Azure OpenAI - link: openai - state: Alpha - version: v1 - since: "1.12" - features: - input: false - output: true + output: true \ No newline at end of file From 54aa16942466bdb3ce9d6f5c9da10ecfcd62fc76 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Tue, 25 Jul 2023 13:14:16 -0400 Subject: [PATCH 8/9] update to 1.11.2 (#3633) Signed-off-by: Hannah Hunter --- .../content/en/operations/support/support-release-policy.md | 5 +++-- daprdocs/layouts/shortcodes/dapr-latest-version.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/daprdocs/content/en/operations/support/support-release-policy.md b/daprdocs/content/en/operations/support/support-release-policy.md index 704c58fe30a..ba433190b66 100644 --- a/daprdocs/content/en/operations/support/support-release-policy.md +++ b/daprdocs/content/en/operations/support/support-release-policy.md @@ -45,11 +45,12 @@ The table below shows the versions of Dapr releases that have been tested togeth | Release date | Runtime | CLI | SDKs | Dashboard | Status | |--------------------|:--------:|:--------|---------|---------|---------| +| July 20th 2023 | 1.11.2
| 1.11.0 | Java 1.9.0
Go 1.8.0
PHP 1.1.0
Python 1.10.0
.NET 1.11.0
JS 3.1.0 | 0.13.0 | Supported (current) | | June 22nd 2023 | 1.11.1
| 1.11.0 | Java 1.9.0
Go 1.8.0
PHP 1.1.0
Python 1.10.0
.NET 1.11.0
JS 3.1.0 | 0.13.0 | Supported (current) | | June 12th 2023 | 1.11.0
| 1.11.0 | Java 1.9.0
Go 1.8.0
PHP 1.1.0
Python 1.10.0
.NET 1.11.0
JS 3.1.0 | 0.13.0 | Supported (current) | | May 15th 2023 | 1.10.7
| 1.10.0 | Java 1.8.0
Go 1.7.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 3.0.0 | 0.11.0 | Supported | | May 12th 2023 | 1.10.6
| 1.10.0 | Java 1.8.0
Go 1.7.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 3.0.0 | 0.11.0 | Supported | -| April 13 2023 |1.10.5
| 1.10.0 | Java 1.8.0
Go 1.6.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 3.0.0 | 0.11.0 | Supported (current) | +| April 13 2023 |1.10.5
| 1.10.0 | Java 1.8.0
Go 1.6.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 3.0.0 | 0.11.0 | Supported | | March 16 2023 | 1.10.4
| 1.10.0 | Java 1.8.0
Go 1.6.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 2.5.0 | 0.11.0 | Supported | | March 14 2023 | 1.10.3
| 1.10.0 | Java 1.8.0
Go 1.6.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 2.5.0 | 0.11.0 | Supported | | February 24 2023 | 1.10.2
| 1.10.0 | Java 1.8.0
Go 1.6.0
PHP 1.1.0
Python 1.9.0
.NET 1.10.0
JS 2.5.0 | 0.11.0 | Supported | @@ -118,7 +119,7 @@ General guidance on upgrading can be found for [self hosted mode]({{< ref self-h | 1.8.0 to 1.8.6 | N/A | 1.9.6 | | 1.9.0 | N/A | 1.9.6 | | 1.10.0 | N/A | 1.10.8 | -| 1.11.0 | N/A | 1.11.1 | +| 1.11.0 | N/A | 1.11.2 | ## Upgrade on Hosting platforms diff --git a/daprdocs/layouts/shortcodes/dapr-latest-version.html b/daprdocs/layouts/shortcodes/dapr-latest-version.html index 41d35c1517f..a205d616a55 100644 --- a/daprdocs/layouts/shortcodes/dapr-latest-version.html +++ b/daprdocs/layouts/shortcodes/dapr-latest-version.html @@ -1 +1 @@ -{{- if .Get "short" }}1.11{{ else if .Get "long" }}1.11.1{{ else if .Get "cli" }}1.11.0{{ else }}1.11.1{{ end -}} +{{- if .Get "short" }}1.11{{ else if .Get "long" }}1.11.2{{ else if .Get "cli" }}1.11.0{{ else }}1.11.2{{ end -}} From 5816f3c1903d77dd651d7c8b4b3027061d3b04f3 Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Tue, 25 Jul 2023 15:26:26 -0700 Subject: [PATCH 9/9] Update resiliency-schema.md (#3637) Signed-off-by: Yaron Schneider --- .../en/reference/resource-specs/resiliency-schema.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daprdocs/content/en/reference/resource-specs/resiliency-schema.md b/daprdocs/content/en/reference/resource-specs/resiliency-schema.md index d62061e091d..32888adc753 100644 --- a/daprdocs/content/en/reference/resource-specs/resiliency-schema.md +++ b/daprdocs/content/en/reference/resource-specs/resiliency-schema.md @@ -20,8 +20,8 @@ scopes: - spec: policies: # Required - timeouts: # Replace with any unique name - timeoutName: + timeouts: + timeoutName: # Replace with any unique name retries: retryName: # Replace with any unique name policy: @@ -62,4 +62,4 @@ targets: # Required ## Related links -[Learn more about resiliency policies and targets]({{< ref resiliency-overview.md >}}) \ No newline at end of file +[Learn more about resiliency policies and targets]({{< ref resiliency-overview.md >}})