vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
9.36k stars 1.37k forks source link

Add Azure Extensions to the Azure provider #2237

Open ajoublin opened 2 months ago

ajoublin commented 2 months ago

Feature Description

It would be a complete support of the Azure provider if we could plug Azure extensions such as Azure AI Search. It already exists in the Azure OpenAI SDK and it is called like that :

await openAIClient.getChatCompletions(process.env.AZURE_AI_DEPLOYMENT, messages, {
    maxTokens: process.env.AZURE_AI_MAX_TOKENS,
    azureExtensionOptions: {
        extensions: [
            {
                type: "azure_search",
                authentication: {
                    type: "api_key",
                    key: process.env.AZURE_AI_SEARCH_API_KEY,
                },
                endpoint: process.env.AZURE_AI_SEARCH_ENDPOINT,
                indexName: process.env.AZURE_AI_SEARCH_INDEX,
                queryType: "vector_semantic_hybrid",
                embeddingDependency: {
                    type: "deployment_name",
                    deploymentName: process.env.AZURE_AI_EMBEDDING_MODEL,
                },
                semanticConfiguration:
                    process.env.AZURE_AI_SEARCH_INDEX + "-semantic-configuration",
                roleInformation: "",
                strictness: process.env.AZURE_AI_STRICTNESS,
                topNDocuments: process.env.AZURE_AI_NB_RETRIEVE_DOCS,
            },
        ],
    },
});

Use Case

It is very useful when we want to use Azure RAG capabilities.

Additional context

No response

lgrammel commented 1 month ago

For reference: https://learn.microsoft.com/en-us/azure/ai-services/openai/references/on-your-data