Skip to content

Latest commit

 

History

History
167 lines (127 loc) · 9.36 KB

functions-bindings-openai-embeddingsstore-output.md

File metadata and controls

167 lines (127 loc) · 9.36 KB
titledescriptionms.topicms.customms.collectionms.datezone_pivot_groups
Azure OpenAI embeddings store output binding for Azure Functions
Learn how to use the Azure OpenAI embeddings store output binding to write searchable content to a semantic document store during function execution in Azure Functions.
reference
build-2024
devx-track-extended-java
devx-track-js
devx-track-python
devx-track-ts
ce-skilling-ai-copilot
01/07/2025
programming-languages-set-functions

Azure OpenAI embeddings store output binding for Azure Functions

[!INCLUDE preview-support]

The Azure OpenAI embeddings store output binding allows you to write files to a semantic document store that can be referenced later in a semantic search.

For information on setup and configuration details of the Azure OpenAI extension, see Azure OpenAI extensions for Azure Functions. To learn more about semantic ranking in Azure AI Search, see Semantic ranking in Azure AI Search.

[!INCLUDE functions-support-notes-samples-openai]

Example

::: zone pivot="programming-language-csharp"
This example writes an HTTP input stream to a semantic document store at the provided URL.

:::code language="csharp" source="~/functions-openai-extension/samples/rag-aisearch/csharp-ooproc/FilePrompt.cs" range="29-70":::

::: zone-end
::: zone pivot="programming-language-java" This example writes an HTTP input stream to a semantic document store at the provided URL.

:::code language="java" source="~/functions-openai-extension/samples/rag-aisearch/java/src/main/java/com/azfs/FilePrompt.java" range="24-68":::

::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript" This example writes an HTTP input stream to a semantic document store at the provided URL. ::: zone-end
::: zone pivot="programming-language-javascript"

:::code language="javascript" source="~/functions-openai-extension/samples/rag-aisearch/javascript/src/app.js" range="5-37":::

::: zone-end
::: zone pivot="programming-language-typescript"

:::code language="typescript" source="~/functions-openai-extension/samples/rag-aisearch/typescript/src/app.ts" range="4-40":::

::: zone-end
::: zone pivot="programming-language-powershell"
This example writes an HTTP input stream to a semantic document store at the provided URL.

Here's the function.json file for ingesting files:

:::code language="json" source="~/functions-openai-extension/samples/rag-aisearch/powershell/IngestFile/function.json" :::

For more information about function.json file properties, see the Configuration section.

:::code language="powershell" source="~/functions-openai-extension/samples/rag-aisearch/powershell/IngestFile/run.ps1" :::

::: zone-end
::: zone pivot="programming-language-python"
This example writes an HTTP input stream to a semantic document store at the provided URL.

:::code language="python" source="~/functions-openai-extension/samples/rag-aisearch/python/function_app.py" range="8-25":::

::: zone-end

::: zone pivot="programming-language-csharp"

Attributes

Apply the EmbeddingsStoreOutput attribute to define an embeddings store output binding, which supports these parameters:

ParameterDescription
InputThe input string for which to generate embeddings.
ModelOptional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage.
MaxChunkLengthOptional. The maximum number of characters used for chunking the input. For more information, see Usage.
MaxOverlapOptional. Gets or sets the maximum number of characters to overlap between chunks.
InputTypeOptional. Gets the type of the input.
ConnectionNameThe name of an app setting or environment variable that contains the connection string value. This property supports binding expressions.
CollectionThe name of the collection or table or index to search. This property supports binding expressions.

::: zone-end ::: zone pivot="programming-language-java"

Annotations

The EmbeddingsStoreOutput annotation enables you to define an embeddings store output binding, which supports these parameters:

ElementDescription
nameGets or sets the name of the output binding.
inputThe input string for which to generate embeddings.
modelOptional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage.
maxChunkLengthOptional. The maximum number of characters used for chunking the input. For more information, see Usage.
maxOverlapOptional. Gets or sets the maximum number of characters to overlap between chunks.
inputTypeOptional. Gets the type of the input.
connectionNameThe name of an app setting or environment variable that contains the connection string value. This property supports binding expressions.
collectionThe name of the collection or table or index to search. This property supports binding expressions.

::: zone-end
::: zone pivot="programming-language-python"

Decorators

During the preview, define the output binding as a generic_output_binding binding of type semanticSearch, which supports these parameters:

ParameterDescription
arg_nameThe name of the variable that represents the binding parameter.
inputThe input string for which to generate embeddings.
modelOptional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage.
maxChunkLengthOptional. The maximum number of characters used for chunking the input. For more information, see Usage.
max_overlapOptional. Gets or sets the maximum number of characters to overlap between chunks.
input_typeGets the type of the input.
connection_nameThe name of an app setting or environment variable that contains the connection string value. This property supports binding expressions.
collectionThe name of the collection or table or index to search. This property supports binding expressions.

::: zone-end ::: zone pivot="programming-language-powershell"

Configuration

The binding supports these configuration properties that you set in the function.json file.

PropertyDescription
typeMust be embeddingsStore.
directionMust be out.
nameThe name of the output binding.
inputThe input string for which to generate embeddings.
modelOptional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage.
maxChunkLengthOptional. The maximum number of characters used for chunking the input. For more information, see Usage.
maxOverlapOptional. Gets or sets the maximum number of characters to overlap between chunks.
inputTypeOptional. Gets the type of the input.
connectionNameThe name of an app setting or environment variable that contains the connection string value. This property supports binding expressions.
collectionThe name of the collection or table or index to search. This property supports binding expressions.

::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript"

Configuration

The binding supports these properties, which are defined in your code:

PropertyDescription
inputThe input string for which to generate embeddings.
modelOptional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage.
maxChunkLengthOptional. The maximum number of characters used for chunking the input. For more information, see Usage.
maxOverlapOptional. Gets or sets the maximum number of characters to overlap between chunks.
inputTypeOptional. Gets the type of the input.
connectionNameThe name of an app setting or environment variable that contains the connection string value. This property supports binding expressions.
collectionThe name of the collection or table or index to search. This property supports binding expressions.

::: zone-end

Usage

See the Example section for complete examples.

Related content

close