microsoft / semantic-kernel

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

Python: Bug: Pylance complains when attempting to construct an instance of OpenAIChatPromptExecutionSettings with only response_format #8327

Open lsiddiquee opened 2 months ago

lsiddiquee commented 2 months ago

Describe the bug I need to set the response_format to {"type": "json_object"}. In order to do that I need to create an instance of OpenAIChatPromptExecutionSettings and use that when building the Kernel function. However, in order to only set the response_format I have to use the following code, even though there are defaults specified.

    prompt_execution_settings=OpenAIChatPromptExecutionSettings(
        service_id=None,
        ai_model_id=None,
        frequency_penalty=None,
        max_tokens=None,
        number_of_responses=None,
        presence_penalty=None,
        temperature=None,
        top_p=None,
        tools=None,
        function_call_behavior=None,
        function_choice_behavior=None,
        tool_choice=None,
        response_format={"type": "json_object"},
    )

This is already a known issue for pydantic and default fields. It is documented here and they have also included workarounds.

To Reproduce Attempt to create an instance of OpenAIChatPromptExecutionSettings and only set response_format.

Expected behavior Should be able to create an instance with only response_format.

Screenshots image

Platform

Additional context Add any other context about the problem here.

matthewbolanos commented 2 months ago

@eavanvalkenburg, would you be able to take a look at this oine?