File tree 1 file changed +12
-15
lines changed
1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -23,16 +23,14 @@ pip install cohere
23
23
``` Python
24
24
import cohere
25
25
26
- co = cohere.Client(
27
- api_key = " YOUR_API_KEY" ,
28
- )
26
+ co = cohere.ClientV2()
29
27
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! " }],
33
31
)
34
32
35
- print (chat )
33
+ print (response )
36
34
```
37
35
38
36
> [ !TIP]
@@ -48,17 +46,16 @@ use `chat_stream`.
48
46
``` Python
49
47
import cohere
50
48
51
- co = cohere.Client(
52
- api_key = " YOUR_API_KEY" ,
53
- )
49
+ co = cohere.ClientV2()
54
50
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!" }],
57
54
)
58
55
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 = " " )
62
59
```
63
60
64
61
## Contributing
You can’t perform that action at this time.
0 commit comments