Skip to content

Commit

Permalink
SDK regeneration (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Apr 26, 2024
1 parent 41e65d0 commit bd13c06
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 46 deletions.
4 changes: 4 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
option "github.com/cohere-ai/cohere-go/v2/option"
io "io"
http "net/http"
os "os"
)

type Client struct {
Expand All @@ -33,6 +34,9 @@ type Client struct {

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
if options.Token == "" {
options.Token = os.Getenv("CO_API_KEY")
}
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
Expand Down
4 changes: 4 additions & 0 deletions connectors/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
option "github.com/cohere-ai/cohere-go/v2/option"
io "io"
http "net/http"
os "os"
)

type Client struct {
Expand All @@ -23,6 +24,9 @@ type Client struct {

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
if options.Token == "" {
options.Token = os.Getenv("CO_API_KEY")
}
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
Expand Down
2 changes: 1 addition & 1 deletion core/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func isEmptyValue(v reflect.Value) bool {
IsZero() bool
}

if !v.IsNil() {
if !v.IsZero() {
if z, ok := v.Interface().(zeroable); ok {
return z.IsZero()
}
Expand Down
14 changes: 14 additions & 0 deletions core/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,18 @@ func TestQueryValues(t *testing.T) {
require.NoError(t, err)
assert.Empty(t, values.Encode())
})

t.Run("omitempty with non-pointer zero value", func(t *testing.T) {
type enum string

type example struct {
Enum enum `json:"enum,omitempty" url:"enum,omitempty"`
}

values, err := QueryValues(
&example{},
)
require.NoError(t, err)
assert.Empty(t, values.Encode())
})
}
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.1")
headers.Set("X-Fern-SDK-Version", "v2.7.3")
return headers
}

Expand Down
6 changes: 5 additions & 1 deletion datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type DatasetsCreateRequest struct {
// The name of the uploaded dataset.
Name string `json:"-" url:"name"`
// 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"`
Type DatasetType `json:"-" url:"type"`
// Indicates if the original file should be stored.
KeepOriginalFile *bool `json:"-" url:"keep_original_file,omitempty"`
// Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field.
Expand All @@ -26,6 +26,8 @@ type DatasetsCreateRequest struct {
TextSeparator *string `json:"-" url:"text_separator,omitempty"`
// The delimiter used for .csv uploads.
CsvDelimiter *string `json:"-" url:"csv_delimiter,omitempty"`
// flag to enable dry_run mode
DryRun *bool `json:"-" url:"dry_run,omitempty"`
}

type DatasetsListRequest struct {
Expand All @@ -39,6 +41,8 @@ type DatasetsListRequest struct {
Limit *float64 `json:"-" url:"limit,omitempty"`
// optional offset to start of results
Offset *float64 `json:"-" url:"offset,omitempty"`
// optional filter by validation status
ValidationStatus *DatasetValidationStatus `json:"-" url:"validationStatus,omitempty"`
}

type DatasetsCreateResponse struct {
Expand Down
4 changes: 4 additions & 0 deletions datasets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
io "io"
multipart "mime/multipart"
http "net/http"
os "os"
)

type Client struct {
Expand All @@ -24,6 +25,9 @@ type Client struct {

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
if options.Token == "" {
options.Token = os.Getenv("CO_API_KEY")
}
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
Expand Down
2 changes: 1 addition & 1 deletion embed_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type CreateEmbedJobRequest struct {
Model string `json:"model" url:"model"`
// ID of a [Dataset](https://docs.cohere.com/docs/datasets). The Dataset must be of type `embed-input` and must have a validation status `Validated`
DatasetId string `json:"dataset_id" url:"dataset_id"`
InputType EmbedInputType `json:"input_type,omitempty" url:"input_type,omitempty"`
InputType EmbedInputType `json:"input_type" url:"input_type"`
// 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.
Expand Down
4 changes: 4 additions & 0 deletions embedjobs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
option "github.com/cohere-ai/cohere-go/v2/option"
io "io"
http "net/http"
os "os"
)

type Client struct {
Expand All @@ -23,6 +24,9 @@ type Client struct {

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
if options.Token == "" {
options.Token = os.Getenv("CO_API_KEY")
}
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
Expand Down
7 changes: 5 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (n *NotFoundError) Unwrap() error {
return n.APIError
}

// Status Service Unavailable
type ServiceUnavailableError struct {
*core.APIError
Body *finetuning.Error
Expand All @@ -123,13 +124,14 @@ func (s *ServiceUnavailableError) Unwrap() error {
return s.APIError
}

// Too many requests
type TooManyRequestsError struct {
*core.APIError
Body interface{}
Body *TooManyRequestsErrorBody
}

func (t *TooManyRequestsError) UnmarshalJSON(data []byte) error {
var body interface{}
var body *TooManyRequestsErrorBody
if err := json.Unmarshal(data, &body); err != nil {
return err
}
Expand All @@ -146,6 +148,7 @@ func (t *TooManyRequestsError) Unwrap() error {
return t.APIError
}

// Unauthorized
type UnauthorizedError struct {
*core.APIError
Body *finetuning.Error
Expand Down
4 changes: 4 additions & 0 deletions finetuning/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
option "github.com/cohere-ai/cohere-go/v2/option"
io "io"
http "net/http"
os "os"
)

type Client struct {
Expand All @@ -24,6 +25,9 @@ type Client struct {

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
if options.Token == "" {
options.Token = os.Getenv("CO_API_KEY")
}
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
Expand Down
5 changes: 4 additions & 1 deletion finetuning/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type BaseModel struct {
// read-only. The version of the base model.
Version *string `json:"version,omitempty" url:"version,omitempty"`
// The type of the base model.
BaseType BaseType `json:"base_type,omitempty" url:"base_type,omitempty"`
BaseType BaseType `json:"base_type" url:"base_type"`
// The fine-tuning strategy.
Strategy *Strategy `json:"strategy,omitempty" url:"strategy,omitempty"`

Expand Down Expand Up @@ -174,6 +174,7 @@ func (e *Event) UnmarshalJSON(data []byte) error {
}
*e = Event(unmarshaler.embed)
e.CreatedAt = unmarshaler.CreatedAt.TimePtr()

e._rawJSON = json.RawMessage(data)
return nil
}
Expand Down Expand Up @@ -247,6 +248,7 @@ func (f *FinetunedModel) UnmarshalJSON(data []byte) error {
f.UpdatedAt = unmarshaler.UpdatedAt.TimePtr()
f.CompletedAt = unmarshaler.CompletedAt.TimePtr()
f.LastUsed = unmarshaler.LastUsed.TimePtr()

f._rawJSON = json.RawMessage(data)
return nil
}
Expand Down Expand Up @@ -605,6 +607,7 @@ func (t *TrainingStepMetrics) UnmarshalJSON(data []byte) error {
}
*t = TrainingStepMetrics(unmarshaler.embed)
t.CreatedAt = unmarshaler.CreatedAt.TimePtr()

t._rawJSON = json.RawMessage(data)
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ type ModelsListRequest struct {
PageToken *string `json:"-" url:"page_token,omitempty"`
// When provided, filters the list of models to only those that are compatible with the specified endpoint.
Endpoint *CompatibleEndpoint `json:"-" url:"endpoint,omitempty"`
// When provided, filters the list of models to only the default model to the endpoint. This parameter is only valid when `endpoint` is provided.
DefaultOnly *bool `json:"-" url:"default_only,omitempty"`
}
4 changes: 4 additions & 0 deletions models/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
option "github.com/cohere-ai/cohere-go/v2/option"
io "io"
http "net/http"
os "os"
)

type Client struct {
Expand All @@ -23,6 +24,9 @@ type Client struct {

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
if options.Token == "" {
options.Token = os.Getenv("CO_API_KEY")
}
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
Expand Down
Loading

0 comments on commit bd13c06

Please sign in to comment.