-
Notifications
You must be signed in to change notification settings - Fork 617
fix(py): update define_embedder in google plugin_api and other test files #3964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -153,7 +153,7 @@ def test_googleai_initialize(): | |||||||||||||||||||||||
| ai_mock.define_embedder.assert_any_call( | ||||||||||||||||||||||||
| name=googleai_name(version), | ||||||||||||||||||||||||
| fn=ANY, | ||||||||||||||||||||||||
| metadata=ANY, | ||||||||||||||||||||||||
| options=ANY, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -244,10 +244,15 @@ def test_googleai__resolve_embedder( | |||||||||||||||||||||||
| name=model_name, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ai_mock.define_embedder.assert_called_once_with( | ||||||||||||||||||||||||
| name=expected_model_name, fn=ANY, metadata=default_embedder_info(clean_name) | ||||||||||||||||||||||||
| info = default_embedder_info(clean_name) | ||||||||||||||||||||||||
| options = EmbedderOptions( | ||||||||||||||||||||||||
| label=info.get('label'), | ||||||||||||||||||||||||
| supports=EmbedderSupports(**info.get('supports', {})), | ||||||||||||||||||||||||
| dimensions=info.get('dimensions'), | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ai_mock.define_embedder.assert_called_once_with(name=expected_model_name, fn=ANY, options=options) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def test_googleai_list_actions(googleai_plugin_instance): | ||||||||||||||||||||||||
| """Unit test for list actions.""" | ||||||||||||||||||||||||
|
|
@@ -491,6 +496,7 @@ def test_vertexai_initialize(vertexai_plugin_instance): | |||||||||||||||||||||||
| plugin.initialize(ai_mock) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| assert ai_mock.define_model.call_count == len(VertexAIGeminiVersion) + len(ImagenVersion) | ||||||||||||||||||||||||
| # The actual call passes EmbedderOptions, so verify we are calling passing options | ||||||||||||||||||||||||
| assert ai_mock.define_embedder.call_count == len(VertexEmbeddingModels) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| for version in VertexAIGeminiVersion: | ||||||||||||||||||||||||
|
|
@@ -507,7 +513,7 @@ def test_vertexai_initialize(vertexai_plugin_instance): | |||||||||||||||||||||||
| ai_mock.define_embedder.assert_any_call( | ||||||||||||||||||||||||
| name=vertexai_name(version), | ||||||||||||||||||||||||
| fn=ANY, | ||||||||||||||||||||||||
| metadata=ANY, | ||||||||||||||||||||||||
| options=ANY, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -648,10 +654,15 @@ def test_vertexai__resolve_embedder( | |||||||||||||||||||||||
| name=model_name, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ai_mock.define_embedder.assert_called_once_with( | ||||||||||||||||||||||||
| name=expected_model_name, fn=ANY, metadata=default_embedder_info(clean_name) | ||||||||||||||||||||||||
| info = default_embedder_info(clean_name) | ||||||||||||||||||||||||
| options = EmbedderOptions( | ||||||||||||||||||||||||
| label=info.get('label'), | ||||||||||||||||||||||||
| supports=EmbedderSupports(**info.get('supports', {})), | ||||||||||||||||||||||||
| dimensions=info.get('dimensions'), | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
Comment on lines
+658
to
662
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to a previous comment, the logic for constructing
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ai_mock.define_embedder.assert_called_once_with(name=expected_model_name, fn=ANY, options=options) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def test_vertexai_list_actions(vertexai_plugin_instance): | ||||||||||||||||||||||||
| """Unit test for list actions.""" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for constructing
EmbedderOptions, specifically for thesupportsfield, diverges from the implementation ingoogle.py. The implementation results insupports=Noneif thesupportsdictionary is missing or empty, while this test would create anEmbedderSupportsobject with default values. This discrepancy could lead to the test failing incorrectly ifdefault_embedder_infochanges its return value in the future. To ensure consistency and robustness, the test should replicate the implementation's logic.