rob-9 commented on code in PR #883:
URL: https://github.com/apache/flink-agents/pull/883#discussion_r3763659149


##########
integrations/chat-models/openai/src/main/java/org/apache/flink/agents/integrations/chatmodels/openai/OpenAICompletionsConnection.java:
##########
@@ -98,15 +101,23 @@ public OpenAICompletionsConnection(
             builder.baseUrl(apiBaseUrl);
         }
 
-        Integer timeoutSeconds = descriptor.getArgument("timeout");
-        if (timeoutSeconds != null && timeoutSeconds > 0) {
-            builder.timeout(Duration.ofSeconds(timeoutSeconds));
+        this.timeoutSeconds =
+                Optional.ofNullable(descriptor.<Number>getArgument("timeout"))
+                        .map(Number::intValue)
+                        
.orElse(OpenAIChatCompletionsUtils.DEFAULT_TIMEOUT_SECONDS);
+        if (this.timeoutSeconds < 0) {
+            throw new IllegalArgumentException("timeout must be >= 0, got: " + 
this.timeoutSeconds);
         }
-
-        Integer maxRetries = descriptor.getArgument("max_retries");
-        if (maxRetries != null && maxRetries >= 0) {
-            builder.maxRetries(maxRetries);
+        builder.timeout(Duration.ofSeconds(this.timeoutSeconds));

Review Comment:
   `timeout=0` now disables timeouts in both Java and Python. added 
SDK/transport-level tests. 



##########
integrations/chat-models/openai/src/main/java/org/apache/flink/agents/integrations/chatmodels/openai/OpenAICompletionsConnection.java:
##########
@@ -98,15 +101,23 @@ public OpenAICompletionsConnection(
             builder.baseUrl(apiBaseUrl);
         }
 
-        Integer timeoutSeconds = descriptor.getArgument("timeout");
-        if (timeoutSeconds != null && timeoutSeconds > 0) {
-            builder.timeout(Duration.ofSeconds(timeoutSeconds));
+        this.timeoutSeconds =
+                Optional.ofNullable(descriptor.<Number>getArgument("timeout"))
+                        .map(Number::intValue)

Review Comment:
   thanks -- validation now checks the raw numeric value before conversion. 
`max_retries` must be an exact bounded integer, while timeouts preserve 
fractional values and reject invalid inputs. also added boundary coverage.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to