Skip to content

Commit 1231a31

Browse files
dont use deprecated models (#696)
1 parent db36582 commit 1231a31

File tree

3 files changed

+18
-125
lines changed

3 files changed

+18
-125
lines changed

tests/test_async_client.py

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ async def test_context_manager(self) -> None:
2525

2626
async def test_chat(self) -> None:
2727
chat = await self.co.chat(
28+
model="command-a-03-2025",
2829
chat_history=[
2930
UserMessage(
3031
message="Who discovered gravity?"),
3132
ChatbotMessage(message="The man who is widely credited with discovering "
3233
"gravity is Sir Isaac Newton")
3334
],
3435
message="What year was he born?",
35-
connectors=[ChatConnector(id="web-search")]
3636
)
3737

3838
print(chat)
3939

4040
async def test_chat_stream(self) -> None:
4141
stream = self.co.chat_stream(
42+
model="command-a-03-2025",
4243
chat_history=[
4344
UserMessage(
4445
message="Who discovered gravity?"),
4546
ChatbotMessage(message="The man who is widely credited with discovering "
4647
"gravity is Sir Isaac Newton")
4748
],
4849
message="What year was he born?",
49-
connectors=[ChatConnector(id="web-search")]
5050
)
5151

5252
events = set()
@@ -218,75 +218,22 @@ async def test_save_load(self) -> None:
218218

219219
await self.co.datasets.delete(my_dataset.id or "")
220220

221-
async def test_summarize(self) -> None:
222-
text = (
223-
"Ice cream is a sweetened frozen food typically eaten as a snack or dessert. "
224-
"It may be made from milk or cream and is flavoured with a sweetener, "
225-
"either sugar or an alternative, and a spice, such as cocoa or vanilla, "
226-
"or with fruit such as strawberries or peaches. "
227-
"It can also be made by whisking a flavored cream base and liquid nitrogen together. "
228-
"Food coloring is sometimes added, in addition to stabilizers. "
229-
"The mixture is cooled below the freezing point of water and stirred to incorporate air spaces "
230-
"and to prevent detectable ice crystals from forming. The result is a smooth, "
231-
"semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). "
232-
"It becomes more malleable as its temperature increases.\n\n"
233-
"The meaning of the name \"ice cream\" varies from one country to another. "
234-
"In some countries, such as the United States, \"ice cream\" applies only to a specific variety, "
235-
"and most governments regulate the commercial use of the various terms according to the "
236-
"relative quantities of the main ingredients, notably the amount of cream. "
237-
"Products that do not meet the criteria to be called ice cream are sometimes labelled "
238-
"\"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, "
239-
"one word is used fo\r all variants. Analogues made from dairy alternatives, "
240-
"such as goat's or sheep's milk, or milk substitutes "
241-
"(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are "
242-
"lactose intolerant, allergic to dairy protein or vegan."
243-
)
244-
245-
response = await self.co.summarize(
246-
text=text,
247-
)
248-
249-
print(response)
250-
251221
async def test_tokenize(self) -> None:
252222
response = await self.co.tokenize(
253223
text='tokenize me! :D',
254-
model='command',
224+
model="command-a-03-2025",
255225
offline=False,
256226
)
257227
print(response)
258228

259229
async def test_detokenize(self) -> None:
260230
response = await self.co.detokenize(
261231
tokens=[10104, 12221, 1315, 34, 1420, 69],
262-
model="command",
232+
model="command-a-03-2025",
263233
offline=False,
264234
)
265235
print(response)
266236

267-
@unittest.skipIf(os.getenv("CO_API_URL") is not None, "Doesn't work in staging.")
268-
async def test_connectors_crud(self) -> None:
269-
created_connector = await self.co.connectors.create(
270-
name="Example connector",
271-
url="https://dummy-connector-o5btz7ucgq-uc.a.run.app/search",
272-
service_auth=CreateConnectorServiceAuth(
273-
token="dummy-connector-token",
274-
type="bearer",
275-
)
276-
)
277-
print(created_connector)
278-
279-
connector = await self.co.connectors.get(created_connector.connector.id)
280-
281-
print(connector)
282-
283-
updated_connector = await self.co.connectors.update(
284-
id=connector.connector.id, name="new name")
285-
286-
print(updated_connector)
287-
288-
await self.co.connectors.delete(created_connector.connector.id)
289-
290237
@unittest.skipIf(os.getenv("CO_API_URL") is not None, "Doesn't work in staging.")
291238
async def test_tool_use(self) -> None:
292239
tools = [
@@ -347,7 +294,7 @@ async def test_tool_use(self) -> None:
347294
tools=tools,
348295
tool_results=tool_results,
349296
force_single_step=True,
350-
model="command-nightly",
297+
model="command-a-03-2025",
351298
)
352299

353300
self.assertEqual(cited_response.documents, [
@@ -362,21 +309,21 @@ async def test_tool_use(self) -> None:
362309

363310
async def test_local_tokenize(self) -> None:
364311
response = await self.co.tokenize(
365-
model="command",
312+
model="command-a-03-2025",
366313
text="tokenize me! :D"
367314
)
368315
print(response)
369316

370317
async def test_local_detokenize(self) -> None:
371318
response = await self.co.detokenize(
372-
model="command",
319+
model="command-a-03-2025",
373320
tokens=[10104, 12221, 1315, 34, 1420, 69]
374321
)
375322
print(response)
376323

377324
async def test_tokenize_async_context_with_sync_client(self) -> None:
378325
# Test that the sync client can be used in an async context.
379326
co = cohere.Client(timeout=10000)
380-
print(co.tokenize(model="command", text="tokenize me! :D"))
381-
print(co.detokenize(model="command", tokens=[
327+
print(co.tokenize(model="command-a-03-2025", text="tokenize me! :D"))
328+
print(co.detokenize(model="command-a-03-2025", tokens=[
382329
10104, 12221, 1315, 34, 1420, 69]))

tests/test_client.py

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def test_chat(self) -> None:
3131
"gravity is Sir Isaac Newton")
3232
],
3333
message="What year was he born?",
34-
connectors=[ChatConnector(id="web-search")]
3534
)
3635

3736
print(chat)
@@ -45,7 +44,6 @@ def test_chat_stream(self) -> None:
4544
"gravity is Sir Isaac Newton")
4645
],
4746
message="What year was he born?",
48-
connectors=[ChatConnector(id="web-search")]
4947
)
5048

5149
events = set()
@@ -257,74 +255,22 @@ def test_save_load(self) -> None:
257255

258256
co.datasets.delete(my_dataset.id or "")
259257

260-
def test_summarize(self) -> None:
261-
text = (
262-
"Ice cream is a sweetened frozen food typically eaten as a snack or dessert. "
263-
"It may be made from milk or cream and is flavoured with a sweetener, "
264-
"either sugar or an alternative, and a spice, such as cocoa or vanilla, "
265-
"or with fruit such as strawberries or peaches. "
266-
"It can also be made by whisking a flavored cream base and liquid nitrogen together. "
267-
"Food coloring is sometimes added, in addition to stabilizers. "
268-
"The mixture is cooled below the freezing point of water and stirred to incorporate air spaces "
269-
"and to prevent detectable ice crystals from forming. The result is a smooth, "
270-
"semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). "
271-
"It becomes more malleable as its temperature increases.\n\n"
272-
"The meaning of the name \"ice cream\" varies from one country to another. "
273-
"In some countries, such as the United States, \"ice cream\" applies only to a specific variety, "
274-
"and most governments regulate the commercial use of the various terms according to the "
275-
"relative quantities of the main ingredients, notably the amount of cream. "
276-
"Products that do not meet the criteria to be called ice cream are sometimes labelled "
277-
"\"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, "
278-
"one word is used fo\r all variants. Analogues made from dairy alternatives, "
279-
"such as goat's or sheep's milk, or milk substitutes "
280-
"(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are "
281-
"lactose intolerant, allergic to dairy protein or vegan."
282-
)
283-
284-
response = co.summarize(
285-
text=text,
286-
)
287-
288-
print(response)
289-
290258
def test_tokenize(self) -> None:
291259
response = co.tokenize(
292260
text='tokenize me! :D',
293-
model='command',
261+
model='command-a-03-2025',
294262
offline=False,
295263
)
296264
print(response)
297265

298266
def test_detokenize(self) -> None:
299267
response = co.detokenize(
300268
tokens=[10104, 12221, 1315, 34, 1420, 69],
301-
model="command",
269+
model="command-a-03-2025",
302270
offline=False,
303271
)
304272
print(response)
305273

306-
@unittest.skipIf(os.getenv("CO_API_URL") is not None, "Doesn't work in staging.")
307-
def test_connectors_crud(self) -> None:
308-
created_connector = co.connectors.create(
309-
name="Example connector",
310-
url="https://dummy-connector-o5btz7ucgq-uc.a.run.app/search",
311-
service_auth=CreateConnectorServiceAuth(
312-
token="dummy-connector-token",
313-
type="bearer",
314-
)
315-
)
316-
print(created_connector)
317-
318-
connector = co.connectors.get(created_connector.connector.id)
319-
320-
print(connector)
321-
322-
updated_connector = co.connectors.update(
323-
id=connector.connector.id, name="new name")
324-
325-
print(updated_connector)
326-
327-
co.connectors.delete(created_connector.connector.id)
328274

329275
@unittest.skipIf(os.getenv("CO_API_URL") is not None, "Doesn't work in staging.")
330276
def test_tool_use(self) -> None:
@@ -401,14 +347,14 @@ def test_tool_use(self) -> None:
401347

402348
def test_local_tokenize(self) -> None:
403349
response = co.tokenize(
404-
model="command",
350+
model="command-a-03-2025",
405351
text="tokenize me! :D"
406352
)
407353
print(response)
408354

409355
def test_local_detokenize(self) -> None:
410356
response = co.detokenize(
411-
model="command",
357+
model="command-a-03-2025",
412358
tokens=[10104, 12221, 1315, 34, 1420, 69]
413359
)
414360
print(response)

tests/test_client_v2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class TestClientV2(unittest.TestCase):
1515

1616
def test_chat(self) -> None:
1717
response = co.chat(
18-
model="command-r-plus", messages=[cohere.UserChatMessageV2(content="hello world!")])
18+
model="command-a-03-2025", messages=[cohere.UserChatMessageV2(content="hello world!")])
1919

2020
print(response.message)
2121

2222
def test_chat_stream(self) -> None:
2323
stream = co.chat_stream(
24-
model="command-r-plus", messages=[cohere.UserChatMessageV2(content="hello world!")])
24+
model="command-a-03-2025", messages=[cohere.UserChatMessageV2(content="hello world!")])
2525

2626
events = set()
2727

@@ -49,7 +49,7 @@ def test_chat_documents(self) -> None:
4949
messages=[cohere.UserChatMessageV2(
5050
content=[cohere.TextContent(text="how many widges were sold in 2020?")],
5151
)],
52-
model="command-r-plus",
52+
model="command-a-03-2025",
5353
documents=documents,
5454
)
5555

@@ -76,7 +76,7 @@ def test_chat_tools(self) -> None:
7676
messages: cohere.ChatMessages = [
7777
cohere.UserChatMessageV2(content="what is the weather in Toronto?")
7878
]
79-
res = co.chat(model="command-r-plus", tools=tools, messages=messages)
79+
res = co.chat(model="command-a-03-2025", tools=tools, messages=messages)
8080

8181
# call the get_weather tool
8282
tool_result = {"temperature": "30C"}
@@ -88,5 +88,5 @@ def test_chat_tools(self) -> None:
8888
messages.append(cohere.ToolChatMessageV2(
8989
tool_call_id=res.message.tool_calls[0].id, content=list(tool_content)))
9090

91-
res = co.chat(tools=tools, messages=messages, model="command-r-plus")
91+
res = co.chat(tools=tools, messages=messages, model="command-a-03-2025")
9292
print(res.message)

0 commit comments

Comments
 (0)