Fix type error and test issues

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-04-25 21:03:36 +00:00
parent 50059c7120
commit 5623e2c851
2 changed files with 7 additions and 1 deletions

View File

@@ -20,7 +20,8 @@ class FixedGoogleVertexEmbeddingFunction(GoogleVertexEmbeddingFunction):
model_name: str = "textembedding-gecko",
api_key: Optional[str] = None,
**kwargs: Any):
super().__init__(model_name=model_name, api_key=api_key, **kwargs)
api_key_str = "" if api_key is None else api_key
super().__init__(model_name=model_name, api_key=api_key_str, **kwargs)
self._original_post = requests.post
requests.post = self._patched_post

View File

@@ -45,8 +45,13 @@ class TestFixedGoogleVertexEmbeddingFunction:
def test_embedding_call(self, embedding_function):
function, mock_post = embedding_function
mock_response = MagicMock()
mock_response.json.return_value = {"predictions": [[0.1, 0.2, 0.3]]}
mock_post.return_value = mock_response
embeddings = function(["test text"])
mock_post.assert_called_once()
assert isinstance(embeddings, list)
assert len(embeddings) > 0