title | description | ms.topic | ms.custom | ms.collection | ms.date | zone_pivot_groups | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Azure OpenAI assistant trigger for Azure Functions |
Learn how to use the Azure OpenAI assistant trigger to execute code based on custom chat bots and skills in Azure Functions. |
reference |
|
|
05/24/2024 |
programming-languages-set-functions |
[!INCLUDE preview-support]
The Azure OpenAI assistant trigger lets you run your code based on custom chat bot or skill request made to an assistant.
For information on setup and configuration details of the Azure OpenAI extension, see Azure OpenAI extensions for Azure Functions. To learn more about Azure OpenAI assistants, see Azure OpenAI Assistants API.
[!INCLUDE functions-support-notes-samples-openai]
::: zone pivot="programming-language-csharp"
This example demonstrates how to create an assistant that adds a new todo task to a database. The trigger has a static description of Create a new todo task
used by the model. The function itself takes a string, which represents a new task to add. When executed, the function adds the task as a new todo item in a custom item store and returns a response from the store.
:::code language="csharp" source="~/functions-openai-extension/samples/assistant/csharp-ooproc/AssistantSkills.cs" range="31-43" :::
::: zone-end
::: zone pivot="programming-language-java"
This example demonstrates how to create an assistant that adds a new todo task to a database. The trigger has a static description of Create a new todo task
used by the model. The function itself takes a string, which represents a new task to add. When executed, the function adds the task as a new todo item in a custom item store and returns a response from the store.
:::code language="java" source="~/functions-openai-extension/samples/assistant/java/src/main/java/com/azfs/AssistantSkills.java" range="27-43":::
::: zone-end
::: zone pivot="programming-language-javascript"
[!INCLUDE functions-examples-not-available-note]
::: zone-end
::: zone pivot="programming-language-typescript"
This example demonstrates how to create an assistant that adds a new todo task to a database. The trigger has a static description of Create a new todo task
used by the model. The function itself takes a string, which represents a new task to add. When executed, the function adds the task as a new todo item in a custom item store and returns a response from the store.
:::code language="typescript" source="~/functions-openai-extension/samples/assistant/typescript/src/functions/assistantSkills.ts" range="9-24" :::
::: zone-end
::: zone pivot="programming-language-powershell"
This example demonstrates how to create an assistant that adds a new todo task to a database. The trigger has a static description of Create a new todo task
used by the model. The function itself takes a string, which represents a new task to add. When executed, the function adds the task as a new todo item in a custom item store and returns a response from the store.
Here's the function.json file for Add Todo:
:::code language="json" source="~/functions-openai-extension/samples/assistant/powershell/AddTodo/function.json" :::
For more information about function.json file properties, see the Configuration section.
:::code language="powershell" source="~/functions-openai-extension/samples/assistant/powershell/AddTodo/run.ps1" :::
::: zone-end
::: zone pivot="programming-language-python"
This example demonstrates how to create an assistant that adds a new todo task to a database. The trigger has a static description of Create a new todo task
used by the model. The function itself takes a string, which represents a new task to add. When executed, the function adds the task as a new todo item in a custom item store and returns a response from the store.
:::code language="python" source="~/functions-openai-extension/samples/assistant/python/assistant_skills.py" range="13-23" :::
::: zone-end
::: zone pivot="programming-language-csharp"
Apply the AssistantSkillTrigger
attribute to define an assistant trigger, which supports these parameters:
Parameter | Description |
---|---|
FunctionDescription | Gets the description of the assistant function, which is provided to the model. |
FunctionName | Optional. Gets or sets the name of the function called by the assistant. |
ParameterDescriptionJson | Optional. Gets or sets a JSON description of the function parameter, which is provided to the model. For more information, see Usage. |
Model | Optional. Gets or sets the OpenAI chat model deployment to use, with a default value of gpt-3.5-turbo . |
::: zone-end ::: zone pivot="programming-language-java"
The AssistantSkillTrigger
annotation enables you to define an assistant trigger, which supports these parameters:
Element | Description |
---|---|
name | Gets or sets the name of the input binding. |
functionDescription | Gets the description of the assistant function, which is provided to the model. |
functionName | Optional. Gets or sets the name of the function called by the assistant. |
parameterDescriptionJson | Optional. Gets or sets a JSON description of the function parameter, which is provided to the model. For more information, see Usage. |
model | Optional. Gets or sets the OpenAI chat model deployment to use, with a default value of gpt-3.5-turbo . |
::: zone-end
::: zone pivot="programming-language-python"
During the preview, define the input binding as a generic_trigger
binding of type assistantSkillTrigger
, which supports these parameters:
Parameter | Description |
---|---|
function_description | Gets the description of the assistant function, which is provided to the model. |
function_name | Optional. Gets or sets the name of a function called by the assistant. |
parameterDescriptionJson | Optional. Gets or sets a JSON description of the function parameter, which is provided to the model. For more information, see Usage. |
model | Optional. Gets or sets the OpenAI chat model deployment to use, with a default value of gpt-3.5-turbo . |
::: zone-end ::: zone pivot="programming-language-powershell"
The binding supports these configuration properties that you set in the function.json file.
Property | Description |
---|---|
type | Must be AssistantSkillTrigger . |
direction | Must be in . |
name | The name of the trigger. |
functionName | Gets or sets the name of the function called by the assistant. |
functionDescription | Gets the description of the assistant function, which is provided to the LLM |
parameterDescriptionJson | Optional. Gets or sets a JSON description of the function parameter, which is provided to the model. For more information, see Usage. |
model | Optional. Gets or sets the OpenAI chat model deployment to use, with a default value of gpt-3.5-turbo . |
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript"
The binding supports these properties, which are defined in your code:
Property | Description |
---|---|
type | Must be AssistantSkillTrigger . |
name | The name of the trigger. |
functionName | Gets or sets the name of the function called by the assistant. |
functionDescription | Gets the description of the assistant function, which is provided to the LLM |
parameterDescriptionJson | Optional. Gets or sets a JSON description of the function parameter, which is provided to the model. For more information, see Usage. |
model | Optional. Gets or sets the OpenAI chat model deployment to use, with a default value of gpt-3.5-turbo . |
::: zone-end
See the Example section for complete examples.
When parameterDescriptionJson
JSON value isn't provided, it's autogenerated. For more information on the syntax of this object, see the OpenAI API documentation.