utkarsharma2 commented on code in PR #38465:
URL: https://github.com/apache/airflow/pull/38465#discussion_r1607933073
##########
airflow/providers/cohere/hooks/cohere.py:
##########
@@ -46,23 +59,34 @@ def __init__(
conn_id: str = default_conn_name,
timeout: int | None = None,
max_retries: int | None = None,
+ request_options: dict | None = None,
) -> None:
super().__init__()
self.conn_id = conn_id
self.timeout = timeout
self.max_retries = max_retries
+ self.request_options = request_options
+ if self.max_retries:
+ warnings.warn(
+ "Argument `max_retries` is deprecated. Please use
`request_options` dict for function-specific request configuration instead.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
+ self.request_options = (
+ {"max_retries": self.max_retries}
+ if self.request_options is None
+ else self.request_options.update({"max_retries":
self.max_retries})
+ )
@cached_property
def get_conn(self) -> cohere.Client: # type: ignore[override]
conn = self.get_connection(self.conn_id)
- return cohere.Client(
- api_key=conn.password, timeout=self.timeout,
max_retries=self.max_retries, api_url=conn.host
- )
+ return cohere.Client(api_key=conn.password, timeout=self.timeout,
base_url=conn.host)
def create_embeddings(
self, texts: list[str], model: str = "embed-multilingual-v2.0"
- ) -> list[list[float]]:
- response = self.get_conn.embed(texts=texts, model=model)
+ ) -> list[list[float]] | cohere.EmbedByTypeResponseEmbeddings:
Review Comment:
I think return type should be just `EmbedResponse`
[ref](https://github.com/cohere-ai/cohere-python/blob/ee899df546000356b9d0c2a807a083ccfcd719d4/src/cohere/client.py#L123C10-L123C23).
Is there any case where we will still return list[list[float]]?
--
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]