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


##########
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:
   Done both Java assertions now check the package and class, and I updated the 
azure_openai comment to call out vllm as the other colliding alias.



##########
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:
   Done! the blank-arguments test now checks both values after withVLLMDefaults 
(I used your suggested assertion). That way, if the isBlank() handling 
regresses, the test will catch it instead of silently falling back to the SDK 
default endpoint.



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