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 May 14, 2024
1 parent f040529 commit 36120aa
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
66 changes: 66 additions & 0 deletions memory/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 36120aa

Please sign in to comment.