File tree Expand file tree Collapse file tree 2 files changed +8
-18
lines changed
Expand file tree Collapse file tree 2 files changed +8
-18
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ using namespace std;
3333using namespace cohere ;
3434
3535int main () {
36- Cohere co = Cohere( "YOUR_API_KEY");
36+ Cohere co{ "YOUR_API_KEY"}; // can rewrite to make it more "Pythonic"
3737 Json chat = co.Chat->chat(
3838 "hello world!",
3939 "command"
@@ -49,7 +49,7 @@ For chat streams, you can perform the following:
4949
5050``` cpp
5151int main () {
52- Cohere co = Cohere( );
52+ Cohere co("YOUR_API_KEY" );
5353 Json chat_stream = co.Chat->chat(
5454 "Tell me about Terry Fox",
5555 "command",
Original file line number Diff line number Diff line change @@ -23,23 +23,13 @@ int main() {
2323 // Json words = co.Tokens->detokenize({40723,21641}, "command");
2424 // cout << words.dump() << endl;
2525
26- Cohere co = Cohere () ; // enviroment variable: CO_API_KEY
26+ Cohere co; // enviroment variable: CO_API_KEY
2727
28- ifstream ifs{" prompts.txt" };
29-
30- vector<string> prompts;
31- string prompt;
32-
33- while (ifs >> prompt) {
34- prompts.push_back (prompt);
35- }
36-
37- cout << " {" << prompts[0 ] << " }" << endl;
38-
39- for (auto &p: prompts) {
40- Json chat = co.Chat ->chat (p, " command" );
41- cout << chat << endl;
42- }
28+ Json chat = co.Chat ->chat (
29+ " hello world!" ,
30+ " command"
31+ );
4332
33+ cout << chat.dump () << endl;
4434 return 0 ;
4535}
You can’t perform that action at this time.
0 commit comments