-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: billytrend-cohere <[email protected]>
- Loading branch information
1 parent
8526713
commit 01a2aa8
Showing
16 changed files
with
735 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { CohereClientV2 } = require('cohere-ai'); | ||
|
||
const cohere = new CohereClientV2({ | ||
token: '<<apiKey>>', | ||
}); | ||
|
||
(async () => { | ||
const response = await cohere.chat({ | ||
model: 'command-r-plus', | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: 'hello world!', | ||
}, | ||
], | ||
}); | ||
|
||
console.log(response); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { CohereClientV2 } = require('cohere-ai'); | ||
|
||
const cohere = new CohereClientV2({ | ||
token: '<<apiKey>>', | ||
}); | ||
|
||
(async () => { | ||
const response = await cohere.chat({ | ||
model: 'command-r-plus', | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ type: 'document', id: '1', document: { text: 'Cohere is the best!' } }, | ||
{ type: 'text', text: "Who's the best?" }, | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
console.log(response); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { CohereClientV2 } = require('cohere-ai'); | ||
|
||
const cohere = new CohereClientV2({ | ||
token: '<<apiKey>>', | ||
}); | ||
|
||
(async () => { | ||
const stream = await cohere.chatStream({ | ||
model: 'command-r-plus', | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: 'hello world!', | ||
}, | ||
], | ||
}); | ||
|
||
for await (const chatEvent of stream) { | ||
if (chatEvent.type === 'content-delta') { | ||
console.log(chatEvent.delta?.message); | ||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { CohereClientV2 } = require('cohere-ai'); | ||
|
||
const cohere = new CohereClientV2({ | ||
token: '<<apiKey>>', | ||
}); | ||
|
||
(async () => { | ||
const response = await cohere.chat({ | ||
model: 'command-r-plus', | ||
tools: [ | ||
{ | ||
type: 'function', | ||
function: { | ||
name: 'query_daily_sales_report', | ||
description: | ||
'Connects to a database to retrieve overall sales volumes and sales information for a given day.', | ||
parameters: { | ||
day: { | ||
description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', | ||
type: 'str', | ||
required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
type: 'function', | ||
function: { | ||
name: 'query_product_catalog', | ||
description: | ||
'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', | ||
parameters: { | ||
category: { | ||
description: 'Retrieves product information data for all products in this category.', | ||
type: 'str', | ||
required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: | ||
"Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?", | ||
}, | ||
], | ||
}); | ||
|
||
console.log(response); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import cohere | ||
import asyncio | ||
|
||
co = cohere.AsyncClientV2("<<apiKey>>") | ||
|
||
|
||
async def main(): | ||
response = await co.chat( | ||
model="command-r-plus", | ||
messages=[ | ||
cohere.v2.ChatMessage2_User( | ||
content="hello world!" | ||
) | ||
] | ||
) | ||
|
||
print(response) | ||
|
||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import cohere | ||
|
||
co = cohere.ClientV2("<<apiKey>>") | ||
|
||
response = co.chat( | ||
model="command-r-plus", | ||
messages=[ | ||
cohere.v2.ChatMessage2_User( | ||
content="hello world!" | ||
) | ||
] | ||
) | ||
|
||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import cohere | ||
|
||
co = cohere.ClientV2("<<apiKey>>") | ||
|
||
response = co.chat( | ||
model="command-r-plus", | ||
messages=[ | ||
cohere.v2.ChatMessage2_User( | ||
content=[ | ||
cohere.v2.DocumentContent( | ||
id=1, | ||
document={'title': 'The best', | ||
'text': 'Cohere is the best!'} | ||
), | ||
cohere.v2.TextContent(text="Who's the best?"), | ||
] | ||
) | ||
] | ||
) | ||
|
||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import cohere | ||
|
||
co = cohere.ClientV2("<<apiKey>>") | ||
|
||
response = co.chat_stream( | ||
model="command-r-plus", | ||
messages=[ | ||
cohere.v2.ChatMessage2_User( | ||
content="hello world!" | ||
) | ||
] | ||
) | ||
|
||
for event in response: | ||
if event.event_type == "text-generation": | ||
print(event.text, end='') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import cohere | ||
|
||
co = cohere.Client("<<apiKey>>") | ||
|
||
response = co.chat( | ||
model="command-r-plus", | ||
tools=[ | ||
cohere.v2.Tool2(type='function', function={ | ||
"name": 'query_daily_sales_report', | ||
"description": 'Connects to a database to retrieve overall sales volumes and sales information for a given day.', | ||
"parameters": { | ||
"day": { | ||
"description": 'Retrieves sales data for this day, formatted as YYYY-MM-DD.', | ||
"type": 'str', | ||
"required": True, | ||
}, | ||
} | ||
}), | ||
cohere.v2.Tool2(type='function', function={ | ||
"name": 'query_product_catalog', | ||
"description": 'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.', | ||
"parameters": { | ||
"category": { | ||
"description": 'Retrieves product information data for all products in this category.', | ||
"type": 'str', | ||
"required": True, | ||
}, | ||
} | ||
}) | ||
], | ||
messages=[ | ||
cohere.v2.ChatMessage2_User( | ||
content="Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?" | ||
) | ||
] | ||
) | ||
|
||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
snippets/snippets/python/finetuning/update-finetuned-model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
from cohere.finetuning import ( | ||
BaseModel, | ||
Settings, | ||
) | ||
import cohere | ||
|
||
co = cohere.Client("<<apiKey>>") | ||
|