question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request]: Support Azure OpenAI Service chat completion extensions

See original GitHub issue

Describe your user scenario

A key customer scenario will be to use AI to chat with their own data. Azure OpenAI Service supports bringing your own data from Azure Cognitive Search. The Azure OpenAI Service REST API has an endpoint for chat completion extensions. This extends the chat completion endpoint to enable developers to specify an Azure Cognitive Search data source as part of the request.

Describe the solution you’d like

Extend the config.json schema to include a new type called chat_extensions.

{
    "schema": 1,
    "description": "Chat with your SharePoint data",
    "type": "chat_extensions",
    "completion": {
        "max_tokens": 800,
        "temperature": 0.0,
        "top_p": 1.0,
        "presence_penalty": 0.0,
        "frequency_penalty": 0.0
    }
}

Extend AzureOpenAIPlanner with a new property for setting data sources.

const planner = new AzureOpenAIPlanner({
    apiKey: config.openAIKey,
    apiVersion: '2023-03-15-preview',
    dataSources: [
        {
            type: "AzureCognitiveSearch",
            parameters: {
                endpoint: config.azureCognitiveSearchEndpoint,
                key: config.azureCognitiveSearchKey,
                indexName: config.azureCognitiveSearchIndexName,
            }
        }
    ],
    defaultModel: 'gpt-msteams-spo-oai',
    endpoint: config.openAIEndpoint,
    logRequests: true,
    useSystemMessage: true
});

Requests should be made to the correct endpoint by the SDK.

POST https://{your-resource-name}/openai/deployments/{deployment-id}/extensions/chat/completions?api-version={api-version}

The datasources object should be passed in the body of the request along with the messages object.

{
    "dataSources": [
        {
            "type": "AzureCognitiveSearch",
            "parameters": {
                "endpoint": "https://{acs-resource-name}.search.windows.net",
                "key": "{acs-api-key}",
                "indexName": "{acs-index}"
            }
        }
    ],
    "messages": [
        {
            "role": "user",
            "content": "What are the differences between Azure Machine Learning and Azure AI services?"
        }
    ]
}

Describe alternatives you’ve considered

The alternative I have considered is to not use the AI capabilities of the SDK, but instead send my own requests and manage the conversation history myself. Here is an example of how I have done this in another sample: https://github.com/garrytrinder/msteams-azure-search-openai-demo

Additional context

Azure OpenAI Service REST API reference - Completions Extensions

Issue Analytics

  • State:open
  • Created 2 months ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
kevmcdonkcommented, Aug 13, 2023

Disappointed to see this on the Backburner. Having your own data is a key feature for some of our clients and frustrating to see this held back

1reaction
pkbullockcommented, Aug 16, 2023

I would love this feature, this is only going to get more popular to bring your own data as it dramatically improves the quality and relevance of responses. To be able to surface this within apps would be super powerful. I am working on a project that really could have used this feature.

@garrytrinder I noticed you don’t have a license set (or MIT) on your repo example, can I use the sample code? I think I am going to need to switch to raw calls like in that example, Id love to build on what yo have done already.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure OpenAI Service REST API reference
Learn how to use Azure OpenAI's REST API. In this article, you'll learn about authorization options, how to structure a request and receive ......
Read more >
What's new in Azure OpenAI Service?
Azure OpenAI now supports function calling to enable you to work with functions in the chat completions API. Embedding input array increase.
Read more >
Azure OpenAI Service – Advanced Language Models
Azure OpenAI Service offers industry-leading coding and language AI models that you can fine-tune to your specific needs for a variety of use...
Read more >
Get started using GPT-35-Turbo and GPT-4 with Azure ...
Walkthrough on how to get started with GPT-35-Turbo and GPT-4 on Azure OpenAI Service.
Read more >
Using your data with Azure OpenAI Service
Azure OpenAI on your data enables you to run supported chat models ... service, you can start using the chat completions extensions API....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found