Azure-Samples / gen-ai-bot-in-a-box

This template deploys a Generative AI Virtual Assistant using Azure OpenAI and Bot Framework.
MIT License
14 stars 6 forks source link

400 Bad Request Errors When Using Cognitive Search (AzureSearchChatData) #15

Open scotwoodyard-csulb opened 7 hours ago

scotwoodyard-csulb commented 7 hours ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ x] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Configure AzureSearchChatData source. Ask a question that returns information from a search. Ask a follow up question,

Any log messages given by the failure

The error message is "Status: 400 (Bad Request)". I have attached a transcript file with more details.

Expected/desired behavior

The follow up question would return chat completion results.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful

The previous iteration of the project works as expected.


Thanks! We'll be in touch soon. transcripts.txt

scotwoodyard-csulb commented 6 hours ago

Here is a code snippet from Startup.cs:

            if (configuration.GetValue("AZURE_SEARCH_API_ENDPOINT", "") != "")
            {
                services.AddSingleton(new AzureSearchChatDataSource()
                {
                    Endpoint = new Uri(configuration.GetValue<string>("AZURE_SEARCH_API_ENDPOINT")),
                    IndexName = configuration.GetValue<string>("AZURE_SEARCH_INDEX"),
                    Authentication = DataSourceAuthentication.FromApiKey(configuration.GetValue<string>("AZURE_SEARCH_API_KEY")),
                });
            }

I am injecting that into SemanctiKernelBot.cs:

        private readonly string _instructions;
        private readonly string _welcomeMessage;
        private readonly string _endpoint;
        private readonly string _deployment;
        private readonly AzureSearchChatDataSource _chatDataSource;
        private readonly string _apiKey;
        private readonly CanvasApiClient _canvasDataService;

        public SemanticKernelBot(IConfiguration config, ConversationState conversationState, UserState userState, AzureOpenAIClient aoaiClient, AzureSearchChatDataSource chatDataSource, CanvasApiClient canvasDataService, T dialog)
            : base(config, conversationState, userState, dialog)
        {
            _instructions = config["LLM_INSTRUCTIONS"];
            _welcomeMessage = config.GetValue("LLM_WELCOME_MESSAGE", "Hello and welcome to the Semantic Kernel Bot Dotnet!");
            _endpoint = config["AZURE_OPENAI_API_ENDPOINT"];
            _deployment = config["AZURE_OPENAI_DEPLOYMENT_NAME"];
            _apiKey = config["AZURE_OPENAI_API_KEY"];
            _chatDataSource = chatDataSource;
            _canvasDataService = canvasDataService;
        }

I am configuring the chat completion options like so:

            // Define prompt execution settings
            var promptExecutionSettings = new AzureOpenAIPromptExecutionSettings()
            {
                AzureChatDataSource = _chatDataSource,
                ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions
            };

I've also noticed that plugins (i.e. the wikipedia plugin) are no longer responding.