Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Apr 4, 2024
1 parent bde3a73 commit 808f7f8
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 145 deletions.
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
headers := r.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.7.0")
headers.Set("X-Fern-SDK-Version", "v2.7.1")
return headers
}

Expand Down
2 changes: 1 addition & 1 deletion datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type DatasetsCreateRequest struct {
// The name of the uploaded dataset.
Name string `json:"-" url:"name"`
// The dataset type, which is used to validate the data.
// The dataset type, which is used to validate the data. Valid types are `embed-input`, `reranker-finetune-input`, `prompt-completion-finetune-input`, `single-label-classification-finetune-input`, `chat-finetune-input`, and `multi-label-classification-finetune-input`.
Type DatasetType `json:"-" url:"type,omitempty"`
// Indicates if the original file should be stored.
KeepOriginalFile *bool `json:"-" url:"keep_original_file,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions embed_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ type CreateEmbedJobRequest struct {
InputType EmbedInputType `json:"input_type,omitempty" url:"input_type,omitempty"`
// The name of the embed job.
Name *string `json:"name,omitempty" url:"name,omitempty"`
// Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types.
//
// * `"float"`: Use this when you want to get back the default float embeddings. Valid for all models.
// * `"int8"`: Use this when you want to get back signed int8 embeddings. Valid for only v3 models.
// * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models.
// * `"binary"`: Use this when you want to get back signed binary embeddings. Valid for only v3 models.
// * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Valid for only v3 models.
EmbeddingTypes []EmbeddingType `json:"embedding_types,omitempty" url:"embedding_types,omitempty"`
// One of `START|END` to specify how the API will handle inputs longer than the maximum token length.
//
// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
Expand Down
71 changes: 71 additions & 0 deletions models/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
context "context"
json "encoding/json"
errors "errors"
fmt "fmt"
v2 "github.com/cohere-ai/cohere-go/v2"
core "github.com/cohere-ai/cohere-go/v2/core"
option "github.com/cohere-ai/cohere-go/v2/option"
Expand Down Expand Up @@ -34,6 +35,76 @@ func NewClient(opts ...option.RequestOption) *Client {
}
}

// Returns the details of a model, provided its name.
func (c *Client) Get(
ctx context.Context,
model string,
opts ...option.RequestOption,
) (*v2.GetModelResponse, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.cohere.ai/v1"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"models/%v", model)

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(v2.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 429:
value := new(v2.TooManyRequestsError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 500:
value := new(v2.InternalServerError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *v2.GetModelResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodGet,
MaxAttempts: options.MaxAttempts,
Headers: headers,
Client: options.HTTPClient,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}

// Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models.
func (c *Client) List(
ctx context.Context,
Expand Down
Loading

0 comments on commit 808f7f8

Please sign in to comment.