@@ -22,20 +22,42 @@ public class AzureOpenAIChatModelFactory implements ChatModelFactory {
2222
2323 @ Override
2424 public ChatLanguageModel createChatModel (@ NotNull ChatModel chatModel ) {
25- boolean isO1 = chatModel .getModelName ().startsWith ("o1-" );
25+ String modelName = chatModel .getModelName ();
26+
27+ boolean isReasoningModel = isReasoningModelWithLimitedParameters (modelName );
2628
2729 final var builder = AzureOpenAiChatModel .builder ()
2830 .apiKey (getApiKey (MODEL_PROVIDER ))
2931 .deploymentName (DevoxxGenieStateService .getInstance ().getAzureOpenAIDeployment ())
3032 .maxRetries (chatModel .getMaxRetries ())
33+ .temperature (isReasoningModel ? 1.0 : chatModel .getTemperature ())
3134 .timeout (Duration .ofSeconds (chatModel .getTimeout ()))
32- .topP (isO1 ? 1.0 : chatModel .getTopP ())
35+ .topP (isReasoningModel ? 1.0 : chatModel .getTopP ())
3336 .endpoint (DevoxxGenieStateService .getInstance ().getAzureOpenAIEndpoint ())
3437 .listeners (getListener ());
3538
3639 return builder .build ();
3740 }
3841
42+ /**
43+ * Returns whether the model is a reasoning model with limited parameter support, in order to provide default
44+ * values instead of given configuration.
45+ * <p>
46+ * @see <a href="https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/reasoning?tabs=python-secure%2Cpy#not-supported">Azure OpenAI reasoning models - parameters not supported</a>
47+ * for details on parameter support for reasoning models.
48+ *
49+ * @param modelName name of the model to check
50+ * @return true if the model name indicates a reasoning model
51+ */
52+ static boolean isReasoningModelWithLimitedParameters (String modelName ) {
53+ boolean isO1 = modelName .startsWith ("o1" );
54+ boolean isO3 = modelName .startsWith ("o3" );
55+ boolean isO4 = modelName .startsWith ("o4-mini" );
56+ boolean isCodex = modelName .equalsIgnoreCase ("codex-mini" );
57+
58+ return isO1 || isO3 || isO4 || isCodex ;
59+ }
60+
3961 @ Override
4062 public StreamingChatLanguageModel createStreamingChatModel (@ NotNull ChatModel chatModel ) {
4163 boolean isO1 = chatModel .getModelName ().startsWith ("o1-" );
0 commit comments