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 -- March 21, 2024 #68

Merged
merged 1 commit into from
Mar 21, 2024
Merged
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
21 changes: 18 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
core "github.com/cohere-ai/cohere-go/v2/core"
datasets "github.com/cohere-ai/cohere-go/v2/datasets"
embedjobs "github.com/cohere-ai/cohere-go/v2/embedjobs"
finetuningclient "github.com/cohere-ai/cohere-go/v2/finetuning/client"
models "github.com/cohere-ai/cohere-go/v2/models"
option "github.com/cohere-ai/cohere-go/v2/option"
io "io"
Expand All @@ -27,6 +28,7 @@ type Client struct {
Datasets *datasets.Client
Connectors *connectors.Client
Models *models.Client
Finetuning *finetuningclient.Client
}

func NewClient(opts ...option.RequestOption) *Client {
Expand All @@ -44,6 +46,7 @@ func NewClient(opts ...option.RequestOption) *Client {
Datasets: datasets.NewClient(opts...),
Connectors: connectors.NewClient(opts...),
Models: models.NewClient(opts...),
Finetuning: finetuningclient.NewClient(opts...),
}
}

Expand Down Expand Up @@ -159,7 +162,11 @@ func (c *Client) Chat(
return response, nil
}

// This endpoint generates realistic text conditioned on a given input.
// > 🚧 Warning
// >
// > This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API.
//
// Generates realistic text conditioned on a given input.
func (c *Client) GenerateStream(
ctx context.Context,
request *v2.GenerateStreamRequest,
Expand Down Expand Up @@ -226,7 +233,11 @@ func (c *Client) GenerateStream(
)
}

// This endpoint generates realistic text conditioned on a given input.
// > 🚧 Warning
// >
// > This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API.
//
// Generates realistic text conditioned on a given input.
func (c *Client) Generate(
ctx context.Context,
request *v2.GenerateRequest,
Expand Down Expand Up @@ -501,7 +512,11 @@ func (c *Client) Classify(
return response, nil
}

// This endpoint generates a summary in English for a given text.
// > 🚧 Warning
// >
// > This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API.
//
// Generates a summary in English for a given text.
func (c *Client) Summarize(
ctx context.Context,
request *v2.SummarizeRequest,
Expand Down
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.6.0")
headers.Set("X-Fern-SDK-Version", "v2.7.0")
return headers
}

Expand Down
4 changes: 2 additions & 2 deletions datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ type DatasetsListRequest struct {
// optional filter after a date
After *time.Time `json:"-" url:"after,omitempty"`
// optional limit to number of results
Limit *string `json:"-" url:"limit,omitempty"`
Limit *float64 `json:"-" url:"limit,omitempty"`
// optional offset to start of results
Offset *string `json:"-" url:"offset,omitempty"`
Offset *float64 `json:"-" url:"offset,omitempty"`
}

type DatasetsCreateResponse struct {
Expand Down
47 changes: 47 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package api
import (
json "encoding/json"
core "github.com/cohere-ai/cohere-go/v2/core"
finetuning "github.com/cohere-ai/cohere-go/v2/finetuning"
)

type BadRequestError struct {
Expand Down Expand Up @@ -99,6 +100,29 @@ func (n *NotFoundError) Unwrap() error {
return n.APIError
}

type ServiceUnavailableError struct {
*core.APIError
Body *finetuning.Error
}

func (s *ServiceUnavailableError) UnmarshalJSON(data []byte) error {
var body *finetuning.Error
if err := json.Unmarshal(data, &body); err != nil {
return err
}
s.StatusCode = 503
s.Body = body
return nil
}

func (s *ServiceUnavailableError) MarshalJSON() ([]byte, error) {
return json.Marshal(s.Body)
}

func (s *ServiceUnavailableError) Unwrap() error {
return s.APIError
}

type TooManyRequestsError struct {
*core.APIError
Body interface{}
Expand All @@ -121,3 +145,26 @@ func (t *TooManyRequestsError) MarshalJSON() ([]byte, error) {
func (t *TooManyRequestsError) Unwrap() error {
return t.APIError
}

type UnauthorizedError struct {
*core.APIError
Body *finetuning.Error
}

func (u *UnauthorizedError) UnmarshalJSON(data []byte) error {
var body *finetuning.Error
if err := json.Unmarshal(data, &body); err != nil {
return err
}
u.StatusCode = 401
u.Body = body
return nil
}

func (u *UnauthorizedError) MarshalJSON() ([]byte, error) {
return json.Marshal(u.Body)
}

func (u *UnauthorizedError) Unwrap() error {
return u.APIError
}
96 changes: 96 additions & 0 deletions finetuning.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// This file was auto-generated by Fern from our API Definition.

package api

import (
json "encoding/json"
core "github.com/cohere-ai/cohere-go/v2/core"
finetuning "github.com/cohere-ai/cohere-go/v2/finetuning"
time "time"
)

type FinetuningListEventsRequest struct {
// Maximum number of results to be returned by the server. If 0, defaults to 50.
PageSize *int `json:"-" url:"page_size,omitempty"`
// Request a specific page of the list results.
PageToken *string `json:"-" url:"page_token,omitempty"`
// Comma separated list of fields. For example: "created_at,name". The default
// sorting order is ascending. To specify descending order for a field, append
// " desc" to the field name. For example: "created_at desc,name".
//
// Supported sorting fields:
//
// - created_at (default)
OrderBy *string `json:"-" url:"order_by,omitempty"`
}

type FinetuningListFinetunedModelsRequest struct {
// Maximum number of results to be returned by the server. If 0, defaults to 50.
PageSize *int `json:"-" url:"page_size,omitempty"`
// Request a specific page of the list results.
PageToken *string `json:"-" url:"page_token,omitempty"`
// Comma separated list of fields. For example: "created_at,name". The default
// sorting order is ascending. To specify descending order for a field, append
// " desc" to the field name. For example: "created_at desc,name".
//
// Supported sorting fields:
//
// - created_at (default)
OrderBy *string `json:"-" url:"order_by,omitempty"`
}

type FinetuningListTrainingStepMetricsRequest struct {
// Maximum number of results to be returned by the server. If 0, defaults to 50.
PageSize *int `json:"-" url:"page_size,omitempty"`
// Request a specific page of the list results.
PageToken *string `json:"-" url:"page_token,omitempty"`
}

type FinetuningUpdateFinetunedModelRequest struct {
// FinetunedModel name (e.g. `foobar`).
Name string `json:"name" url:"name"`
// User ID of the creator.
CreatorId *string `json:"creator_id,omitempty" url:"creator_id,omitempty"`
// Organization ID.
OrganizationId *string `json:"organization_id,omitempty" url:"organization_id,omitempty"`
// FinetunedModel settings such as dataset, hyperparameters...
Settings *finetuning.Settings `json:"settings,omitempty" url:"settings,omitempty"`
// Current stage in the life-cycle of the fine-tuned model.
Status *finetuning.Status `json:"status,omitempty" url:"status,omitempty"`
// Creation timestamp.
CreatedAt *time.Time `json:"created_at,omitempty" url:"created_at,omitempty"`
// Latest update timestamp.
UpdatedAt *time.Time `json:"updated_at,omitempty" url:"updated_at,omitempty"`
// Timestamp for the completed fine-tuning.
CompletedAt *time.Time `json:"completed_at,omitempty" url:"completed_at,omitempty"`
// Timestamp for the latest request to this fine-tuned model.
LastUsed *time.Time `json:"last_used,omitempty" url:"last_used,omitempty"`
}

func (f *FinetuningUpdateFinetunedModelRequest) UnmarshalJSON(data []byte) error {
type unmarshaler FinetuningUpdateFinetunedModelRequest
var body unmarshaler
if err := json.Unmarshal(data, &body); err != nil {
return err
}
*f = FinetuningUpdateFinetunedModelRequest(body)
return nil
}

func (f *FinetuningUpdateFinetunedModelRequest) MarshalJSON() ([]byte, error) {
type embed FinetuningUpdateFinetunedModelRequest
var marshaler = struct {
embed
CreatedAt *core.DateTime `json:"created_at,omitempty"`
UpdatedAt *core.DateTime `json:"updated_at,omitempty"`
CompletedAt *core.DateTime `json:"completed_at,omitempty"`
LastUsed *core.DateTime `json:"last_used,omitempty"`
}{
embed: embed(*f),
CreatedAt: core.NewOptionalDateTime(f.CreatedAt),
UpdatedAt: core.NewOptionalDateTime(f.UpdatedAt),
CompletedAt: core.NewOptionalDateTime(f.CompletedAt),
LastUsed: core.NewOptionalDateTime(f.LastUsed),
}
return json.Marshal(marshaler)
}
Loading
Loading