Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[BUG] EnhancementOptions in AzureChatExtensionsOptions is always set to null #40826

Open shibayan opened 11 months ago

shibayan commented 11 months ago

Library name and version

Azure.AI.OpenAI 1.0.0-beta.12

Describe the bug

While EnhancementOptions is a get-only property, it is always null because it is not initialized in the constructor. As a result, a NullReferenceException is always thrown when accessing the property.

In the code below, we can see that Extensions are initialized while EnhancementOptions are not. Since EnhancementOptions is read-only, it cannot be set externally and there is no workaround.

https://github.com/Azure/azure-sdk-for-net/blob/806d914d1581def963ad055b8b5662938ec8dbd8/sdk/openai/Azure.AI.OpenAI/src/Custom/AzureChatExtensions/AzureChatExtensionsOptions.cs#L34-L40

Expected behavior

Properties of EnhancementOptions can be set correctly.

Actual behavior

The following NullReferenceException is always raised

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Reproduction Steps

var extensionOptions = new AzureChatExtensionsOptions
{
    EnhancementOptions =
    {
        Grounding = new AzureChatGroundingEnhancementConfiguration(true),
        Ocr = new AzureChatOCREnhancementConfiguration(true),
    }
};

Environment

No response

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.

miika-prose commented 9 months ago

I can confirm it. No way to replicate API:

{
    "enhancements": {
        "ocr": {
            "enabled": true
        },
        "grounding": {
            "enabled": true
        }
    },
    "messages": [],
    "temperature": 0.7,
    "top_p": 0.95,
    "max_tokens": 800
}

EDIT: Apply also to Azure.AI.OpenAI.1.0.0-beta.13