Skip to content

Commit 05fe9e7

Browse files
Update README.md
1 parent 0cbad81 commit 05fe9e7

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

README.md

+12-15
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ pip install cohere
2323
```Python
2424
import cohere
2525

26-
co = cohere.Client(
27-
api_key="YOUR_API_KEY",
28-
)
26+
co = cohere.ClientV2()
2927

30-
chat = co.chat(
31-
message="hello world!",
32-
model="command"
28+
response = co.chat(
29+
model="command-r-plus-08-2024",
30+
messages=[{"role": "user", "content": "hello world!"}],
3331
)
3432

35-
print(chat)
33+
print(response)
3634
```
3735

3836
> [!TIP]
@@ -48,17 +46,16 @@ use `chat_stream`.
4846
```Python
4947
import cohere
5048

51-
co = cohere.Client(
52-
api_key="YOUR_API_KEY",
53-
)
49+
co = cohere.ClientV2()
5450

55-
stream = co.chat_stream(
56-
message="Tell me a short story"
51+
response = co.chat_stream(
52+
model="command-r-plus-08-2024",
53+
messages=[{"role": "user", "content": "hello world!"}],
5754
)
5855

59-
for event in stream:
60-
if event.event_type == "text-generation":
61-
print(event.text, end='')
56+
for event in response:
57+
if event.type == "content-delta":
58+
print(event.delta.message.content.text, end="")
6259
```
6360

6461
## Contributing

0 commit comments

Comments
 (0)