Skip to content

Commit

Permalink
remove more tests involving serialization of lambdas (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 authored Jan 10, 2025
1 parent 97a2cda commit 20c9437
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 64 deletions.
19 changes: 0 additions & 19 deletions integrations/anthropic/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ def test_to_dict_with_parameters(self, monkeypatch):
},
}

def test_to_dict_with_lambda_streaming_callback(self, monkeypatch):
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-api-key")
component = AnthropicGenerator(
model="claude-3-sonnet-20240229",
streaming_callback=lambda x: x,
generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"},
)
data = component.to_dict()
assert data == {
"type": "haystack_integrations.components.generators.anthropic.generator.AnthropicGenerator",
"init_parameters": {
"api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "strict": True, "type": "env_var"},
"model": "claude-3-sonnet-20240229",
"streaming_callback": "tests.test_generator.<lambda>",
"system_prompt": None,
"generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
},
}

def test_from_dict(self, monkeypatch):
monkeypatch.setenv("ANTHROPIC_API_KEY", "fake-api-key")
data = {
Expand Down
24 changes: 0 additions & 24 deletions integrations/anthropic/tests/test_vertex_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,6 @@ def test_to_dict_with_parameters(self):
},
}

def test_to_dict_with_lambda_streaming_callback(self):
component = AnthropicVertexChatGenerator(
region="us-central1",
project_id="test-project-id",
model="claude-3-5-sonnet@20240620",
streaming_callback=lambda x: x,
generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"},
)
data = component.to_dict()
assert data == {
"type": (
"haystack_integrations.components.generators."
"anthropic.chat.vertex_chat_generator.AnthropicVertexChatGenerator"
),
"init_parameters": {
"region": "us-central1",
"project_id": "test-project-id",
"model": "claude-3-5-sonnet@20240620",
"streaming_callback": "tests.test_vertex_chat_generator.<lambda>",
"generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
"ignore_tools_thinking_messages": True,
},
}

def test_from_dict(self):
data = {
"type": (
Expand Down
21 changes: 0 additions & 21 deletions integrations/cohere/tests/test_cohere_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,6 @@ def test_to_dict_with_parameters(self, monkeypatch):
},
}

def test_to_dict_with_lambda_streaming_callback(self, monkeypatch):
monkeypatch.setenv("COHERE_API_KEY", "test-api-key")
component = CohereGenerator(
model="command-r",
max_tokens=10,
some_test_param="test-params",
streaming_callback=lambda x: x,
api_base_url="test-base-url",
)
data = component.to_dict()
assert data == {
"type": "haystack_integrations.components.generators.cohere.generator.CohereGenerator",
"init_parameters": {
"model": "command-r",
"streaming_callback": "tests.test_cohere_generator.<lambda>",
"api_base_url": "test-base-url",
"api_key": {"type": "env_var", "env_vars": ["COHERE_API_KEY", "CO_API_KEY"], "strict": True},
"generation_kwargs": {},
},
}

def test_from_dict(self, monkeypatch):
monkeypatch.setenv("COHERE_API_KEY", "fake-api-key")
monkeypatch.setenv("CO_API_KEY", "fake-api-key")
Expand Down

0 comments on commit 20c9437

Please sign in to comment.