Sxnan commented on code in PR #611:
URL: https://github.com/apache/flink-agents/pull/611#discussion_r3055412564


##########
python/flink_agents/integrations/embedding_models/tests/test_tongyi_embedding_model.py:
##########
@@ -0,0 +1,176 @@
+################################################################################
+#  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.
+################################################################################
+import os
+from http import HTTPStatus
+from types import SimpleNamespace
+from unittest.mock import MagicMock
+
+import pytest
+
+from flink_agents.api.resource import Resource, ResourceType
+from flink_agents.integrations.embedding_models.tongyi_embedding_model import (
+    TongyiEmbeddingModelConnection,
+    TongyiEmbeddingModelSetup,
+)
+
+test_model = os.environ.get("TONGYI_EMBEDDING_MODEL", "text-embedding-v4")
+api_key_available = "DASHSCOPE_API_KEY" in os.environ
+
+
[email protected](not api_key_available, reason="DashScope API key is not 
set")
+def test_tongyi_embedding_model() -> None:
+    """Test basic embedding functionality of TongyiEmbeddingModelConnection."""
+    connection = TongyiEmbeddingModelConnection(name="tongyi")
+
+    def get_resource(name: str, type: ResourceType) -> Resource:
+        if type == ResourceType.EMBEDDING_MODEL_CONNECTION:
+            return connection
+        else:
+            msg = f"Unknown resource type: {type}"
+            raise ValueError(msg)
+
+    embedding_model = TongyiEmbeddingModelSetup(
+        name="tongyi", model=test_model, connection="tongyi", 
get_resource=get_resource
+    )
+    embedding_model.open()
+
+    response = embedding_model.embed("衣服的质量杠杠的,很漂亮,不枉我等了这么久啊,喜欢,以后还来这里买")  # 
noqa: RUF001

Review Comment:
   Done. Changed to English in 57e2578.



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