jeff3071 commented on code in PR #72002:
URL: https://github.com/apache/airflow/pull/72002#discussion_r4013739930
##########
providers/common/ai/src/airflow/providers/common/ai/hooks/llamaindex.py:
##########
@@ -172,14 +181,42 @@ def get_embedding_model(self) -> BaseEmbedding:
except ImportError as e:
raise AirflowOptionalProviderFeatureException(e)
+ reserved_keys = sorted(self.embedding_kwargs.keys() & {"model",
"model_name"})
+ if reserved_keys:
+ raise ValueError(
+ f"embedding_kwargs must not contain reserved keys
{reserved_keys}; use embed_model instead"
+ )
+ additional_kwargs = self.embedding_kwargs.get("additional_kwargs")
+ if isinstance(additional_kwargs, dict):
+ reserved_request_keys = sorted(additional_kwargs.keys() &
{"input", "model", "model_name"})
+ if reserved_request_keys:
+ raise ValueError(
+ "embedding_kwargs['additional_kwargs'] must not contain
reserved keys "
+ f"{reserved_request_keys}; model identity and input are
managed by the hook"
+ )
+
conn = self.get_connection(self.embed_conn_id)
model_id = self._resolve_model(
conn.extra_dejson,
constructor_value=self.embed_model,
extra_key="embed_model",
kind="embedding",
)
- return OpenAIEmbedding(model=model_id, **self._connection_kwargs(conn))
+ connection_kwargs = self._connection_kwargs(conn)
+ overridden_keys = sorted(self.embedding_kwargs.keys() &
connection_kwargs.keys())
Review Comment:
Agree, there is no reliable way to guard every override path because the
supported parameters and nesting vary by integration.
I removed the denylist and document `embedding_kwargs` would forward without
filtering and may override hook-provided values.
The remaining warnings cover:
- LangChain: `api_key`, `base_url`, `provider`.
- LlamaIndex: `api_key`, `api_base`.
--
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]