internal ChatCompletionOptions BuildRequest()

in src/WebJobs.Extensions.OpenAI/Assistants/AssistantBaseAttribute.cs [84:121]


    internal ChatCompletionOptions BuildRequest()
    {
        ChatCompletionOptions request = new();
        if (float.TryParse(this.TopP, out float topP))
        {
            request.TopP = topP;
        }

        if (this.IsReasoningModel)
        {
            this.MaxTokens = null;
            this.Temperature = null; // property not supported for reasoning model.
        }
        else
        {
            if (int.TryParse(this.MaxTokens, out int maxTokens))
            {
                request.MaxOutputTokenCount = maxTokens;
            }

            if (float.TryParse(this.Temperature, out float temperature))
            {
                request.Temperature = temperature;
            }
        }

        // ToDo: SetNewMaxCompletionTokensPropertyEnabled() has a bug in the current version 
        // of the Azure.AI.OpenAI SDK but is fixed in the next preview.
        // 
        // This method doesn't swap max_tokens with max_completion_tokens and throws errors 
        // if max_tokens is set. max_completion_tokens is not configurable due to this bug.
        // 
        // Hence, setting max_tokens to null for reasoning models until the fixed SDK version 
        // can be adopted.
        // request.SetNewMaxCompletionTokensPropertyEnabled(this.IsReasoningModel);

        return request;
    }