2025-05-19 10:30:41 +08:00
// Package client provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
package client
import (
"bytes"
"context"
"encoding/json"
2025-05-29 01:35:05 +08:00
"errors"
2025-05-19 10:30:41 +08:00
"fmt"
"io"
"net/http"
"net/url"
"strings"
2025-05-29 01:22:48 +08:00
"github.com/oapi-codegen/runtime"
)
// Defines values for SessionMessageRole.
const (
Assistant SessionMessageRole = "assistant"
System SessionMessageRole = "system"
User SessionMessageRole = "user"
2025-05-19 10:30:41 +08:00
)
2025-05-29 00:53:22 +08:00
// ProviderInfo defines model for Provider.Info.
type ProviderInfo struct {
2025-05-29 01:57:24 +08:00
Models map [ string ] struct {
2025-05-29 00:53:22 +08:00
Attachment bool ` json:"attachment" `
ContextWindow float32 ` json:"contextWindow" `
Cost struct {
Input float32 ` json:"input" `
InputCached float32 ` json:"inputCached" `
Output float32 ` json:"output" `
OutputCached float32 ` json:"outputCached" `
} ` json:"cost" `
MaxTokens float32 ` json:"maxTokens" `
Name * string ` json:"name,omitempty" `
2025-05-29 01:57:24 +08:00
} ` json:"models" `
2025-05-29 00:53:22 +08:00
Options * map [ string ] interface { } ` json:"options,omitempty" `
}
2025-05-19 10:30:41 +08:00
// SessionInfo defines model for Session.Info.
type SessionInfo struct {
2025-05-29 01:57:24 +08:00
Cost * float32 ` json:"cost,omitempty" `
Id string ` json:"id" `
ShareID * string ` json:"shareID,omitempty" `
Title string ` json:"title" `
2025-05-27 06:14:36 +08:00
Tokens struct {
2025-05-19 10:30:41 +08:00
Input float32 ` json:"input" `
Output float32 ` json:"output" `
Reasoning float32 ` json:"reasoning" `
} ` json:"tokens" `
}
2025-05-29 01:22:48 +08:00
// SessionMessage defines model for Session.Message.
type SessionMessage struct {
Id string ` json:"id" `
Metadata struct {
SessionID string ` json:"sessionID" `
Time struct {
Completed * float32 ` json:"completed,omitempty" `
Created float32 ` json:"created" `
} ` json:"time" `
Tool map [ string ] interface { } ` json:"tool" `
} ` json:"metadata" `
Parts [ ] SessionMessagePart ` json:"parts" `
Role SessionMessageRole ` json:"role" `
}
// SessionMessageRole defines model for SessionMessage.Role.
type SessionMessageRole string
// SessionMessagePart defines model for Session.Message.Part.
type SessionMessagePart struct {
union json . RawMessage
}
// SessionMessagePartFile defines model for Session.Message.Part.File.
type SessionMessagePartFile struct {
Filename * string ` json:"filename,omitempty" `
MediaType string ` json:"mediaType" `
Type string ` json:"type" `
Url string ` json:"url" `
}
// SessionMessagePartReasoning defines model for Session.Message.Part.Reasoning.
type SessionMessagePartReasoning struct {
ProviderMetadata * map [ string ] interface { } ` json:"providerMetadata,omitempty" `
Text string ` json:"text" `
Type string ` json:"type" `
}
// SessionMessagePartSourceUrl defines model for Session.Message.Part.SourceUrl.
type SessionMessagePartSourceUrl struct {
ProviderMetadata * map [ string ] interface { } ` json:"providerMetadata,omitempty" `
SourceId string ` json:"sourceId" `
Title * string ` json:"title,omitempty" `
Type string ` json:"type" `
Url string ` json:"url" `
}
// SessionMessagePartStepStart defines model for Session.Message.Part.StepStart.
type SessionMessagePartStepStart struct {
Type string ` json:"type" `
}
// SessionMessagePartText defines model for Session.Message.Part.Text.
type SessionMessagePartText struct {
Text string ` json:"text" `
Type string ` json:"type" `
}
// SessionMessagePartToolInvocation defines model for Session.Message.Part.ToolInvocation.
type SessionMessagePartToolInvocation struct {
ToolInvocation SessionMessageToolInvocation ` json:"toolInvocation" `
Type string ` json:"type" `
}
// SessionMessageToolInvocation defines model for Session.Message.ToolInvocation.
type SessionMessageToolInvocation struct {
union json . RawMessage
}
// SessionMessageToolInvocationToolCall defines model for Session.Message.ToolInvocation.ToolCall.
type SessionMessageToolInvocationToolCall struct {
Args map [ string ] interface { } ` json:"args" `
State string ` json:"state" `
Step * float32 ` json:"step,omitempty" `
ToolCallId string ` json:"toolCallId" `
ToolName string ` json:"toolName" `
}
// SessionMessageToolInvocationToolPartialCall defines model for Session.Message.ToolInvocation.ToolPartialCall.
type SessionMessageToolInvocationToolPartialCall struct {
Args map [ string ] interface { } ` json:"args" `
State string ` json:"state" `
Step * float32 ` json:"step,omitempty" `
ToolCallId string ` json:"toolCallId" `
ToolName string ` json:"toolName" `
}
// SessionMessageToolInvocationToolResult defines model for Session.Message.ToolInvocation.ToolResult.
type SessionMessageToolInvocationToolResult struct {
Args map [ string ] interface { } ` json:"args" `
Result string ` json:"result" `
State string ` json:"state" `
Step * float32 ` json:"step,omitempty" `
ToolCallId string ` json:"toolCallId" `
ToolName string ` json:"toolName" `
}
2025-05-19 10:30:41 +08:00
// PostSessionChatJSONBody defines parameters for PostSessionChat.
type PostSessionChatJSONBody struct {
2025-05-29 01:22:48 +08:00
ModelID string ` json:"modelID" `
Parts [ ] SessionMessagePart ` json:"parts" `
ProviderID string ` json:"providerID" `
SessionID string ` json:"sessionID" `
2025-05-19 10:30:41 +08:00
}
2025-05-27 06:14:36 +08:00
// PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
type PostSessionMessagesJSONBody struct {
SessionID string ` json:"sessionID" `
}
// PostSessionShareJSONBody defines parameters for PostSessionShare.
type PostSessionShareJSONBody struct {
SessionID string ` json:"sessionID" `
}
2025-05-19 10:30:41 +08:00
// PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
type PostSessionChatJSONRequestBody PostSessionChatJSONBody
2025-05-27 06:14:36 +08:00
// PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
// PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
type PostSessionShareJSONRequestBody PostSessionShareJSONBody
2025-05-29 01:22:48 +08:00
// AsSessionMessagePartText returns the union data inside the SessionMessagePart as a SessionMessagePartText
func ( t SessionMessagePart ) AsSessionMessagePartText ( ) ( SessionMessagePartText , error ) {
var body SessionMessagePartText
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessagePartText overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartText
func ( t * SessionMessagePart ) FromSessionMessagePartText ( v SessionMessagePartText ) error {
2025-05-29 01:35:05 +08:00
v . Type = "text"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessagePartText performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartText
func ( t * SessionMessagePart ) MergeSessionMessagePartText ( v SessionMessagePartText ) error {
2025-05-29 01:35:05 +08:00
v . Type = "text"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessagePartReasoning returns the union data inside the SessionMessagePart as a SessionMessagePartReasoning
func ( t SessionMessagePart ) AsSessionMessagePartReasoning ( ) ( SessionMessagePartReasoning , error ) {
var body SessionMessagePartReasoning
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessagePartReasoning overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartReasoning
func ( t * SessionMessagePart ) FromSessionMessagePartReasoning ( v SessionMessagePartReasoning ) error {
2025-05-29 01:35:05 +08:00
v . Type = "reasoning"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessagePartReasoning performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartReasoning
func ( t * SessionMessagePart ) MergeSessionMessagePartReasoning ( v SessionMessagePartReasoning ) error {
2025-05-29 01:35:05 +08:00
v . Type = "reasoning"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessagePartToolInvocation returns the union data inside the SessionMessagePart as a SessionMessagePartToolInvocation
func ( t SessionMessagePart ) AsSessionMessagePartToolInvocation ( ) ( SessionMessagePartToolInvocation , error ) {
var body SessionMessagePartToolInvocation
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessagePartToolInvocation overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartToolInvocation
func ( t * SessionMessagePart ) FromSessionMessagePartToolInvocation ( v SessionMessagePartToolInvocation ) error {
2025-05-29 01:35:05 +08:00
v . Type = "tool-invocation"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessagePartToolInvocation performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartToolInvocation
func ( t * SessionMessagePart ) MergeSessionMessagePartToolInvocation ( v SessionMessagePartToolInvocation ) error {
2025-05-29 01:35:05 +08:00
v . Type = "tool-invocation"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessagePartSourceUrl returns the union data inside the SessionMessagePart as a SessionMessagePartSourceUrl
func ( t SessionMessagePart ) AsSessionMessagePartSourceUrl ( ) ( SessionMessagePartSourceUrl , error ) {
var body SessionMessagePartSourceUrl
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessagePartSourceUrl overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartSourceUrl
func ( t * SessionMessagePart ) FromSessionMessagePartSourceUrl ( v SessionMessagePartSourceUrl ) error {
2025-05-29 01:35:05 +08:00
v . Type = "source-url"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessagePartSourceUrl performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartSourceUrl
func ( t * SessionMessagePart ) MergeSessionMessagePartSourceUrl ( v SessionMessagePartSourceUrl ) error {
2025-05-29 01:35:05 +08:00
v . Type = "source-url"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessagePartFile returns the union data inside the SessionMessagePart as a SessionMessagePartFile
func ( t SessionMessagePart ) AsSessionMessagePartFile ( ) ( SessionMessagePartFile , error ) {
var body SessionMessagePartFile
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessagePartFile overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartFile
func ( t * SessionMessagePart ) FromSessionMessagePartFile ( v SessionMessagePartFile ) error {
2025-05-29 01:35:05 +08:00
v . Type = "file"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessagePartFile performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartFile
func ( t * SessionMessagePart ) MergeSessionMessagePartFile ( v SessionMessagePartFile ) error {
2025-05-29 01:35:05 +08:00
v . Type = "file"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessagePartStepStart returns the union data inside the SessionMessagePart as a SessionMessagePartStepStart
func ( t SessionMessagePart ) AsSessionMessagePartStepStart ( ) ( SessionMessagePartStepStart , error ) {
var body SessionMessagePartStepStart
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessagePartStepStart overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartStepStart
func ( t * SessionMessagePart ) FromSessionMessagePartStepStart ( v SessionMessagePartStepStart ) error {
2025-05-29 01:35:05 +08:00
v . Type = "step-start"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessagePartStepStart performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartStepStart
func ( t * SessionMessagePart ) MergeSessionMessagePartStepStart ( v SessionMessagePartStepStart ) error {
2025-05-29 01:35:05 +08:00
v . Type = "step-start"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
2025-05-29 01:35:05 +08:00
func ( t SessionMessagePart ) Discriminator ( ) ( string , error ) {
var discriminator struct {
Discriminator string ` json:"type" `
}
err := json . Unmarshal ( t . union , & discriminator )
return discriminator . Discriminator , err
2025-05-29 01:22:48 +08:00
}
2025-05-29 01:35:05 +08:00
func ( t SessionMessagePart ) ValueByDiscriminator ( ) ( interface { } , error ) {
discriminator , err := t . Discriminator ( )
2025-05-29 01:22:48 +08:00
if err != nil {
2025-05-29 01:35:05 +08:00
return nil , err
}
switch discriminator {
case "file" :
return t . AsSessionMessagePartFile ( )
case "reasoning" :
return t . AsSessionMessagePartReasoning ( )
case "source-url" :
return t . AsSessionMessagePartSourceUrl ( )
case "step-start" :
return t . AsSessionMessagePartStepStart ( )
case "text" :
return t . AsSessionMessagePartText ( )
case "tool-invocation" :
return t . AsSessionMessagePartToolInvocation ( )
default :
return nil , errors . New ( "unknown discriminator value: " + discriminator )
2025-05-29 01:22:48 +08:00
}
}
func ( t SessionMessagePart ) MarshalJSON ( ) ( [ ] byte , error ) {
b , err := t . union . MarshalJSON ( )
return b , err
}
func ( t * SessionMessagePart ) UnmarshalJSON ( b [ ] byte ) error {
err := t . union . UnmarshalJSON ( b )
return err
}
// AsSessionMessageToolInvocationToolCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolCall
func ( t SessionMessageToolInvocation ) AsSessionMessageToolInvocationToolCall ( ) ( SessionMessageToolInvocationToolCall , error ) {
var body SessionMessageToolInvocationToolCall
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessageToolInvocationToolCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolCall
func ( t * SessionMessageToolInvocation ) FromSessionMessageToolInvocationToolCall ( v SessionMessageToolInvocationToolCall ) error {
2025-05-29 01:35:05 +08:00
v . State = "call"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessageToolInvocationToolCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolCall
func ( t * SessionMessageToolInvocation ) MergeSessionMessageToolInvocationToolCall ( v SessionMessageToolInvocationToolCall ) error {
2025-05-29 01:35:05 +08:00
v . State = "call"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessageToolInvocationToolPartialCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolPartialCall
func ( t SessionMessageToolInvocation ) AsSessionMessageToolInvocationToolPartialCall ( ) ( SessionMessageToolInvocationToolPartialCall , error ) {
var body SessionMessageToolInvocationToolPartialCall
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessageToolInvocationToolPartialCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolPartialCall
func ( t * SessionMessageToolInvocation ) FromSessionMessageToolInvocationToolPartialCall ( v SessionMessageToolInvocationToolPartialCall ) error {
2025-05-29 01:35:05 +08:00
v . State = "partial-call"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessageToolInvocationToolPartialCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolPartialCall
func ( t * SessionMessageToolInvocation ) MergeSessionMessageToolInvocationToolPartialCall ( v SessionMessageToolInvocationToolPartialCall ) error {
2025-05-29 01:35:05 +08:00
v . State = "partial-call"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
// AsSessionMessageToolInvocationToolResult returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolResult
func ( t SessionMessageToolInvocation ) AsSessionMessageToolInvocationToolResult ( ) ( SessionMessageToolInvocationToolResult , error ) {
var body SessionMessageToolInvocationToolResult
err := json . Unmarshal ( t . union , & body )
return body , err
}
// FromSessionMessageToolInvocationToolResult overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolResult
func ( t * SessionMessageToolInvocation ) FromSessionMessageToolInvocationToolResult ( v SessionMessageToolInvocationToolResult ) error {
2025-05-29 01:35:05 +08:00
v . State = "result"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
t . union = b
return err
}
// MergeSessionMessageToolInvocationToolResult performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolResult
func ( t * SessionMessageToolInvocation ) MergeSessionMessageToolInvocationToolResult ( v SessionMessageToolInvocationToolResult ) error {
2025-05-29 01:35:05 +08:00
v . State = "result"
2025-05-29 01:22:48 +08:00
b , err := json . Marshal ( v )
if err != nil {
return err
}
merged , err := runtime . JSONMerge ( t . union , b )
t . union = merged
return err
}
2025-05-29 01:35:05 +08:00
func ( t SessionMessageToolInvocation ) Discriminator ( ) ( string , error ) {
var discriminator struct {
Discriminator string ` json:"state" `
}
err := json . Unmarshal ( t . union , & discriminator )
return discriminator . Discriminator , err
}
func ( t SessionMessageToolInvocation ) ValueByDiscriminator ( ) ( interface { } , error ) {
discriminator , err := t . Discriminator ( )
if err != nil {
return nil , err
}
switch discriminator {
case "call" :
return t . AsSessionMessageToolInvocationToolCall ( )
case "partial-call" :
return t . AsSessionMessageToolInvocationToolPartialCall ( )
case "result" :
return t . AsSessionMessageToolInvocationToolResult ( )
default :
return nil , errors . New ( "unknown discriminator value: " + discriminator )
}
}
2025-05-29 01:22:48 +08:00
func ( t SessionMessageToolInvocation ) MarshalJSON ( ) ( [ ] byte , error ) {
b , err := t . union . MarshalJSON ( )
return b , err
}
func ( t * SessionMessageToolInvocation ) UnmarshalJSON ( b [ ] byte ) error {
err := t . union . UnmarshalJSON ( b )
return err
}
2025-05-19 10:30:41 +08:00
// RequestEditorFn is the function signature for the RequestEditor callback function
type RequestEditorFn func ( ctx context . Context , req * http . Request ) error
// Doer performs HTTP requests.
//
// The standard http.Client implements this interface.
type HttpRequestDoer interface {
Do ( req * http . Request ) ( * http . Response , error )
}
// Client which conforms to the OpenAPI3 specification for this service.
type Client struct {
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example. This can contain a path relative
// to the server, such as https://api.deepmap.com/dev-test, and all the
// paths in the swagger spec will be appended to the server.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client HttpRequestDoer
// A list of callbacks for modifying requests which are generated before sending over
// the network.
RequestEditors [ ] RequestEditorFn
}
// ClientOption allows setting custom parameters during construction
type ClientOption func ( * Client ) error
// Creates a new Client, with reasonable defaults
func NewClient ( server string , opts ... ClientOption ) ( * Client , error ) {
// create a client with sane default values
client := Client {
Server : server ,
}
// mutate client and add all optional params
for _ , o := range opts {
if err := o ( & client ) ; err != nil {
return nil , err
}
}
// ensure the server URL always has a trailing slash
if ! strings . HasSuffix ( client . Server , "/" ) {
client . Server += "/"
}
// create httpClient, if not already present
if client . Client == nil {
client . Client = & http . Client { }
}
return & client , nil
}
// WithHTTPClient allows overriding the default Doer, which is
// automatically created using http.Client. This is useful for tests.
func WithHTTPClient ( doer HttpRequestDoer ) ClientOption {
return func ( c * Client ) error {
c . Client = doer
return nil
}
}
// WithRequestEditorFn allows setting up a callback function, which will be
// called right before sending the request. This can be used to mutate the request.
func WithRequestEditorFn ( fn RequestEditorFn ) ClientOption {
return func ( c * Client ) error {
c . RequestEditors = append ( c . RequestEditors , fn )
return nil
}
}
// The interface specification for the client above.
type ClientInterface interface {
2025-05-29 00:53:22 +08:00
// PostProviderList request
PostProviderList ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * http . Response , error )
2025-05-19 10:30:41 +08:00
// PostSessionChatWithBody request with any body
PostSessionChatWithBody ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * http . Response , error )
PostSessionChat ( ctx context . Context , body PostSessionChatJSONRequestBody , reqEditors ... RequestEditorFn ) ( * http . Response , error )
// PostSessionCreate request
PostSessionCreate ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * http . Response , error )
2025-05-27 06:14:36 +08:00
2025-05-28 03:35:48 +08:00
// PostSessionList request
PostSessionList ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * http . Response , error )
2025-05-27 06:14:36 +08:00
// PostSessionMessagesWithBody request with any body
PostSessionMessagesWithBody ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * http . Response , error )
PostSessionMessages ( ctx context . Context , body PostSessionMessagesJSONRequestBody , reqEditors ... RequestEditorFn ) ( * http . Response , error )
// PostSessionShareWithBody request with any body
PostSessionShareWithBody ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * http . Response , error )
PostSessionShare ( ctx context . Context , body PostSessionShareJSONRequestBody , reqEditors ... RequestEditorFn ) ( * http . Response , error )
2025-05-19 10:30:41 +08:00
}
2025-05-29 00:53:22 +08:00
func ( c * Client ) PostProviderList ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostProviderListRequest ( 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 )
}
2025-05-19 10:30:41 +08:00
func ( c * Client ) PostSessionChatWithBody ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostSessionChatRequestWithBody ( c . Server , contentType , body )
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 ) PostSessionChat ( ctx context . Context , body PostSessionChatJSONRequestBody , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostSessionChatRequest ( c . Server , body )
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 ) PostSessionCreate ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostSessionCreateRequest ( 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 )
}
2025-05-28 03:35:48 +08:00
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 )
}
2025-05-27 06:14:36 +08:00
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 {
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 ) PostSessionMessages ( ctx context . Context , body PostSessionMessagesJSONRequestBody , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostSessionMessagesRequest ( c . Server , body )
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 ) PostSessionShareWithBody ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostSessionShareRequestWithBody ( c . Server , contentType , body )
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 ) PostSessionShare ( ctx context . Context , body PostSessionShareJSONRequestBody , reqEditors ... RequestEditorFn ) ( * http . Response , error ) {
req , err := NewPostSessionShareRequest ( c . Server , body )
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 )
}
2025-05-29 00:53:22 +08:00
// NewPostProviderListRequest generates requests for PostProviderList
func NewPostProviderListRequest ( server string ) ( * http . Request , error ) {
var err error
serverURL , err := url . Parse ( server )
if err != nil {
return nil , err
}
operationPath := fmt . Sprintf ( "/provider_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
}
2025-05-19 10:30:41 +08:00
// NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
func NewPostSessionChatRequest ( server string , body PostSessionChatJSONRequestBody ) ( * http . Request , error ) {
var bodyReader io . Reader
buf , err := json . Marshal ( body )
if err != nil {
return nil , err
}
bodyReader = bytes . NewReader ( buf )
return NewPostSessionChatRequestWithBody ( server , "application/json" , bodyReader )
}
// NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
func NewPostSessionChatRequestWithBody ( server string , contentType string , body io . Reader ) ( * http . Request , error ) {
var err error
serverURL , err := url . Parse ( server )
if err != nil {
return nil , err
}
operationPath := fmt . Sprintf ( "/session_chat" )
if operationPath [ 0 ] == '/' {
operationPath = "." + operationPath
}
queryURL , err := serverURL . Parse ( operationPath )
if err != nil {
return nil , err
}
req , err := http . NewRequest ( "POST" , queryURL . String ( ) , body )
if err != nil {
return nil , err
}
req . Header . Add ( "Content-Type" , contentType )
return req , nil
}
// NewPostSessionCreateRequest generates requests for PostSessionCreate
func NewPostSessionCreateRequest ( server string ) ( * http . Request , error ) {
var err error
serverURL , err := url . Parse ( server )
if err != nil {
return nil , err
}
operationPath := fmt . Sprintf ( "/session_create" )
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
}
2025-05-28 03:35:48 +08:00
// 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
}
2025-05-27 06:14:36 +08:00
// NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
func NewPostSessionMessagesRequest ( server string , body PostSessionMessagesJSONRequestBody ) ( * http . Request , error ) {
var bodyReader io . Reader
buf , err := json . Marshal ( body )
if err != nil {
return nil , err
}
bodyReader = bytes . NewReader ( buf )
return NewPostSessionMessagesRequestWithBody ( server , "application/json" , bodyReader )
}
// NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
func NewPostSessionMessagesRequestWithBody ( server string , contentType string , body io . Reader ) ( * http . Request , error ) {
var err error
serverURL , err := url . Parse ( server )
if err != nil {
return nil , err
}
operationPath := fmt . Sprintf ( "/session_messages" )
if operationPath [ 0 ] == '/' {
operationPath = "." + operationPath
}
queryURL , err := serverURL . Parse ( operationPath )
if err != nil {
return nil , err
}
req , err := http . NewRequest ( "POST" , queryURL . String ( ) , body )
if err != nil {
return nil , err
}
req . Header . Add ( "Content-Type" , contentType )
return req , nil
}
// NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
func NewPostSessionShareRequest ( server string , body PostSessionShareJSONRequestBody ) ( * http . Request , error ) {
var bodyReader io . Reader
buf , err := json . Marshal ( body )
if err != nil {
return nil , err
}
bodyReader = bytes . NewReader ( buf )
return NewPostSessionShareRequestWithBody ( server , "application/json" , bodyReader )
}
// NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
func NewPostSessionShareRequestWithBody ( server string , contentType string , body io . Reader ) ( * http . Request , error ) {
var err error
serverURL , err := url . Parse ( server )
if err != nil {
return nil , err
}
operationPath := fmt . Sprintf ( "/session_share" )
if operationPath [ 0 ] == '/' {
operationPath = "." + operationPath
}
queryURL , err := serverURL . Parse ( operationPath )
if err != nil {
return nil , err
}
req , err := http . NewRequest ( "POST" , queryURL . String ( ) , body )
if err != nil {
return nil , err
}
req . Header . Add ( "Content-Type" , contentType )
return req , nil
}
2025-05-19 10:30:41 +08:00
func ( c * Client ) applyEditors ( ctx context . Context , req * http . Request , additionalEditors [ ] RequestEditorFn ) error {
for _ , r := range c . RequestEditors {
if err := r ( ctx , req ) ; err != nil {
return err
}
}
for _ , r := range additionalEditors {
if err := r ( ctx , req ) ; err != nil {
return err
}
}
return nil
}
// ClientWithResponses builds on ClientInterface to offer response payloads
type ClientWithResponses struct {
ClientInterface
}
// NewClientWithResponses creates a new ClientWithResponses, which wraps
// Client with return type handling
func NewClientWithResponses ( server string , opts ... ClientOption ) ( * ClientWithResponses , error ) {
client , err := NewClient ( server , opts ... )
if err != nil {
return nil , err
}
return & ClientWithResponses { client } , nil
}
// WithBaseURL overrides the baseURL.
func WithBaseURL ( baseURL string ) ClientOption {
return func ( c * Client ) error {
newBaseURL , err := url . Parse ( baseURL )
if err != nil {
return err
}
c . Server = newBaseURL . String ( )
return nil
}
}
// ClientWithResponsesInterface is the interface specification for the client with responses above.
type ClientWithResponsesInterface interface {
2025-05-29 00:53:22 +08:00
// PostProviderListWithResponse request
PostProviderListWithResponse ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * PostProviderListResponse , error )
2025-05-19 10:30:41 +08:00
// PostSessionChatWithBodyWithResponse request with any body
PostSessionChatWithBodyWithResponse ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * PostSessionChatResponse , error )
PostSessionChatWithResponse ( ctx context . Context , body PostSessionChatJSONRequestBody , reqEditors ... RequestEditorFn ) ( * PostSessionChatResponse , error )
// PostSessionCreateWithResponse request
PostSessionCreateWithResponse ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * PostSessionCreateResponse , error )
2025-05-27 06:14:36 +08:00
2025-05-28 03:35:48 +08:00
// PostSessionListWithResponse request
PostSessionListWithResponse ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * PostSessionListResponse , error )
2025-05-27 06:14:36 +08:00
// PostSessionMessagesWithBodyWithResponse request with any body
PostSessionMessagesWithBodyWithResponse ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * PostSessionMessagesResponse , error )
PostSessionMessagesWithResponse ( ctx context . Context , body PostSessionMessagesJSONRequestBody , reqEditors ... RequestEditorFn ) ( * PostSessionMessagesResponse , error )
// PostSessionShareWithBodyWithResponse request with any body
PostSessionShareWithBodyWithResponse ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * PostSessionShareResponse , error )
PostSessionShareWithResponse ( ctx context . Context , body PostSessionShareJSONRequestBody , reqEditors ... RequestEditorFn ) ( * PostSessionShareResponse , error )
2025-05-19 10:30:41 +08:00
}
2025-05-29 00:53:22 +08:00
type PostProviderListResponse struct {
Body [ ] byte
HTTPResponse * http . Response
JSON200 * map [ string ] ProviderInfo
}
// Status returns HTTPResponse.Status
func ( r PostProviderListResponse ) Status ( ) string {
if r . HTTPResponse != nil {
return r . HTTPResponse . Status
}
return http . StatusText ( 0 )
}
// StatusCode returns HTTPResponse.StatusCode
func ( r PostProviderListResponse ) StatusCode ( ) int {
if r . HTTPResponse != nil {
return r . HTTPResponse . StatusCode
}
return 0
}
2025-05-19 10:30:41 +08:00
type PostSessionChatResponse struct {
Body [ ] byte
HTTPResponse * http . Response
}
// Status returns HTTPResponse.Status
func ( r PostSessionChatResponse ) Status ( ) string {
if r . HTTPResponse != nil {
return r . HTTPResponse . Status
}
return http . StatusText ( 0 )
}
// StatusCode returns HTTPResponse.StatusCode
func ( r PostSessionChatResponse ) StatusCode ( ) int {
if r . HTTPResponse != nil {
return r . HTTPResponse . StatusCode
}
return 0
}
type PostSessionCreateResponse struct {
Body [ ] byte
HTTPResponse * http . Response
JSON200 * SessionInfo
}
// Status returns HTTPResponse.Status
func ( r PostSessionCreateResponse ) Status ( ) string {
if r . HTTPResponse != nil {
return r . HTTPResponse . Status
}
return http . StatusText ( 0 )
}
// StatusCode returns HTTPResponse.StatusCode
func ( r PostSessionCreateResponse ) StatusCode ( ) int {
if r . HTTPResponse != nil {
return r . HTTPResponse . StatusCode
}
return 0
}
2025-05-28 03:35:48 +08:00
type PostSessionListResponse struct {
Body [ ] byte
HTTPResponse * http . Response
JSON200 * [ ] struct {
2025-05-29 01:57:24 +08:00
Cost * float32 ` json:"cost,omitempty" `
Id string ` json:"id" `
ShareID * string ` json:"shareID,omitempty" `
Title string ` json:"title" `
2025-05-28 03:35:48 +08:00
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
}
2025-05-27 06:14:36 +08:00
type PostSessionMessagesResponse struct {
Body [ ] byte
HTTPResponse * http . Response
2025-05-29 01:22:48 +08:00
JSON200 * [ ] SessionMessage
2025-05-27 06:14:36 +08:00
}
// Status returns HTTPResponse.Status
func ( r PostSessionMessagesResponse ) Status ( ) string {
if r . HTTPResponse != nil {
return r . HTTPResponse . Status
}
return http . StatusText ( 0 )
}
// StatusCode returns HTTPResponse.StatusCode
func ( r PostSessionMessagesResponse ) StatusCode ( ) int {
if r . HTTPResponse != nil {
return r . HTTPResponse . StatusCode
}
return 0
}
type PostSessionShareResponse struct {
Body [ ] byte
HTTPResponse * http . Response
JSON200 * SessionInfo
}
// Status returns HTTPResponse.Status
func ( r PostSessionShareResponse ) Status ( ) string {
if r . HTTPResponse != nil {
return r . HTTPResponse . Status
}
return http . StatusText ( 0 )
}
// StatusCode returns HTTPResponse.StatusCode
func ( r PostSessionShareResponse ) StatusCode ( ) int {
if r . HTTPResponse != nil {
return r . HTTPResponse . StatusCode
}
return 0
}
2025-05-29 00:53:22 +08:00
// PostProviderListWithResponse request returning *PostProviderListResponse
func ( c * ClientWithResponses ) PostProviderListWithResponse ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * PostProviderListResponse , error ) {
rsp , err := c . PostProviderList ( ctx , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostProviderListResponse ( rsp )
}
2025-05-19 10:30:41 +08:00
// PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
func ( c * ClientWithResponses ) PostSessionChatWithBodyWithResponse ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * PostSessionChatResponse , error ) {
rsp , err := c . PostSessionChatWithBody ( ctx , contentType , body , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostSessionChatResponse ( rsp )
}
func ( c * ClientWithResponses ) PostSessionChatWithResponse ( ctx context . Context , body PostSessionChatJSONRequestBody , reqEditors ... RequestEditorFn ) ( * PostSessionChatResponse , error ) {
rsp , err := c . PostSessionChat ( ctx , body , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostSessionChatResponse ( rsp )
}
// PostSessionCreateWithResponse request returning *PostSessionCreateResponse
func ( c * ClientWithResponses ) PostSessionCreateWithResponse ( ctx context . Context , reqEditors ... RequestEditorFn ) ( * PostSessionCreateResponse , error ) {
rsp , err := c . PostSessionCreate ( ctx , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostSessionCreateResponse ( rsp )
}
2025-05-28 03:35:48 +08:00
// 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 )
}
2025-05-27 06:14:36 +08:00
// 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 ... )
if err != nil {
return nil , err
}
return ParsePostSessionMessagesResponse ( rsp )
}
func ( c * ClientWithResponses ) PostSessionMessagesWithResponse ( ctx context . Context , body PostSessionMessagesJSONRequestBody , reqEditors ... RequestEditorFn ) ( * PostSessionMessagesResponse , error ) {
rsp , err := c . PostSessionMessages ( ctx , body , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostSessionMessagesResponse ( rsp )
}
// PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
func ( c * ClientWithResponses ) PostSessionShareWithBodyWithResponse ( ctx context . Context , contentType string , body io . Reader , reqEditors ... RequestEditorFn ) ( * PostSessionShareResponse , error ) {
rsp , err := c . PostSessionShareWithBody ( ctx , contentType , body , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostSessionShareResponse ( rsp )
}
func ( c * ClientWithResponses ) PostSessionShareWithResponse ( ctx context . Context , body PostSessionShareJSONRequestBody , reqEditors ... RequestEditorFn ) ( * PostSessionShareResponse , error ) {
rsp , err := c . PostSessionShare ( ctx , body , reqEditors ... )
if err != nil {
return nil , err
}
return ParsePostSessionShareResponse ( rsp )
}
2025-05-29 00:53:22 +08:00
// ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
func ParsePostProviderListResponse ( rsp * http . Response ) ( * PostProviderListResponse , error ) {
bodyBytes , err := io . ReadAll ( rsp . Body )
defer func ( ) { _ = rsp . Body . Close ( ) } ( )
if err != nil {
return nil , err
}
response := & PostProviderListResponse {
Body : bodyBytes ,
HTTPResponse : rsp ,
}
switch {
case strings . Contains ( rsp . Header . Get ( "Content-Type" ) , "json" ) && rsp . StatusCode == 200 :
var dest map [ string ] ProviderInfo
if err := json . Unmarshal ( bodyBytes , & dest ) ; err != nil {
return nil , err
}
response . JSON200 = & dest
}
return response , nil
}
2025-05-19 10:30:41 +08:00
// ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
func ParsePostSessionChatResponse ( rsp * http . Response ) ( * PostSessionChatResponse , error ) {
bodyBytes , err := io . ReadAll ( rsp . Body )
defer func ( ) { _ = rsp . Body . Close ( ) } ( )
if err != nil {
return nil , err
}
response := & PostSessionChatResponse {
Body : bodyBytes ,
HTTPResponse : rsp ,
}
return response , nil
}
// ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
func ParsePostSessionCreateResponse ( rsp * http . Response ) ( * PostSessionCreateResponse , error ) {
bodyBytes , err := io . ReadAll ( rsp . Body )
defer func ( ) { _ = rsp . Body . Close ( ) } ( )
if err != nil {
return nil , err
}
response := & PostSessionCreateResponse {
Body : bodyBytes ,
HTTPResponse : rsp ,
}
switch {
case strings . Contains ( rsp . Header . Get ( "Content-Type" ) , "json" ) && rsp . StatusCode == 200 :
var dest SessionInfo
if err := json . Unmarshal ( bodyBytes , & dest ) ; err != nil {
return nil , err
}
response . JSON200 = & dest
}
return response , nil
}
2025-05-27 06:14:36 +08:00
2025-05-28 03:35:48 +08:00
// 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 {
2025-05-29 01:57:24 +08:00
Cost * float32 ` json:"cost,omitempty" `
Id string ` json:"id" `
ShareID * string ` json:"shareID,omitempty" `
Title string ` json:"title" `
2025-05-28 03:35:48 +08:00
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
}
2025-05-27 06:14:36 +08:00
// ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
func ParsePostSessionMessagesResponse ( rsp * http . Response ) ( * PostSessionMessagesResponse , error ) {
bodyBytes , err := io . ReadAll ( rsp . Body )
defer func ( ) { _ = rsp . Body . Close ( ) } ( )
if err != nil {
return nil , err
}
response := & PostSessionMessagesResponse {
Body : bodyBytes ,
HTTPResponse : rsp ,
}
switch {
case strings . Contains ( rsp . Header . Get ( "Content-Type" ) , "json" ) && rsp . StatusCode == 200 :
2025-05-29 01:22:48 +08:00
var dest [ ] SessionMessage
2025-05-27 06:14:36 +08:00
if err := json . Unmarshal ( bodyBytes , & dest ) ; err != nil {
return nil , err
}
response . JSON200 = & dest
}
return response , nil
}
// ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
func ParsePostSessionShareResponse ( rsp * http . Response ) ( * PostSessionShareResponse , error ) {
bodyBytes , err := io . ReadAll ( rsp . Body )
defer func ( ) { _ = rsp . Body . Close ( ) } ( )
if err != nil {
return nil , err
}
response := & PostSessionShareResponse {
Body : bodyBytes ,
HTTPResponse : rsp ,
}
switch {
case strings . Contains ( rsp . Header . Get ( "Content-Type" ) , "json" ) && rsp . StatusCode == 200 :
var dest SessionInfo
if err := json . Unmarshal ( bodyBytes , & dest ) ; err != nil {
return nil , err
}
response . JSON200 = & dest
}
return response , nil
}