weiqingy commented on code in PR #945:
URL: https://github.com/apache/flink-agents/pull/945#discussion_r3745444812


##########
integrations/chat-models/openai/src/test/java/org/apache/flink/agents/integrations/chatmodels/openai/VLLMChatModelConnectionTest.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.agents.integrations.chatmodels.openai;
+
+import com.openai.models.chat.completions.ChatCompletionCreateParams;
+import org.apache.flink.agents.api.chat.messages.ChatMessage;
+import org.apache.flink.agents.api.resource.ResourceContext;
+import org.apache.flink.agents.api.resource.ResourceDescriptor;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+/**
+ * Unit tests for {@link VLLMChatModelConnection} — constructor/default 
handling only, no network
+ * access.
+ */
+class VLLMChatModelConnectionTest {
+
+    private static final ResourceContext NOOP = 
ResourceContext.fromGetResource((a, b) -> null);
+
+    private static ResourceDescriptor.Builder connectionDescriptor() {
+        return 
ResourceDescriptor.Builder.newBuilder(VLLMChatModelConnection.class.getName());
+    }
+
+    @Test
+    @DisplayName("Constructor succeeds with no arguments: api_key and 
api_base_url are defaulted")
+    void testConstructorNoArguments() {
+        // The parent OpenAI connection throws when api_key is missing, so a 
successful
+        // construction here proves the vLLM defaults were injected.
+        ResourceDescriptor desc = connectionDescriptor().build();
+        VLLMChatModelConnection conn = new VLLMChatModelConnection(desc, NOOP);
+        assertThat(conn).isInstanceOf(OpenAICompletionsConnection.class);
+    }
+
+    @Test
+    @DisplayName("Constructor defaults blank api_key and api_base_url")
+    void testConstructorBlankArgumentsAreDefaulted() {
+        ResourceDescriptor desc =
+                connectionDescriptor()
+                        .addInitialArgument("api_key", "")
+                        .addInitialArgument("api_base_url", " ")
+                        .build();
+        assertThatCode(() -> new VLLMChatModelConnection(desc, 
NOOP)).doesNotThrowAnyException();

Review Comment:
   Now that `withVLLMDefaults` is package-visible, this one could pin values 
too. Drop just the `isBlank()` clause for `api_base_url` 
(`VLLMChatModelConnection.java:89-92`) and the whole Java suite stays green: a 
blank `api_base_url` makes the parent skip `builder.baseUrl(...)` 
(`OpenAICompletionsConnection.java:100`) rather than throw, so 
`doesNotThrowAnyException()` still holds. That leaves `api_base_url: ""` 
silently building against the SDK's default endpoint instead of the vLLM 
server. Python pins both values (`test_vllm_chat_model.py:62-66`). Worth 
extending this one the same way?
   
   In case it helps:
   
   ```java
   
assertThat(VLLMChatModelConnection.withVLLMDefaults(desc).getInitialArguments())
           .containsEntry("api_key", 
VLLMChatModelConnection.DEFAULT_VLLM_API_KEY)
           .containsEntry("api_base_url", 
VLLMChatModelConnection.DEFAULT_VLLM_API_BASE_URL);
   ```



##########
python/flink_agents/api/yaml/tests/test_aliases.py:
##########
@@ -127,6 +127,21 @@ def test_resolve_clazz_default_language_is_python() -> 
None:
     assert default == explicit
 
 
+def test_resolve_clazz_covers_chat_model_vllm_in_both_languages() -> None:
+    assert resolve_clazz("vllm", ResourceType.CHAT_MODEL_CONNECTION).endswith(
+        "vllm_chat_model.VLLMChatModelConnection"
+    )
+    assert resolve_clazz("vllm", ResourceType.CHAT_MODEL).endswith(
+        "vllm_chat_model.VLLMChatModelSetup"
+    )
+    assert resolve_clazz("vllm", ResourceType.CHAT_MODEL_CONNECTION, 
"java").startswith(

Review Comment:
   `vllm` is a second alias whose Java and Python simple names collide, and 
these two Java assertions each pin half of what lines 158-162 pin for 
`azure_openai`: this one the package, line 140 the class. A Java entry that 
lost its `.Java` suffix and resolved to the Python class would still pass here, 
which is the case the comment at line 152 says to guard against. That comment 
also calls `azure_openai` the *only* such alias, which this PR makes false. 
Should this one pin both halves, and the comment pick up `vllm`?



-- 
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