title | description | ms.topic | ms.custom | ms.collection | ms.date | zone_pivot_groups | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Azure OpenAI assistant query input binding for Azure Functions | Learn how to use the Azure OpenAI assistant query input binding to access Azure OpenAI Assistants APIs during function execution in Azure Functions. | reference |
|
| 01/07/2025 | programming-languages-set-functions |
[!INCLUDE preview-support]
The Azure OpenAI assistant query input binding allows you to integrate Assistants API queries into your code executions.
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 the creation process, where the HTTP GET function that queries the conversation history of the assistant chat bot. The response to the prompt is returned in the HTTP response.
:::code language="csharp" source="~/functions-openai-extension/samples/assistant/csharp-ooproc/AssistantApis.cs" range="74-83":::
::: zone-end
::: zone pivot="programming-language-java"
This example demonstrates the creation process, where the HTTP GET function that queries the conversation history of the assistant chat bot. The response to the prompt is returned in the HTTP response.
:::code language="java" source="~/functions-openai-extension/samples/assistant/java/src/main/java/com/azfs/AssistantApis.java" range="63-78":::
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript" This example demonstrates the creation process, where the HTTP GET function that queries the conversation history of the assistant chat bot. The response to the prompt is returned in the HTTP response. ::: zone-end
::: zone pivot="programming-language-javascript"
:::code language="javascript" source="~/functions-openai-extension/samples/assistant/javascript/src/functions/assistantApis.js" range="6-7,63-79":::
::: zone-end
::: zone pivot="programming-language-typescript"
This example demonstrates the creation process, where the HTTP GET function that queries the conversation history of the assistant chat bot. The response to the prompt is returned in the HTTP response.
:::code language="typescript" source="~/functions-openai-extension/samples/assistant/typescript/src/functions/assistantApis.ts" range="6-7,63-79":::
::: zone-end
::: zone pivot="programming-language-powershell"
This example demonstrates the creation process, where the HTTP GET function that queries the conversation history of the assistant chat bot. The response to the prompt is returned in the HTTP response.
Here's the function.json file for Get Chat State:
:::code language="json" source="~/functions-openai-extension/samples/assistant/powershell/GetChatState/function.json" :::
For more information about function.json file properties, see the Configuration section.
:::code language="powershell" source="~/functions-openai-extension/samples/assistant/powershell/GetChatState/run.ps1" :::
::: zone-end
::: zone pivot="programming-language-python"
This example demonstrates the creation process, where the HTTP GET function that queries the conversation history of the assistant chat bot. The response to the prompt is returned in the HTTP response.
:::code language="python" source="~/functions-openai-extension/samples/assistant/python/assistant_apis.py" range="37-41":::
::: zone-end
::: zone pivot="programming-language-csharp"
Apply the AssistantQuery
attribute to define an assistant query input binding, which supports these parameters:
Parameter | Description |
---|---|
Id | Gets the ID of the assistant to query. |
TimeStampUtc | Optional. Gets or sets the timestamp of the earliest message in the chat history to fetch. The timestamp should be in ISO 8601 format - for example, 2023-08-01T00:00:00Z. |
::: zone-end ::: zone pivot="programming-language-java"
The assistantQuery
annotation enables you to define an assistant query input binding, which supports these parameters:
Element | Description |
---|---|
name | Gets or sets the name of the input binding. |
id | Gets the ID of the assistant to query. |
timeStampUtc | Optional. Gets or sets the timestamp of the earliest message in the chat history to fetch. The timestamp should be in ISO 8601 format - for example, 2023-08-01T00:00:00Z. |
::: zone-end
::: zone pivot="programming-language-python"
During the preview, define the input binding as a generic_input_binding
binding of type assistantQuery
, which supports these parameters:
Parameter | Description |
---|---|
arg_name | The name of the variable that represents the binding parameter. |
id | Gets the ID of the assistant to query. |
time_stamp_utc | Optional. Gets or sets the timestamp of the earliest message in the chat history to fetch. The timestamp should be in ISO 8601 format - for example, 2023-08-01T00:00:00Z. |
::: 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 assistantQuery . |
direction | Must be in . |
name | The name of the input binding. |
id | Gets the ID of the assistant to query. |
timeStampUtc | Optional. Gets or sets the timestamp of the earliest message in the chat history to fetch. The timestamp should be in ISO 8601 format - for example, 2023-08-01T00:00:00Z. |
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript"
The binding supports these properties, which are defined in your code:
Property | Description |
---|---|
id | Gets the ID of the assistant to query. |
timeStampUtc | Optional. Gets or sets the timestamp of the earliest message in the chat history to fetch. The timestamp should be in ISO 8601 format - for example, 2023-08-01T00:00:00Z. |
::: zone-end
See the Example section for complete examples.