Skip to content

Commit c763fde

Browse files
authored
chore: revert default model to command-r-08-2024 (#2282)
* chore: Upgrade default model to command-r-08-2024 again * fix README
1 parent 24676f2 commit c763fde

7 files changed

Lines changed: 17 additions & 19 deletions

File tree

integrations/cohere/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
- [Integration page](https://haystack.deepset.ai/integrations/cohere)
77
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/cohere/CHANGELOG.md)
88

9-
---
10-
119

1210
---
1311

integrations/cohere/examples/cohere_generation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# The pipeline workflow:
99
# 1. Receives a user message requesting to create a JSON object from "Peter Parker" aka Superman.
10-
# 2. Processes the message through components to generate a response using Cohere command-r model.
10+
# 2. Processes the message through components to generate a response using Cohere command-r-08-2024 model.
1111
# 3. Validates the generated response against a predefined JSON schema for person data.
1212
# 4. If the response does not meet the schema, the JsonSchemaValidator provides details on how to correct the errors.
1313
# 4a. The pipeline loops back, using the error information to generate a new JSON object until it satisfies the schema.
@@ -40,7 +40,7 @@
4040

4141
# Add components to the pipeline
4242
pipe.add_component("joiner", BranchJoiner(List[ChatMessage]))
43-
pipe.add_component("fc_llm", CohereChatGenerator(model="command-r"))
43+
pipe.add_component("fc_llm", CohereChatGenerator(model="command-r-08-2024"))
4444
pipe.add_component("validator", JsonSchemaValidator(json_schema=person_schema))
4545
(pipe.add_component("adapter", OutputAdapter("{{chat_message}}", List[ChatMessage])),)
4646
# And connect them

integrations/cohere/src/haystack_integrations/components/generators/cohere/chat/chat_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def weather(city: str) -> str:
515515
def __init__(
516516
self,
517517
api_key: Secret = Secret.from_env_var(["COHERE_API_KEY", "CO_API_KEY"]),
518-
model: str = "command-r-plus",
518+
model: str = "command-r-08-2024",
519519
streaming_callback: Optional[StreamingCallbackT] = None,
520520
api_base_url: Optional[str] = None,
521521
generation_kwargs: Optional[Dict[str, Any]] = None,

integrations/cohere/src/haystack_integrations/components/generators/cohere/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CohereGenerator(CohereChatGenerator):
3232
def __init__(
3333
self,
3434
api_key: Secret = Secret.from_env_var(["COHERE_API_KEY", "CO_API_KEY"]),
35-
model: str = "command-r",
35+
model: str = "command-r-08-2024",
3636
streaming_callback: Optional[Callable] = None,
3737
api_base_url: Optional[str] = None,
3838
**kwargs: Any,

integrations/cohere/tests/test_chat_generator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_init_default(self, monkeypatch):
152152

153153
component = CohereChatGenerator()
154154
assert component.api_key == Secret.from_env_var(["COHERE_API_KEY", "CO_API_KEY"])
155-
assert component.model == "command-r-plus"
155+
assert component.model == "command-r-08-2024"
156156
assert component.streaming_callback is None
157157
assert component.api_base_url == "https://api.cohere.com"
158158
assert not component.generation_kwargs
@@ -190,7 +190,7 @@ def test_to_dict_default(self, monkeypatch):
190190
assert data == {
191191
"type": "haystack_integrations.components.generators.cohere.chat.chat_generator.CohereChatGenerator",
192192
"init_parameters": {
193-
"model": "command-r-plus",
193+
"model": "command-r-08-2024",
194194
"streaming_callback": None,
195195
"api_key": {
196196
"env_vars": ["COHERE_API_KEY", "CO_API_KEY"],
@@ -242,7 +242,7 @@ def test_from_dict(self, monkeypatch):
242242
data = {
243243
"type": "haystack_integrations.components.generators.cohere.chat.chat_generator.CohereChatGenerator",
244244
"init_parameters": {
245-
"model": "command-r-plus",
245+
"model": "command-r-08-2024",
246246
"api_base_url": "test-base-url",
247247
"api_key": {
248248
"env_vars": ["ENV_VAR"],
@@ -257,7 +257,7 @@ def test_from_dict(self, monkeypatch):
257257
},
258258
}
259259
component = CohereChatGenerator.from_dict(data)
260-
assert component.model == "command-r-plus"
260+
assert component.model == "command-r-08-2024"
261261
assert component.streaming_callback is print_streaming_chunk
262262
assert component.api_base_url == "test-base-url"
263263
assert component.generation_kwargs == {
@@ -271,7 +271,7 @@ def test_from_dict_fail_wo_env_var(self, monkeypatch):
271271
data = {
272272
"type": "haystack_integrations.components.generators.cohere.chat.chat_generator.CohereChatGenerator",
273273
"init_parameters": {
274-
"model": "command-r-plus",
274+
"model": "command-r-08-2024",
275275
"api_base_url": "test-base-url",
276276
"api_key": {
277277
"env_vars": ["COHERE_API_KEY", "CO_API_KEY"],
@@ -303,7 +303,7 @@ def test_serde_in_pipeline(self, monkeypatch):
303303
)
304304

305305
generator = CohereChatGenerator(
306-
model="command-r-plus",
306+
model="command-r-08-2024",
307307
generation_kwargs={"temperature": 0.7},
308308
streaming_callback=print_streaming_chunk,
309309
tools=[tool],
@@ -322,7 +322,7 @@ def test_serde_in_pipeline(self, monkeypatch):
322322
"generator": {
323323
"type": "haystack_integrations.components.generators.cohere.chat.chat_generator.CohereChatGenerator", # noqa: E501
324324
"init_parameters": {
325-
"model": "command-r-plus",
325+
"model": "command-r-08-2024",
326326
"api_key": {"type": "env_var", "env_vars": ["COHERE_API_KEY", "CO_API_KEY"], "strict": True},
327327
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
328328
"api_base_url": "https://api.cohere.com",

integrations/cohere/tests/test_chat_generator_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def test_tools_use_with_tools_async(self):
7474
function=stock_price,
7575
)
7676
initial_messages = [ChatMessage.from_user("What is the current price of AAPL?")]
77-
client = CohereChatGenerator(model="command-r")
77+
client = CohereChatGenerator(model="command-r-08-2024")
7878
response = await client.run_async(
7979
messages=initial_messages,
8080
tools=[stock_price_tool],
@@ -137,7 +137,7 @@ async def print_streaming_chunk_async(chunk: StreamingChunk) -> None:
137137

138138
initial_messages = [ChatMessage.from_user("What's the weather like in Paris?")]
139139
component = CohereChatGenerator(
140-
model="command-r", # Cohere's model that supports tools
140+
model="command-r-08-2024", # Cohere's model that supports tools
141141
tools=[weather_tool],
142142
streaming_callback=print_streaming_chunk_async,
143143
)

integrations/cohere/tests/test_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_init_default(self, monkeypatch):
1919
monkeypatch.setenv("COHERE_API_KEY", "foo")
2020
component = CohereGenerator()
2121
assert component.api_key == Secret.from_env_var(["COHERE_API_KEY", "CO_API_KEY"])
22-
assert component.model == "command-r"
22+
assert component.model == "command-r-08-2024"
2323
assert component.streaming_callback is None
2424
assert component.api_base_url == COHERE_API_URL
2525
assert component.model_parameters == {}
@@ -47,7 +47,7 @@ def test_to_dict_default(self, monkeypatch):
4747
assert data == {
4848
"type": "haystack_integrations.components.generators.cohere.generator.CohereGenerator",
4949
"init_parameters": {
50-
"model": "command-r",
50+
"model": "command-r-08-2024",
5151
"api_key": {"env_vars": ["COHERE_API_KEY", "CO_API_KEY"], "strict": True, "type": "env_var"},
5252
"streaming_callback": None,
5353
"api_base_url": COHERE_API_URL,
@@ -86,7 +86,7 @@ def test_from_dict(self, monkeypatch):
8686
data = {
8787
"type": "haystack_integrations.components.generators.cohere.generator.CohereGenerator",
8888
"init_parameters": {
89-
"model": "command-r",
89+
"model": "command-r-08-2024",
9090
"max_tokens": 10,
9191
"api_key": {"env_vars": ["ENV_VAR"], "strict": False, "type": "env_var"},
9292
"some_test_param": "test-params",
@@ -97,7 +97,7 @@ def test_from_dict(self, monkeypatch):
9797
}
9898
component: CohereGenerator = CohereGenerator.from_dict(data)
9999
assert component.api_key == Secret.from_env_var("ENV_VAR", strict=False)
100-
assert component.model == "command-r"
100+
assert component.model == "command-r-08-2024"
101101
assert component.streaming_callback == print_streaming_chunk
102102
assert component.api_base_url == "test-base-url"
103103
assert component.model_parameters == {"max_tokens": 10, "some_test_param": "test-params"}

0 commit comments

Comments
 (0)