imbajin commented on code in PR #304:
URL: 
https://github.com/apache/incubator-hugegraph-ai/pull/304#discussion_r2465639568


##########
hugegraph-llm/src/hugegraph_llm/demo/rag_demo/configs_block.py:
##########
@@ -106,6 +106,83 @@ def test_api_connection(
     return resp.status_code
 
 
+def apply_vector_engine(engine: str):
+    # Persist the vector engine selection
+    setattr(index_settings, "cur_vector_index", engine)
+    try:
+        index_settings.update_env()
+    except Exception:  # pylint: disable=W0718
+        pass
+    gr.Info("Configured!")
+
+
+def apply_vector_engine_backend(  # pylint: disable=too-many-branches
+    engine: str,
+    host: Optional[str] = None,
+    port: Optional[str] = None,
+    user: Optional[str] = None,
+    password: Optional[str] = None,
+    api_key: Optional[str] = None,
+    origin_call=None,
+) -> int:
+    """Test connection and persist per-engine connection settings"""
+    status_code = -1
+
+    # Test connection first
+    try:
+        if engine == "Milvus":
+            from pymilvus import connections, utility
+
+            connections.connect(
+                host=host, port=int(port or 19530), user=user or "", 
password=password or ""
+            )
+            # Test if we can list collections
+            _ = utility.list_collections()

Review Comment:
   🧹 **变量命名**: 使用下划线 `_` 来忽略返回值是 Python 的惯用法,这里做得很好。
   
   ```python
   _ = utility.list_collections()
   _ = client.get_collections()
   ```
   
   不过建议添加注释说明为什么不需要这些返回值,以提高代码可读性。



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to