Skip to content

Commit

Permalink
Update vision_models.py to allow kwargs usage.
Browse files Browse the repository at this point in the history
Update vision_models.py to allow kwargs usage.
Remove filtering that was keeping only default keys values.
  • Loading branch information
TommasoPetrolito committed Sep 6, 2024
1 parent 2fe7942 commit 0ec1efb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libs/vertexai/langchain_google_vertexai/vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _default_params(self) -> Dict[str, Any]:
def _prepare_params(self, **kwargs: Any) -> Dict[str, Any]:
params = self._default_params
for key, value in kwargs.items():
if key in params and value is not None:
if value is not None:
params[key] = value
return params

Expand Down Expand Up @@ -222,7 +222,7 @@ def _generate(
"{'type': 'image_url', 'image_url': {'image': <image_str>}}"
)

captions = self._get_captions(image, **messages[0].additional_kwargs)
captions = self._get_captions(image, **messages[0].additional_kwargs, **kwargs)

generations = [
ChatGeneration(message=AIMessage(content=caption)) for caption in captions
Expand Down Expand Up @@ -285,7 +285,7 @@ def _generate(
)

answers = self._ask_questions(
image=image, query=user_question, **messages[0].additional_kwargs
image=image, query=user_question, **messages[0].additional_kwargs, **kwargs
)

generations = [
Expand Down Expand Up @@ -357,7 +357,7 @@ def _prepare_params(self, **kwargs: Any) -> Dict[str, Any]:
mapping = {"number_of_results": "number_of_images"}
for key, value in kwargs.items():
key = mapping.get(key, key)
if key in params and value is not None:
if value is not None:
params[key] = value
return {k: v for k, v in params.items() if v is not None}

Expand Down Expand Up @@ -473,7 +473,7 @@ def _generate(
)

image_str_list = self._generate_images(
prompt=user_query, **messages[0].additional_kwargs
prompt=user_query, **messages[0].additional_kwargs, **kwargs
)
image_content_part_list = [
create_image_content_part(image_str=image_str)
Expand Down Expand Up @@ -522,7 +522,7 @@ def _generate(
)

image_str_list = self._edit_images(
image_str=image_str, prompt=user_query, **messages[0].additional_kwargs
image_str=image_str, prompt=user_query, **messages[0].additional_kwargs, **kwargs

Check failure on line 525 in libs/vertexai/langchain_google_vertexai/vision_models.py

View workflow job for this annotation

GitHub Actions / cd libs/vertexai / - / make lint #3.8

Ruff (E501)

langchain_google_vertexai/vision_models.py:525:89: E501 Line too long (93 > 88)

Check failure on line 525 in libs/vertexai/langchain_google_vertexai/vision_models.py

View workflow job for this annotation

GitHub Actions / cd libs/vertexai / - / make lint #3.11

Ruff (E501)

langchain_google_vertexai/vision_models.py:525:89: E501 Line too long (93 > 88)
)
image_content_part_list = [
create_image_content_part(image_str=image_str)
Expand Down

0 comments on commit 0ec1efb

Please sign in to comment.