microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.61k stars 3.2k forks source link

Python: Azure Open AI gpt-4o-mini - chat completions not working #8362

Closed jamesmkfoo23 closed 1 month ago

jamesmkfoo23 commented 1 month ago

I'm getting error invoking SK plugin when using gpt-4o-mini model.

llm_result = await self.kernel.invoke(
                plugin_name="plugin",
                function_name="func",
                description=current_description
            )

This is the error message: openai.BadRequestError: Error code: 400 - {'error': {'code': 'OperationNotSupported', 'message': 'The chatCompletion operation does not work with the specified model, gpt-4o-mini. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993.'}}

When will gpt-4o-mini be supported?

evchaki commented 1 month ago

@RogerBarreto can you take a look at this bug?

evchaki commented 1 month ago

@jamesmkfoo23 - thanks for sending this in.

RogerBarreto commented 1 month ago

@evchaki This seems to be an error happening from Azure API. (Azure or OpenAI)

@jamesmkfoo23 if you are targeting azure ensure the deployment is using the gpt-4o-mini model.

Attempting to use a different model than the deployed will give you the above error.

image

jamesmkfoo23 commented 1 month ago

@evchaki This seems to be an error happening from Azure API. (Azure or OpenAI)

@jamesmkfoo23 if you are targeting azure ensure the deployment is using the gpt-4o-mini model.

Attempting to use a different model than the deployed will give you the above error.

image

@RogerBarreto , yes I did deploy the gpt-4o-mini model

image

Added the LLM service to kernel as I do with my other gpt-4o model:

import semantic_kernel.connectors.ai.open_ai as sk_oai
gpt_4o_mini_llm_service = sk_oai.AzureChatCompletion(
            service_id="gpt-4o-mini",

            api_key= os.getenv("AZURE_OPENAI_API_KEY"),
            endpoint= os.getenv("AZURE_OPENAI_ENDPOINT"),
            deployment_name= os.getenv("AZURE_OPENAI_GPT4OMINI_DEPLOYMENT_NAME"), 
            api_version= os.getenv("AZURE_OPENAI_API_VERSION")

        )

        self.kernel.add_service(gpt_4o_mini_llm_service)

Perhaps it isn't a SK issue but I am wondering if AOAI chat completions is actually supported for the gpt-4o-mini model. Another observation I have is that the "Open in Playground" option is greyed out for this model

image
RogerBarreto commented 1 month ago

Potentially is not supported although the documentation says they do support. One observation I have is that your deployment doesn't have a traditional endpoint like ours is called Global-Batch, and something might be related to that as well.

image

Suggest making an REST HTTP request and sending that error into their Azure repository.

yashworlikar commented 1 month ago

Perhaps it isn't a SK issue but I am wondering if AOAI chat completions is actually supported for the gpt-4o-mini model. Another observation I have is that the "Open in Playground" option is greyed out for this model

@jamesmkfoo23 The "Global-batch" deployment type is based on OpenAI's Batch API which I don't think is supported by Semantic kernel.

You would need to create a deployment for gpt-4o-mini using Standard or the Global Standard deployment type for using it with chat completions

jamesmkfoo23 commented 1 month ago

Thanks @RogerBarreto , @yashworlikar. I managed to deploy Global Standard on US EAST and the chat completions on playground is working. Will try using SK tomorrow and it should work.

arnavjain commented 1 month ago

@jamesmkfoo23 were you able to run this on Global Batch? @evchaki @RogerBarreto We can run it via UI Dashboard but not via code. Same error facing as faced by @jamesmkfoo23

jamesmkfoo23 commented 1 month ago

@jamesmkfoo23 were you able to run this on Global Batch? @evchaki @RogerBarreto We can run it via UI Dashboard but not via code. Same error facing as faced by @jamesmkfoo23

No, I did not try. I just went with Global Standard on supported region

BensGitShell commented 1 week ago

Hi all, I'm still getting the same error message despite ticking the completions box on the 4o-mini deployment column options. Is completions truly supported for 4o-mini yet? Thanks very much :) @RogerBarreto @jamesmkfoo23 @evchaki @arnavjain

RogerBarreto commented 1 week ago

@BensGitShell, thanks for reaching out, this error happens in the backend of Azure API, double check what is the version of your gpt-4o-mini deployment. Suggest checking with Azure support service for further guidance, might be a region limitation or another reason for the error.

BensGitShell commented 1 week ago

Thanks @RogerBarreto, will reach out to Azure support.