@@ -41,11 +41,10 @@ class TestCohereRanker:
41
41
def test_init_default (self , monkeypatch ):
42
42
monkeypatch .setenv ("CO_API_KEY" , "test-api-key" )
43
43
component = CohereRanker ()
44
- assert component .model_name == "rerank-english-v2.0 "
44
+ assert component .model_name == "rerank-v3.5 "
45
45
assert component .top_k == 10
46
46
assert component .api_key == Secret .from_env_var (["COHERE_API_KEY" , "CO_API_KEY" ])
47
47
assert component .api_base_url == COHERE_API_URL
48
- assert component .max_chunks_per_doc is None
49
48
assert component .meta_fields_to_embed == []
50
49
assert component .meta_data_separator == "\n "
51
50
assert component .max_tokens_per_doc == 4096
@@ -59,20 +58,18 @@ def test_init_fail_wo_api_key(self, monkeypatch):
59
58
def test_init_with_parameters (self , monkeypatch ):
60
59
monkeypatch .setenv ("CO_API_KEY" , "test-api-key" )
61
60
component = CohereRanker (
62
- model = "rerank-multilingual-v2 .0" ,
61
+ model = "rerank-multilingual-v3 .0" ,
63
62
top_k = 5 ,
64
63
api_key = Secret .from_env_var (["COHERE_API_KEY" , "CO_API_KEY" ]),
65
64
api_base_url = "test-base-url" ,
66
- max_chunks_per_doc = 40 ,
67
65
meta_fields_to_embed = ["meta_field_1" , "meta_field_2" ],
68
66
meta_data_separator = "," ,
69
67
max_tokens_per_doc = 100 ,
70
68
)
71
- assert component .model_name == "rerank-multilingual-v2 .0"
69
+ assert component .model_name == "rerank-multilingual-v3 .0"
72
70
assert component .top_k == 5
73
71
assert component .api_key == Secret .from_env_var (["COHERE_API_KEY" , "CO_API_KEY" ])
74
72
assert component .api_base_url == "test-base-url"
75
- assert component .max_chunks_per_doc == 40
76
73
assert component .meta_fields_to_embed == ["meta_field_1" , "meta_field_2" ]
77
74
assert component .meta_data_separator == ","
78
75
assert component .max_tokens_per_doc == 100
@@ -84,11 +81,10 @@ def test_to_dict_default(self, monkeypatch):
84
81
assert data == {
85
82
"type" : "haystack_integrations.components.rankers.cohere.ranker.CohereRanker" ,
86
83
"init_parameters" : {
87
- "model" : "rerank-english-v2.0 " ,
84
+ "model" : "rerank-v3.5 " ,
88
85
"api_key" : {"env_vars" : ["COHERE_API_KEY" , "CO_API_KEY" ], "strict" : True , "type" : "env_var" },
89
86
"api_base_url" : COHERE_API_URL ,
90
87
"top_k" : 10 ,
91
- "max_chunks_per_doc" : None ,
92
88
"meta_fields_to_embed" : [],
93
89
"meta_data_separator" : "\n " ,
94
90
"max_tokens_per_doc" : 4096 ,
@@ -98,11 +94,10 @@ def test_to_dict_default(self, monkeypatch):
98
94
def test_to_dict_with_parameters (self , monkeypatch ):
99
95
monkeypatch .setenv ("CO_API_KEY" , "test-api-key" )
100
96
component = CohereRanker (
101
- model = "rerank-multilingual-v2 .0" ,
97
+ model = "rerank-multilingual-v3 .0" ,
102
98
top_k = 2 ,
103
99
api_key = Secret .from_env_var (["COHERE_API_KEY" , "CO_API_KEY" ]),
104
100
api_base_url = "test-base-url" ,
105
- max_chunks_per_doc = 50 ,
106
101
meta_fields_to_embed = ["meta_field_1" , "meta_field_2" ],
107
102
meta_data_separator = "," ,
108
103
max_tokens_per_doc = 100 ,
@@ -111,11 +106,10 @@ def test_to_dict_with_parameters(self, monkeypatch):
111
106
assert data == {
112
107
"type" : "haystack_integrations.components.rankers.cohere.ranker.CohereRanker" ,
113
108
"init_parameters" : {
114
- "model" : "rerank-multilingual-v2 .0" ,
109
+ "model" : "rerank-multilingual-v3 .0" ,
115
110
"api_key" : {"env_vars" : ["COHERE_API_KEY" , "CO_API_KEY" ], "strict" : True , "type" : "env_var" },
116
111
"api_base_url" : "test-base-url" ,
117
112
"top_k" : 2 ,
118
- "max_chunks_per_doc" : 50 ,
119
113
"meta_fields_to_embed" : ["meta_field_1" , "meta_field_2" ],
120
114
"meta_data_separator" : "," ,
121
115
"max_tokens_per_doc" : 100 ,
@@ -127,22 +121,20 @@ def test_from_dict(self, monkeypatch):
127
121
data = {
128
122
"type" : "haystack_integrations.components.rankers.cohere.ranker.CohereRanker" ,
129
123
"init_parameters" : {
130
- "model" : "rerank-multilingual-v2 .0" ,
124
+ "model" : "rerank-multilingual-v3 .0" ,
131
125
"api_key" : {"env_vars" : ["COHERE_API_KEY" , "CO_API_KEY" ], "strict" : True , "type" : "env_var" },
132
126
"api_base_url" : "test-base-url" ,
133
127
"top_k" : 2 ,
134
- "max_chunks_per_doc" : 50 ,
135
128
"meta_fields_to_embed" : ["meta_field_1" , "meta_field_2" ],
136
129
"meta_data_separator" : "," ,
137
130
"max_tokens_per_doc" : 100 ,
138
131
},
139
132
}
140
133
component = CohereRanker .from_dict (data )
141
- assert component .model_name == "rerank-multilingual-v2 .0"
134
+ assert component .model_name == "rerank-multilingual-v3 .0"
142
135
assert component .top_k == 2
143
136
assert component .api_key == Secret .from_env_var (["COHERE_API_KEY" , "CO_API_KEY" ])
144
137
assert component .api_base_url == "test-base-url"
145
- assert component .max_chunks_per_doc == 50
146
138
assert component .meta_fields_to_embed == ["meta_field_1" , "meta_field_2" ]
147
139
assert component .meta_data_separator == ","
148
140
assert component .max_tokens_per_doc == 100
@@ -153,10 +145,9 @@ def test_from_dict_fail_wo_env_var(self, monkeypatch):
153
145
data = {
154
146
"type" : "haystack_integrations.components.rankers.cohere.ranker.CohereRanker" ,
155
147
"init_parameters" : {
156
- "model" : "rerank-multilingual-v2 .0" ,
148
+ "model" : "rerank-multilingual-v3 .0" ,
157
149
"api_key" : {"env_vars" : ["COHERE_API_KEY" , "CO_API_KEY" ], "strict" : True , "type" : "env_var" },
158
150
"top_k" : 2 ,
159
- "max_chunks_per_doc" : 50 ,
160
151
"max_tokens_per_doc" : 100 ,
161
152
},
162
153
}
0 commit comments