jeff3071 commented on code in PR #72002:
URL: https://github.com/apache/airflow/pull/72002#discussion_r3999063288


##########
providers/common/ai/tests/unit/common/ai/hooks/test_llamaindex.py:
##########
@@ -128,6 +129,43 @@ def test_dispatches_with_api_base(self, mock_get_conn, 
mock_cls):
             api_base="http://localhost:11434/v1";,
         )
 
+    @patch("llama_index.embeddings.openai.OpenAIEmbedding")
+    @patch.object(LlamaIndexHook, "get_connection")
+    def test_dispatches_with_embedding_kwargs(self, mock_get_conn, mock_cls, 
caplog):
+        mock_get_conn.return_value = _conn(password="sk-test")
+        mock_cls.model_fields = {"api_key": None, "dimensions": None, 
"timeout": None}
+        hook = LlamaIndexHook(
+            embed_model="text-embedding-3-small",
+            embedding_kwargs={"api_key": "from-kwargs", "dimensions": 128, 
"timeout": 30},
+        )
+
+        hook.get_embedding_model()
+
+        mock_cls.assert_called_once_with(
+            model="text-embedding-3-small",
+            api_key="sk-test",
+            dimensions=128,
+            timeout=30,
+        )
+        assert "Connection parameters override embedding_kwargs values: 
['api_key']" in caplog.messages
+
+    @patch("llama_index.embeddings.openai.OpenAIEmbedding")
+    @patch.object(LlamaIndexHook, "get_connection")
+    def test_warns_about_unsupported_embedding_kwargs(self, mock_get_conn, 
mock_cls, caplog):

Review Comment:
   Update `test_warns_about_unsupported_embedding_kwargs` to use 
`OpenAIEmbedding` and parametrized over a signature-only key, a field-only key 
and a genuinely unsupported one.
   
   `test_dispatches_with_embedding_kwargs` check no warning message.
   



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