From 36120aa5a4003e028a9f51b57e1c29073f96b5bf Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 04:41:54 +0000 Subject: [PATCH] SDK regeneration --- core/request_option.go | 2 +- memory.go | 4 +++ memory/client.go | 66 ++++++++++++++++++++++++++++++++++++++++++ types.go | 1 + 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/core/request_option.go b/core/request_option.go index 24a0387..68dc842 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -52,7 +52,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/getzep/zep-go") - headers.Set("X-Fern-SDK-Version", "v1.0.1") + headers.Set("X-Fern-SDK-Version", "v1.0.2") return headers } diff --git a/memory.go b/memory.go index 2592ba1..d7e3194 100644 --- a/memory.go +++ b/memory.go @@ -37,6 +37,10 @@ type ClassifySessionRequest struct { Persist *bool `json:"persist,omitempty" url:"persist,omitempty"` } +type EndSessionRequest struct { + Instruction *string `json:"instruction,omitempty" url:"instruction,omitempty"` +} + type ModelsExtractDataRequest struct { LastNMessages *int `json:"last_n_messages,omitempty" url:"last_n_messages,omitempty"` ZepDataClasses []*ModelsZepDataClass `json:"zep_data_classes,omitempty" url:"zep_data_classes,omitempty"` diff --git a/memory/client.go b/memory/client.go index 91fd48b..d7878ab 100644 --- a/memory/client.go +++ b/memory/client.go @@ -376,6 +376,72 @@ func (c *Client) ClassifySession( return response, nil } +// End a session by ID +func (c *Client) EndSession( + ctx context.Context, + // Session ID + sessionID string, + request *zepgo.EndSessionRequest, + opts ...option.RequestOption, +) (*zepgo.Session, error) { + options := core.NewRequestOptions(opts...) + + baseURL := "https://api.getzep.com/api/v2" + if c.baseURL != "" { + baseURL = c.baseURL + } + if options.BaseURL != "" { + baseURL = options.BaseURL + } + endpointURL := core.EncodeURL(baseURL+"/sessions/%v/end", sessionID) + + 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 404: + value := new(zepgo.NotFoundError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 500: + value := new(zepgo.InternalServerError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + } + return apiError + } + + var response *zepgo.Session + if err := c.caller.Call( + ctx, + &core.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, + }, + ); err != nil { + return nil, err + } + return response, nil +} + // extract data from a session by session id func (c *Client) ExtractSessionData( ctx context.Context, diff --git a/types.go b/types.go index 6232039..21ae810 100644 --- a/types.go +++ b/types.go @@ -537,6 +537,7 @@ type Session struct { Classifications map[string]string `json:"classifications,omitempty" url:"classifications,omitempty"` CreatedAt *string `json:"created_at,omitempty" url:"created_at,omitempty"` DeletedAt *string `json:"deleted_at,omitempty" url:"deleted_at,omitempty"` + EndedAt *string `json:"ended_at,omitempty" url:"ended_at,omitempty"` Facts []string `json:"facts,omitempty" url:"facts,omitempty"` ID *int `json:"id,omitempty" url:"id,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`