diff --git a/client/client.go b/client/client.go index 9afa2e1..47e5c24 100644 --- a/client/client.go +++ b/client/client.go @@ -9,6 +9,7 @@ import ( internal "github.com/getzep/zep-go/v3/internal" option "github.com/getzep/zep-go/v3/option" project "github.com/getzep/zep-go/v3/project" + task "github.com/getzep/zep-go/v3/task" threadclient "github.com/getzep/zep-go/v3/thread/client" user "github.com/getzep/zep-go/v3/user" http "net/http" @@ -19,6 +20,7 @@ type Client struct { Context *context.Client Graph *client.Client Project *project.Client + Task *task.Client Thread *threadclient.Client User *user.Client @@ -36,6 +38,7 @@ func NewClient(opts ...option.RequestOption) *Client { Context: context.NewClient(opts...), Graph: client.NewClient(opts...), Project: project.NewClient(opts...), + Task: task.NewClient(opts...), Thread: threadclient.NewClient(opts...), User: user.NewClient(opts...), baseURL: options.BaseURL, diff --git a/core/request_option.go b/core/request_option.go index 3e5dce4..c1baadd 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -57,8 +57,8 @@ func (r *RequestOptions) cloneHeader() http.Header { headers := r.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") headers.Set("X-Fern-SDK-Name", "github.com/getzep/zep-go/v3") - headers.Set("X-Fern-SDK-Version", "v3.12.0") - headers.Set("User-Agent", "github.com/getzep/zep-go/3.12.0") + headers.Set("X-Fern-SDK-Version", "v3.13.0") + headers.Set("User-Agent", "github.com/getzep/zep-go/3.13.0") return headers } diff --git a/graph.go b/graph.go index e52a227..4752108 100644 --- a/graph.go +++ b/graph.go @@ -42,7 +42,7 @@ type AddTripleRequest struct { // The time (if any) at which the fact stops being true InvalidAt *string `json:"invalid_at,omitempty" url:"-"` // The name of the source node to add - SourceNodeName *string `json:"source_node_name,omitempty" url:"-"` + SourceNodeName string `json:"source_node_name" url:"-"` // The summary of the source node to add SourceNodeSummary *string `json:"source_node_summary,omitempty" url:"-"` // The source node uuid @@ -128,6 +128,8 @@ type AddTripleResponse struct { Edge *EntityEdge `json:"edge,omitempty" url:"edge,omitempty"` SourceNode *EntityNode `json:"source_node,omitempty" url:"source_node,omitempty"` TargetNode *EntityNode `json:"target_node,omitempty" url:"target_node,omitempty"` + // Task ID of the add triple task + TaskID *string `json:"task_id,omitempty" url:"task_id,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -154,6 +156,13 @@ func (a *AddTripleResponse) GetTargetNode() *EntityNode { return a.TargetNode } +func (a *AddTripleResponse) GetTaskID() *string { + if a == nil { + return nil + } + return a.TaskID +} + func (a *AddTripleResponse) GetExtraProperties() map[string]interface{} { return a.extraProperties } @@ -189,7 +198,9 @@ func (a *AddTripleResponse) String() string { type CloneGraphResponse struct { // graph_id is the ID of the cloned graph GraphID *string `json:"graph_id,omitempty" url:"graph_id,omitempty"` - UserID *string `json:"user_id,omitempty" url:"user_id,omitempty"` + // Task ID of the clone graph task + TaskID *string `json:"task_id,omitempty" url:"task_id,omitempty"` + UserID *string `json:"user_id,omitempty" url:"user_id,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -202,6 +213,13 @@ func (c *CloneGraphResponse) GetGraphID() *string { return c.GraphID } +func (c *CloneGraphResponse) GetTaskID() *string { + if c == nil { + return nil + } + return c.TaskID +} + func (c *CloneGraphResponse) GetUserID() *string { if c == nil { return nil diff --git a/task.go b/task.go new file mode 100644 index 0000000..9ecfbdf --- /dev/null +++ b/task.go @@ -0,0 +1,235 @@ +// Code generated by Fern. DO NOT EDIT. + +package zep + +import ( + json "encoding/json" + fmt "fmt" + internal "github.com/getzep/zep-go/v3/internal" +) + +type GetTaskResponse struct { + CompletedAt *string `json:"completed_at,omitempty" url:"completed_at,omitempty"` + CreatedAt *string `json:"created_at,omitempty" url:"created_at,omitempty"` + Error *TaskErrorResponse `json:"error,omitempty" url:"error,omitempty"` + Progress *TaskProgress `json:"progress,omitempty" url:"progress,omitempty"` + StartedAt *string `json:"started_at,omitempty" url:"started_at,omitempty"` + Status *string `json:"status,omitempty" url:"status,omitempty"` + TaskID *string `json:"task_id,omitempty" url:"task_id,omitempty"` + Type *string `json:"type,omitempty" url:"type,omitempty"` + UpdatedAt *string `json:"updated_at,omitempty" url:"updated_at,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (g *GetTaskResponse) GetCompletedAt() *string { + if g == nil { + return nil + } + return g.CompletedAt +} + +func (g *GetTaskResponse) GetCreatedAt() *string { + if g == nil { + return nil + } + return g.CreatedAt +} + +func (g *GetTaskResponse) GetError() *TaskErrorResponse { + if g == nil { + return nil + } + return g.Error +} + +func (g *GetTaskResponse) GetProgress() *TaskProgress { + if g == nil { + return nil + } + return g.Progress +} + +func (g *GetTaskResponse) GetStartedAt() *string { + if g == nil { + return nil + } + return g.StartedAt +} + +func (g *GetTaskResponse) GetStatus() *string { + if g == nil { + return nil + } + return g.Status +} + +func (g *GetTaskResponse) GetTaskID() *string { + if g == nil { + return nil + } + return g.TaskID +} + +func (g *GetTaskResponse) GetType() *string { + if g == nil { + return nil + } + return g.Type +} + +func (g *GetTaskResponse) GetUpdatedAt() *string { + if g == nil { + return nil + } + return g.UpdatedAt +} + +func (g *GetTaskResponse) GetExtraProperties() map[string]interface{} { + return g.extraProperties +} + +func (g *GetTaskResponse) UnmarshalJSON(data []byte) error { + type unmarshaler GetTaskResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *g = GetTaskResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *g) + if err != nil { + return err + } + g.extraProperties = extraProperties + g.rawJSON = json.RawMessage(data) + return nil +} + +func (g *GetTaskResponse) String() string { + if len(g.rawJSON) > 0 { + if value, err := internal.StringifyJSON(g.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(g); err == nil { + return value + } + return fmt.Sprintf("%#v", g) +} + +type TaskErrorResponse struct { + Code *string `json:"code,omitempty" url:"code,omitempty"` + Details map[string]interface{} `json:"details,omitempty" url:"details,omitempty"` + Message *string `json:"message,omitempty" url:"message,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (t *TaskErrorResponse) GetCode() *string { + if t == nil { + return nil + } + return t.Code +} + +func (t *TaskErrorResponse) GetDetails() map[string]interface{} { + if t == nil { + return nil + } + return t.Details +} + +func (t *TaskErrorResponse) GetMessage() *string { + if t == nil { + return nil + } + return t.Message +} + +func (t *TaskErrorResponse) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TaskErrorResponse) UnmarshalJSON(data []byte) error { + type unmarshaler TaskErrorResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TaskErrorResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + t.rawJSON = json.RawMessage(data) + return nil +} + +func (t *TaskErrorResponse) String() string { + if len(t.rawJSON) > 0 { + if value, err := internal.StringifyJSON(t.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} + +type TaskProgress struct { + Message *string `json:"message,omitempty" url:"message,omitempty"` + Stage *string `json:"stage,omitempty" url:"stage,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (t *TaskProgress) GetMessage() *string { + if t == nil { + return nil + } + return t.Message +} + +func (t *TaskProgress) GetStage() *string { + if t == nil { + return nil + } + return t.Stage +} + +func (t *TaskProgress) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TaskProgress) UnmarshalJSON(data []byte) error { + type unmarshaler TaskProgress + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TaskProgress(value) + extraProperties, err := internal.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + t.rawJSON = json.RawMessage(data) + return nil +} + +func (t *TaskProgress) String() string { + if len(t.rawJSON) > 0 { + if value, err := internal.StringifyJSON(t.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/task/client.go b/task/client.go new file mode 100644 index 0000000..f0688d4 --- /dev/null +++ b/task/client.go @@ -0,0 +1,57 @@ +// Code generated by Fern. DO NOT EDIT. + +package task + +import ( + context "context" + v3 "github.com/getzep/zep-go/v3" + core "github.com/getzep/zep-go/v3/core" + internal "github.com/getzep/zep-go/v3/internal" + option "github.com/getzep/zep-go/v3/option" + http "net/http" + os "os" +) + +type Client struct { + WithRawResponse *RawClient + + baseURL string + caller *internal.Caller + header http.Header +} + +func NewClient(opts ...option.RequestOption) *Client { + options := core.NewRequestOptions(opts...) + if options.APIKey == "" { + options.APIKey = os.Getenv("ZEP_API_KEY") + } + return &Client{ + WithRawResponse: NewRawClient(options), + baseURL: options.BaseURL, + caller: internal.NewCaller( + &internal.CallerParams{ + Client: options.HTTPClient, + MaxAttempts: options.MaxAttempts, + }, + ), + header: options.ToHeader(), + } +} + +// Gets a task by its ID +func (c *Client) Get( + ctx context.Context, + // Task ID + taskID string, + opts ...option.RequestOption, +) (*v3.GetTaskResponse, error) { + response, err := c.WithRawResponse.Get( + ctx, + taskID, + opts..., + ) + if err != nil { + return nil, err + } + return response.Body, nil +} diff --git a/task/raw_client.go b/task/raw_client.go new file mode 100644 index 0000000..bc90bca --- /dev/null +++ b/task/raw_client.go @@ -0,0 +1,88 @@ +// Code generated by Fern. DO NOT EDIT. + +package task + +import ( + context "context" + v3 "github.com/getzep/zep-go/v3" + core "github.com/getzep/zep-go/v3/core" + internal "github.com/getzep/zep-go/v3/internal" + option "github.com/getzep/zep-go/v3/option" + http "net/http" +) + +type RawClient struct { + baseURL string + caller *internal.Caller + header http.Header +} + +func NewRawClient(options *core.RequestOptions) *RawClient { + return &RawClient{ + baseURL: options.BaseURL, + caller: internal.NewCaller( + &internal.CallerParams{ + Client: options.HTTPClient, + MaxAttempts: options.MaxAttempts, + }, + ), + header: options.ToHeader(), + } +} + +func (r *RawClient) Get( + ctx context.Context, + // Task ID + taskID string, + opts ...option.RequestOption, +) (*core.Response[*v3.GetTaskResponse], error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + r.baseURL, + "https://api.getzep.com/api/v2", + ) + endpointURL := internal.EncodeURL( + baseURL+"/tasks/%v", + taskID, + ) + headers := internal.MergeHeaders( + r.header.Clone(), + options.ToHeader(), + ) + errorCodes := internal.ErrorCodes{ + 404: func(apiError *core.APIError) error { + return &v3.NotFoundError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &v3.InternalServerError{ + APIError: apiError, + } + }, + } + var response *v3.GetTaskResponse + raw, err := r.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodGet, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ) + if err != nil { + return nil, err + } + return &core.Response[*v3.GetTaskResponse]{ + StatusCode: raw.StatusCode, + Header: raw.Header, + Body: response, + }, nil +} diff --git a/thread.go b/thread.go index 15955d6..af0446c 100644 --- a/thread.go +++ b/thread.go @@ -114,6 +114,7 @@ func (a *AddThreadMessagesRequest) String() string { type AddThreadMessagesResponse struct { Context *string `json:"context,omitempty" url:"context,omitempty"` MessageUUIDs []string `json:"message_uuids,omitempty" url:"message_uuids,omitempty"` + TaskID *string `json:"task_id,omitempty" url:"task_id,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -133,6 +134,13 @@ func (a *AddThreadMessagesResponse) GetMessageUUIDs() []string { return a.MessageUUIDs } +func (a *AddThreadMessagesResponse) GetTaskID() *string { + if a == nil { + return nil + } + return a.TaskID +} + func (a *AddThreadMessagesResponse) GetExtraProperties() map[string]interface{} { return a.extraProperties } diff --git a/types.go b/types.go index 6c2a574..043cee2 100644 --- a/types.go +++ b/types.go @@ -337,6 +337,8 @@ type Episode struct { Score *float64 `json:"score,omitempty" url:"score,omitempty"` Source *GraphDataType `json:"source,omitempty" url:"source,omitempty"` SourceDescription *string `json:"source_description,omitempty" url:"source_description,omitempty"` + // Optional task ID to poll episode processing status. Currently only available for batch ingestion. + TaskID *string `json:"task_id,omitempty" url:"task_id,omitempty"` // Optional thread ID, will be present if the episode is part of a thread ThreadID *string `json:"thread_id,omitempty" url:"thread_id,omitempty"` UUID string `json:"uuid" url:"uuid"` @@ -415,6 +417,13 @@ func (e *Episode) GetSourceDescription() *string { return e.SourceDescription } +func (e *Episode) GetTaskID() *string { + if e == nil { + return nil + } + return e.TaskID +} + func (e *Episode) GetThreadID() *string { if e == nil { return nil