-
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
7e1d1f7
commit fa70d55
Showing
206 changed files
with
17,391 additions
and
0 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,9 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
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,5 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build |
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,13 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/chat \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"chat_history": [ | ||
{"role": "USER", "message": "Who discovered gravity?"}, | ||
{"role": "CHATBOT", "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton"} | ||
], | ||
"message": "What year was he born?", | ||
"connectors": [{"id": "web-search"}] | ||
}' |
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,20 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/classify \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"inputs": ["Confirm your email address", "hey i need u to send some $"], | ||
"examples": [ | ||
{"text": "Dermatologists don'\''t like her!","label": "Spam"}, | ||
{"text": "'\''Hello, open to this?'\''","label": "Spam"}, | ||
{"text": "I need help please wire me $1000 right now","label": "Spam"}, | ||
{"text": "Nice to know you ;)","label": "Spam"}, | ||
{"text": "Please help me?","label": "Spam"}, | ||
{"text": "Your parcel will be delivered today","label": "Not spam"}, | ||
{"text": "Review changes to our Terms and Conditions","label": "Not spam"}, | ||
{"text": "Weekly sync notes","label": "Not spam"}, | ||
{"text": "'\''Re: Follow up from today'\''s meeting'\''","label": "Not spam"}, | ||
{"text": "Pre-read for tomorrow","label": "Not spam"} | ||
] | ||
}' |
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,9 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/connectors \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"name": "Example connector", | ||
"url": "https://connector-example.com/search" | ||
}' |
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,4 @@ | ||
curl --request DELETE \ | ||
--url https://api.cohere.com/v1/connectors/id \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/connectors/id \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,9 @@ | ||
curl --request PATCH \ | ||
--url https://api.cohere.com/v1/connectors/id \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"name": "new name", | ||
"url": "https://example.com/search" | ||
}' |
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,4 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/connectors/id/oauth/authorize \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/connectors \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,5 @@ | ||
curl --request DELETE \ | ||
--url https://api.cohere.com/v1/datasets/id \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/datasets \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,5 @@ | ||
curl --request POST \ | ||
--url "https://api.cohere.com/v1/datasets?name=my-dataset&type=generative-finetune-input" \ | ||
--header 'Content-Type: multipart/form-data' \ | ||
--header "Authorization: Bearer $CO_API_KEY" \ | ||
--form file=@./path/to/file.jsonl |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/datasets/usage \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,9 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/detokenize \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"model": "command", | ||
"tokens": [8466, 5169, 2594, 8, 2792, 43] | ||
}' |
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,5 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/embed-jobs/id/cancel \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/embed-jobs \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,9 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/embed-jobs \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"model": "embed-english-v3.0", | ||
"dataset_id": "my-dataset" | ||
}' |
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,10 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/embed \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"model": "embed-english-v3.0", | ||
"texts": ["hello", "goodbye"], | ||
"input_type": "classification" | ||
}' |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/embed-jobs/id \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"name": "test-finetuned-model", | ||
"settings": { | ||
"base_model": { | ||
"base_type": "BASE_TYPE_GENERATIVE", | ||
}, | ||
"dataset_id": "test-dataset-id" | ||
} | ||
}' |
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,4 @@ | ||
curl --request DELETE \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models/test-id \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models/test-id \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models/test-id/events \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models/test-id/training-step-metrics \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,6 @@ | ||
curl --request PATCH \ | ||
--url https://api.cohere.com/v1/finetuning/finetuned-models/test-id \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ "name": "new name" }' |
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,8 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/generate \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"prompt": "Please explain to me how LLMs work" | ||
}' |
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,4 @@ | ||
curl --request GET \ | ||
--url https://api.cohere.com/v1/models \ | ||
--header 'accept: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" |
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,15 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/rerank \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"model": "rerank-english-v3.0", | ||
"query": "What is the capital of the United States?", | ||
"top_n": 3, | ||
"documents": ["Carson City is the capital city of the American state of Nevada.", | ||
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", | ||
"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", | ||
"Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", | ||
"Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."] | ||
}' |
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,8 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/summarize \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"text": "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. It may be made from milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Food coloring is sometimes added, in addition to stabilizers. The mixture is cooled below the freezing point of water and stirred to incorporate air spaces and to prevent detectable ice crystals from forming. The result is a smooth, semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). It becomes more malleable as its temperature increases.\n\nThe meaning of the name \"ice cream\" varies from one country to another. In some countries, such as the United States, \"ice cream\" applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients, notably the amount of cream. Products that do not meet the criteria to be called ice cream are sometimes labelled \"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, one word is used for all variants. Analogues made from dairy alternatives, such as goat'\''s or sheep'\''s milk, or milk substitutes (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are lactose intolerant, allergic to dairy protein or vegan." | ||
}' |
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,9 @@ | ||
curl --request POST \ | ||
--url https://api.cohere.com/v1/tokenize \ | ||
--header 'accept: application/json' \ | ||
--header 'content-type: application/json' \ | ||
--header "Authorization: bearer $CO_API_KEY" \ | ||
--data '{ | ||
"model": "command", | ||
"text": "tokenize me! :D" | ||
}' |
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,42 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
cohere "github.com/cohere-ai/cohere-go/v2" | ||
client "github.com/cohere-ai/cohere-go/v2/client" | ||
) | ||
|
||
func main() { | ||
co := client.NewClient(client.WithToken("<<apiKey>>")) | ||
|
||
resp, err := co.Chat( | ||
context.TODO(), | ||
&cohere.ChatRequest{ | ||
ChatHistory: []*cohere.Message{ | ||
{ | ||
Role: "USER", | ||
User: &cohere.ChatMessage{ | ||
Message: "Who discovered gravity?", | ||
}, | ||
}, | ||
{ | ||
Role: "CHATBOT", | ||
Chatbot: &cohere.ChatMessage{ | ||
Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", | ||
}, | ||
}}, | ||
Message: "What year was he born?", | ||
Connectors: []*cohere.ChatConnector{ | ||
{Id: "web-search"}, | ||
}, | ||
}, | ||
) | ||
|
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Printf("%+v", resp) | ||
} |
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,61 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"io" | ||
"log" | ||
|
||
cohere "github.com/cohere-ai/cohere-go/v2" | ||
client "github.com/cohere-ai/cohere-go/v2/client" | ||
) | ||
|
||
func main() { | ||
co := client.NewClient(client.WithToken("<<apiKey>>")) | ||
|
||
resp, err := co.ChatStream( | ||
context.TODO(), | ||
&cohere.ChatStreamRequest{ | ||
ChatHistory: []*cohere.Message{ | ||
{ | ||
Role: "USER", | ||
User: &cohere.ChatMessage{ | ||
Message: "Who discovered gravity?", | ||
}, | ||
}, | ||
{ | ||
Role: "CHATBOT", | ||
Chatbot: &cohere.ChatMessage{ | ||
Message: "The man who is widely credited with discovering gravity is Sir Isaac Newton", | ||
}, | ||
}}, | ||
Message: "What year was he born?", | ||
Connectors: []*cohere.ChatConnector{ | ||
{Id: "web-search"}, | ||
}, | ||
}, | ||
) | ||
|
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Make sure to close the stream when you're done reading. | ||
// This is easily handled with defer. | ||
defer resp.Close() | ||
|
||
for { | ||
message, err := resp.Recv() | ||
|
||
if errors.Is(err, io.EOF) { | ||
// An io.EOF error means the server is done sending messages | ||
// and should be treated as a success. | ||
break | ||
} | ||
|
||
if message.TextGeneration != nil { | ||
log.Printf("%+v", resp) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.