summaryrefslogtreecommitdiffhomepage
path: root/pkg/client
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/client')
-rw-r--r--pkg/client/gen/openapi.json58
-rw-r--r--pkg/client/generated-client.go120
2 files changed, 178 insertions, 0 deletions
diff --git a/pkg/client/gen/openapi.json b/pkg/client/gen/openapi.json
index 3a14a4643..478eb02ae 100644
--- a/pkg/client/gen/openapi.json
+++ b/pkg/client/gen/openapi.json
@@ -95,6 +95,64 @@
}
}
},
+ "/session_list": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "List of sessions",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "pattern": "^ses"
+ },
+ "shareID": {
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ },
+ "tokens": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "number"
+ },
+ "output": {
+ "type": "number"
+ },
+ "reasoning": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "input",
+ "output",
+ "reasoning"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "title",
+ "tokens"
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "operationId": "postSession_list",
+ "parameters": [],
+ "description": "List all sessions"
+ }
+ },
"/session_chat": {
"post": {
"responses": {},
diff --git a/pkg/client/generated-client.go b/pkg/client/generated-client.go
index e93e83afe..46fb60205 100644
--- a/pkg/client/generated-client.go
+++ b/pkg/client/generated-client.go
@@ -132,6 +132,9 @@ type ClientInterface interface {
// PostSessionCreate request
PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
+ // PostSessionList request
+ PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
+
// PostSessionMessagesWithBody request with any body
PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
@@ -179,6 +182,18 @@ func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEdi
return c.Client.Do(req)
}
+func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
+ req, err := NewPostSessionListRequest(c.Server)
+ if err != nil {
+ return nil, err
+ }
+ req = req.WithContext(ctx)
+ if err := c.applyEditors(ctx, req, reqEditors); err != nil {
+ return nil, err
+ }
+ return c.Client.Do(req)
+}
+
func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
if err != nil {
@@ -294,6 +309,33 @@ func NewPostSessionCreateRequest(server string) (*http.Request, error) {
return req, nil
}
+// NewPostSessionListRequest generates requests for PostSessionList
+func NewPostSessionListRequest(server string) (*http.Request, error) {
+ var err error
+
+ serverURL, err := url.Parse(server)
+ if err != nil {
+ return nil, err
+ }
+
+ operationPath := fmt.Sprintf("/session_list")
+ if operationPath[0] == '/' {
+ operationPath = "." + operationPath
+ }
+
+ queryURL, err := serverURL.Parse(operationPath)
+ if err != nil {
+ return nil, err
+ }
+
+ req, err := http.NewRequest("POST", queryURL.String(), nil)
+ if err != nil {
+ return nil, err
+ }
+
+ return req, nil
+}
+
// NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
@@ -425,6 +467,9 @@ type ClientWithResponsesInterface interface {
// PostSessionCreateWithResponse request
PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
+ // PostSessionListWithResponse request
+ PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
+
// PostSessionMessagesWithBodyWithResponse request with any body
PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
@@ -479,6 +524,37 @@ func (r PostSessionCreateResponse) StatusCode() int {
return 0
}
+type PostSessionListResponse struct {
+ Body []byte
+ HTTPResponse *http.Response
+ JSON200 *[]struct {
+ Id string `json:"id"`
+ ShareID *string `json:"shareID,omitempty"`
+ Title string `json:"title"`
+ Tokens struct {
+ Input float32 `json:"input"`
+ Output float32 `json:"output"`
+ Reasoning float32 `json:"reasoning"`
+ } `json:"tokens"`
+ }
+}
+
+// Status returns HTTPResponse.Status
+func (r PostSessionListResponse) Status() string {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.Status
+ }
+ return http.StatusText(0)
+}
+
+// StatusCode returns HTTPResponse.StatusCode
+func (r PostSessionListResponse) StatusCode() int {
+ if r.HTTPResponse != nil {
+ return r.HTTPResponse.StatusCode
+ }
+ return 0
+}
+
type PostSessionMessagesResponse struct {
Body []byte
HTTPResponse *http.Response
@@ -549,6 +625,15 @@ func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context,
return ParsePostSessionCreateResponse(rsp)
}
+// PostSessionListWithResponse request returning *PostSessionListResponse
+func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
+ rsp, err := c.PostSessionList(ctx, reqEditors...)
+ if err != nil {
+ return nil, err
+ }
+ return ParsePostSessionListResponse(rsp)
+}
+
// PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
@@ -625,6 +710,41 @@ func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateRespo
return response, nil
}
+// ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
+func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
+ bodyBytes, err := io.ReadAll(rsp.Body)
+ defer func() { _ = rsp.Body.Close() }()
+ if err != nil {
+ return nil, err
+ }
+
+ response := &PostSessionListResponse{
+ Body: bodyBytes,
+ HTTPResponse: rsp,
+ }
+
+ switch {
+ case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
+ var dest []struct {
+ Id string `json:"id"`
+ ShareID *string `json:"shareID,omitempty"`
+ Title string `json:"title"`
+ Tokens struct {
+ Input float32 `json:"input"`
+ Output float32 `json:"output"`
+ Reasoning float32 `json:"reasoning"`
+ } `json:"tokens"`
+ }
+ if err := json.Unmarshal(bodyBytes, &dest); err != nil {
+ return nil, err
+ }
+ response.JSON200 = &dest
+
+ }
+
+ return response, nil
+}
+
// ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
bodyBytes, err := io.ReadAll(rsp.Body)