Search code examples
azureazure-openai

AzureOpenAIModelFactory StreamingChatCompletions throws System NullReferenceException


Calling the AzureOpenAIModelFactory.StreamingChatCompletions() method never works and always results in an immediate System.NullReferenceException.

This seems to be due to the internal constructor calling .Add() on a private field that hasn't been initialized at that point.

public class StreamingChatCompletions : IDisposable
{
    private readonly IList<ChatCompletions> _baseChatCompletions;

    //...
        
    internal StreamingChatCompletions(
            ChatCompletions baseChatCompletions = null,
            List<StreamingChatChoice> streamingChatChoices = null)
    {
        _baseChatCompletions.Add(baseChatCompletions);
        _streamingChatChoices = streamingChatChoices;
        _streamingTaskComplete = true;
    }
}

Solution

  • AzureOpenAIModelFactory class seems to use the one that does not initialize the variable that is causing the nullreference. I have raised the backlog item to check on this.