mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Fix type error and test issues
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user