Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌿 Fern Regeneration -- February 7, 2024 #63

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .fernignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Specify files that shouldn't be modified by Fern
README.md
banner.png
LICENSE
LICENSE
.github/workflows/e2e.yml
25 changes: 25 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI
on:
pull_request: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go 1.x.x
uses: actions/setup-go@v4
with:
go-version: 1.x.x
- name: Install testing dependencies here so we dont have to edit the go.mod file
run: |
go get .
go get golang.org/x/tools/go/[email protected]
go get golang.org/x/[email protected]
go get golang.org/x/[email protected]
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test -v ./...
env:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}

68 changes: 22 additions & 46 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type Client struct {
caller *core.Caller
header http.Header

EmbedJobs *embedjobs.Client
Datasets *datasets.Client
Connectors *connectors.Client
EmbedJobs *embedjobs.Client
}

func NewClient(opts ...core.ClientOption) *Client {
Expand All @@ -35,21 +35,21 @@ func NewClient(opts ...core.ClientOption) *Client {
baseURL: options.BaseURL,
caller: core.NewCaller(options.HTTPClient),
header: options.ToHeader(),
EmbedJobs: embedjobs.NewClient(opts...),
Datasets: datasets.NewClient(opts...),
Connectors: connectors.NewClient(opts...),
EmbedJobs: embedjobs.NewClient(opts...),
}
}

// The `chat` endpoint allows users to have conversations with a Large Language Model (LLM) from Cohere. Users can send messages as part of a persisted conversation using the `conversation_id` parameter, or they can pass in their own conversation history using the `chat_history` parameter.
//
// The endpoint features additional parameters such as [connectors](https://docs.cohere.com/docs/connectors) and `documents` that enable conversations enriched by external knowledge. We call this ["Retrieval Augmented Generation"](https://docs.cohere.com/docs/retrieval-augmented-generation-rag), or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see [this guide](https://docs.cohere.com/docs/cochat-beta).
func (c *Client) ChatStream(ctx context.Context, request *v2.ChatStreamRequest) (*core.Stream[v2.StreamedChatResponse], error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "chat"
endpointURL := baseURL + "/" + "v1/chat"

streamer := core.NewStreamer[v2.StreamedChatResponse](c.caller)
return streamer.Stream(
Expand All @@ -67,11 +67,11 @@ func (c *Client) ChatStream(ctx context.Context, request *v2.ChatStreamRequest)
//
// The endpoint features additional parameters such as [connectors](https://docs.cohere.com/docs/connectors) and `documents` that enable conversations enriched by external knowledge. We call this ["Retrieval Augmented Generation"](https://docs.cohere.com/docs/retrieval-augmented-generation-rag), or "RAG". For a full breakdown of the Chat API endpoint, document and connector modes, and streaming (with code samples), see [this guide](https://docs.cohere.com/docs/cochat-beta).
func (c *Client) Chat(ctx context.Context, request *v2.ChatRequest) (*v2.NonStreamedChatResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "chat"
endpointURL := baseURL + "/" + "v1/chat"

var response *v2.NonStreamedChatResponse
if err := c.caller.Call(
Expand All @@ -91,11 +91,11 @@ func (c *Client) Chat(ctx context.Context, request *v2.ChatRequest) (*v2.NonStre

// This endpoint generates realistic text conditioned on a given input.
func (c *Client) GenerateStream(ctx context.Context, request *v2.GenerateStreamRequest) (*core.Stream[v2.GenerateStreamedResponse], error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "generate"
endpointURL := baseURL + "/" + "v1/generate"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -138,11 +138,11 @@ func (c *Client) GenerateStream(ctx context.Context, request *v2.GenerateStreamR

// This endpoint generates realistic text conditioned on a given input.
func (c *Client) Generate(ctx context.Context, request *v2.GenerateRequest) (*v2.Generation, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "generate"
endpointURL := baseURL + "/" + "v1/generate"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -193,11 +193,11 @@ func (c *Client) Generate(ctx context.Context, request *v2.GenerateRequest) (*v2
//
// If you want to learn more how to use the embedding model, have a look at the [Semantic Search Guide](/docs/semantic-search).
func (c *Client) Embed(ctx context.Context, request *v2.EmbedRequest) (*v2.EmbedResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "embed"
endpointURL := baseURL + "/" + "v1/embed"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -244,11 +244,11 @@ func (c *Client) Embed(ctx context.Context, request *v2.EmbedRequest) (*v2.Embed

// This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score.
func (c *Client) Rerank(ctx context.Context, request *v2.RerankRequest) (*v2.RerankResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "rerank"
endpointURL := baseURL + "/" + "v1/rerank"

var response *v2.RerankResponse
if err := c.caller.Call(
Expand All @@ -269,11 +269,11 @@ func (c *Client) Rerank(ctx context.Context, request *v2.RerankRequest) (*v2.Rer
// This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided `examples` of text + label pairs as a reference.
// Note: [Fine-tuned models](https://docs.cohere.com/docs/classify-fine-tuning) trained on classification examples don't require the `examples` parameter to be passed in explicitly.
func (c *Client) Classify(ctx context.Context, request *v2.ClassifyRequest) (*v2.ClassifyResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "classify"
endpointURL := baseURL + "/" + "v1/classify"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -318,37 +318,13 @@ func (c *Client) Classify(ctx context.Context, request *v2.ClassifyRequest) (*v2
return response, nil
}

// This endpoint identifies which language each of the provided texts is written in.
func (c *Client) DetectLanguage(ctx context.Context, request *v2.DetectLanguageRequest) (*v2.DetectLanguageResponse, error) {
baseURL := "https://api.cohere.ai/v1"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "detect-language"

var response *v2.DetectLanguageResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodPost,
Headers: c.header,
Request: request,
Response: &response,
},
); err != nil {
return nil, err
}
return response, nil
}

// This endpoint generates a summary in English for a given text.
func (c *Client) Summarize(ctx context.Context, request *v2.SummarizeRequest) (*v2.SummarizeResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "summarize"
endpointURL := baseURL + "/" + "v1/summarize"

var response *v2.SummarizeResponse
if err := c.caller.Call(
Expand All @@ -368,11 +344,11 @@ func (c *Client) Summarize(ctx context.Context, request *v2.SummarizeRequest) (*

// This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page.
func (c *Client) Tokenize(ctx context.Context, request *v2.TokenizeRequest) (*v2.TokenizeResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "tokenize"
endpointURL := baseURL + "/" + "v1/tokenize"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -419,11 +395,11 @@ func (c *Client) Tokenize(ctx context.Context, request *v2.TokenizeRequest) (*v2

// This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page.
func (c *Client) Detokenize(ctx context.Context, request *v2.DetokenizeRequest) (*v2.DetokenizeResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "detokenize"
endpointURL := baseURL + "/" + "v1/detokenize"

var response *v2.DetokenizeResponse
if err := c.caller.Call(
Expand Down
24 changes: 12 additions & 12 deletions connectors/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func NewClient(opts ...core.ClientOption) *Client {

// Returns a list of connectors ordered by descending creation date (newer first). See ['Managing your Connector'](https://docs.cohere.com/docs/managing-your-connector) for more information.
func (c *Client) List(ctx context.Context, request *v2.ConnectorsListRequest) (*v2.ListConnectorsResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "connectors"
endpointURL := baseURL + "/" + "v1/connectors"

queryParams := make(url.Values)
if request.Limit != nil {
Expand Down Expand Up @@ -96,11 +96,11 @@ func (c *Client) List(ctx context.Context, request *v2.ConnectorsListRequest) (*

// Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See ['Creating and Deploying a Connector'](https://docs.cohere.com/docs/creating-and-deploying-a-connector) for more information.
func (c *Client) Create(ctx context.Context, request *v2.CreateConnectorRequest) (*v2.CreateConnectorResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "connectors"
endpointURL := baseURL + "/" + "v1/connectors"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -156,11 +156,11 @@ func (c *Client) Create(ctx context.Context, request *v2.CreateConnectorRequest)
//
// The ID of the connector to retrieve.
func (c *Client) Get(ctx context.Context, id string) (*v2.GetConnectorResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connectors/%v", id)
endpointURL := fmt.Sprintf(baseURL+"/"+"v1/connectors/%v", id)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -215,11 +215,11 @@ func (c *Client) Get(ctx context.Context, id string) (*v2.GetConnectorResponse,
//
// The ID of the connector to delete.
func (c *Client) Delete(ctx context.Context, id string) (v2.DeleteConnectorResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connectors/%v", id)
endpointURL := fmt.Sprintf(baseURL+"/"+"v1/connectors/%v", id)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -281,11 +281,11 @@ func (c *Client) Delete(ctx context.Context, id string) (v2.DeleteConnectorRespo
//
// The ID of the connector to update.
func (c *Client) Update(ctx context.Context, id string, request *v2.UpdateConnectorRequest) (*v2.UpdateConnectorResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connectors/%v", id)
endpointURL := fmt.Sprintf(baseURL+"/"+"v1/connectors/%v", id)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
Expand Down Expand Up @@ -348,11 +348,11 @@ func (c *Client) Update(ctx context.Context, id string, request *v2.UpdateConnec
//
// The ID of the connector to authorize.
func (c *Client) OAuthAuthorize(ctx context.Context, id string, request *v2.ConnectorsOAuthAuthorizeRequest) (*v2.OAuthAuthorizeResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connectors/%v/oauth/authorize", id)
endpointURL := fmt.Sprintf(baseURL+"/"+"v1/connectors/%v/oauth/authorize", id)

queryParams := make(url.Values)
if request.AfterTokenRedirect != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/client_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
headers := c.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/cohere-ai/cohere-go/v2")
headers.Set("X-Fern-SDK-Version", "v2.5.1")
headers.Set("X-Fern-SDK-Version", "v2.5.2")
return headers
}
20 changes: 10 additions & 10 deletions datasets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func NewClient(opts ...core.ClientOption) *Client {

// List datasets that have been created.
func (c *Client) List(ctx context.Context, request *v2.DatasetsListRequest) (*v2.DatasetsListResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "datasets"
endpointURL := baseURL + "/" + "v1/datasets"

queryParams := make(url.Values)
if request.DatasetType != nil {
Expand Down Expand Up @@ -78,11 +78,11 @@ func (c *Client) List(ctx context.Context, request *v2.DatasetsListRequest) (*v2

// Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information.
func (c *Client) Create(ctx context.Context, data io.Reader, evalData io.Reader, request *v2.DatasetsCreateRequest) (*v2.DatasetsCreateResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "datasets"
endpointURL := baseURL + "/" + "v1/datasets"

queryParams := make(url.Values)
if request.Name != nil {
Expand Down Expand Up @@ -160,11 +160,11 @@ func (c *Client) Create(ctx context.Context, data io.Reader, evalData io.Reader,

// View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users.
func (c *Client) GetUsage(ctx context.Context) (*v2.DatasetsGetUsageResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "datasets/usage"
endpointURL := baseURL + "/" + "v1/datasets/usage"

var response *v2.DatasetsGetUsageResponse
if err := c.caller.Call(
Expand All @@ -183,11 +183,11 @@ func (c *Client) GetUsage(ctx context.Context) (*v2.DatasetsGetUsageResponse, er

// Retrieve a dataset by ID. See ['Datasets'](https://docs.cohere.com/docs/datasets) for more information.
func (c *Client) Get(ctx context.Context, id string) (*v2.DatasetsGetResponse, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"datasets/%v", id)
endpointURL := fmt.Sprintf(baseURL+"/"+"v1/datasets/%v", id)

var response *v2.DatasetsGetResponse
if err := c.caller.Call(
Expand All @@ -206,11 +206,11 @@ func (c *Client) Get(ctx context.Context, id string) (*v2.DatasetsGetResponse, e

// Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually.
func (c *Client) Delete(ctx context.Context, id string) (map[string]interface{}, error) {
baseURL := "https://api.cohere.ai/v1"
baseURL := "https://api.cohere.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"datasets/%v", id)
endpointURL := fmt.Sprintf(baseURL+"/"+"v1/datasets/%v", id)

var response map[string]interface{}
if err := c.caller.Call(
Expand Down
Loading
Loading