generated-client.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. // Package client provides primitives to interact with the openapi HTTP API.
  2. //
  3. // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
  4. package client
  5. import (
  6. "bytes"
  7. "context"
  8. "encoding/json"
  9. "fmt"
  10. "io"
  11. "net/http"
  12. "net/url"
  13. "strings"
  14. )
  15. // ProviderInfo defines model for Provider.Info.
  16. type ProviderInfo struct {
  17. Models *map[string]struct {
  18. Attachment bool `json:"attachment"`
  19. ContextWindow float32 `json:"contextWindow"`
  20. Cost struct {
  21. Input float32 `json:"input"`
  22. InputCached float32 `json:"inputCached"`
  23. Output float32 `json:"output"`
  24. OutputCached float32 `json:"outputCached"`
  25. } `json:"cost"`
  26. MaxTokens float32 `json:"maxTokens"`
  27. Name *string `json:"name,omitempty"`
  28. } `json:"models,omitempty"`
  29. Options *map[string]interface{} `json:"options,omitempty"`
  30. }
  31. // SessionInfo defines model for Session.Info.
  32. type SessionInfo struct {
  33. Id string `json:"id"`
  34. ShareID *string `json:"shareID,omitempty"`
  35. Title string `json:"title"`
  36. Tokens struct {
  37. Input float32 `json:"input"`
  38. Output float32 `json:"output"`
  39. Reasoning float32 `json:"reasoning"`
  40. } `json:"tokens"`
  41. }
  42. // PostSessionChatJSONBody defines parameters for PostSessionChat.
  43. type PostSessionChatJSONBody struct {
  44. ModelID string `json:"modelID"`
  45. Parts *interface{} `json:"parts,omitempty"`
  46. ProviderID string `json:"providerID"`
  47. SessionID string `json:"sessionID"`
  48. }
  49. // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
  50. type PostSessionMessagesJSONBody struct {
  51. SessionID string `json:"sessionID"`
  52. }
  53. // PostSessionShareJSONBody defines parameters for PostSessionShare.
  54. type PostSessionShareJSONBody struct {
  55. SessionID string `json:"sessionID"`
  56. }
  57. // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
  58. type PostSessionChatJSONRequestBody PostSessionChatJSONBody
  59. // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
  60. type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
  61. // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
  62. type PostSessionShareJSONRequestBody PostSessionShareJSONBody
  63. // RequestEditorFn is the function signature for the RequestEditor callback function
  64. type RequestEditorFn func(ctx context.Context, req *http.Request) error
  65. // Doer performs HTTP requests.
  66. //
  67. // The standard http.Client implements this interface.
  68. type HttpRequestDoer interface {
  69. Do(req *http.Request) (*http.Response, error)
  70. }
  71. // Client which conforms to the OpenAPI3 specification for this service.
  72. type Client struct {
  73. // The endpoint of the server conforming to this interface, with scheme,
  74. // https://api.deepmap.com for example. This can contain a path relative
  75. // to the server, such as https://api.deepmap.com/dev-test, and all the
  76. // paths in the swagger spec will be appended to the server.
  77. Server string
  78. // Doer for performing requests, typically a *http.Client with any
  79. // customized settings, such as certificate chains.
  80. Client HttpRequestDoer
  81. // A list of callbacks for modifying requests which are generated before sending over
  82. // the network.
  83. RequestEditors []RequestEditorFn
  84. }
  85. // ClientOption allows setting custom parameters during construction
  86. type ClientOption func(*Client) error
  87. // Creates a new Client, with reasonable defaults
  88. func NewClient(server string, opts ...ClientOption) (*Client, error) {
  89. // create a client with sane default values
  90. client := Client{
  91. Server: server,
  92. }
  93. // mutate client and add all optional params
  94. for _, o := range opts {
  95. if err := o(&client); err != nil {
  96. return nil, err
  97. }
  98. }
  99. // ensure the server URL always has a trailing slash
  100. if !strings.HasSuffix(client.Server, "/") {
  101. client.Server += "/"
  102. }
  103. // create httpClient, if not already present
  104. if client.Client == nil {
  105. client.Client = &http.Client{}
  106. }
  107. return &client, nil
  108. }
  109. // WithHTTPClient allows overriding the default Doer, which is
  110. // automatically created using http.Client. This is useful for tests.
  111. func WithHTTPClient(doer HttpRequestDoer) ClientOption {
  112. return func(c *Client) error {
  113. c.Client = doer
  114. return nil
  115. }
  116. }
  117. // WithRequestEditorFn allows setting up a callback function, which will be
  118. // called right before sending the request. This can be used to mutate the request.
  119. func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
  120. return func(c *Client) error {
  121. c.RequestEditors = append(c.RequestEditors, fn)
  122. return nil
  123. }
  124. }
  125. // The interface specification for the client above.
  126. type ClientInterface interface {
  127. // PostProviderList request
  128. PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  129. // PostSessionChatWithBody request with any body
  130. PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  131. PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  132. // PostSessionCreate request
  133. PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  134. // PostSessionList request
  135. PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  136. // PostSessionMessagesWithBody request with any body
  137. PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  138. PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  139. // PostSessionShareWithBody request with any body
  140. PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  141. PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  142. }
  143. func (c *Client) PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  144. req, err := NewPostProviderListRequest(c.Server)
  145. if err != nil {
  146. return nil, err
  147. }
  148. req = req.WithContext(ctx)
  149. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  150. return nil, err
  151. }
  152. return c.Client.Do(req)
  153. }
  154. func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  155. req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
  156. if err != nil {
  157. return nil, err
  158. }
  159. req = req.WithContext(ctx)
  160. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  161. return nil, err
  162. }
  163. return c.Client.Do(req)
  164. }
  165. func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  166. req, err := NewPostSessionChatRequest(c.Server, body)
  167. if err != nil {
  168. return nil, err
  169. }
  170. req = req.WithContext(ctx)
  171. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  172. return nil, err
  173. }
  174. return c.Client.Do(req)
  175. }
  176. func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  177. req, err := NewPostSessionCreateRequest(c.Server)
  178. if err != nil {
  179. return nil, err
  180. }
  181. req = req.WithContext(ctx)
  182. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  183. return nil, err
  184. }
  185. return c.Client.Do(req)
  186. }
  187. func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  188. req, err := NewPostSessionListRequest(c.Server)
  189. if err != nil {
  190. return nil, err
  191. }
  192. req = req.WithContext(ctx)
  193. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  194. return nil, err
  195. }
  196. return c.Client.Do(req)
  197. }
  198. func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  199. req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
  200. if err != nil {
  201. return nil, err
  202. }
  203. req = req.WithContext(ctx)
  204. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  205. return nil, err
  206. }
  207. return c.Client.Do(req)
  208. }
  209. func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  210. req, err := NewPostSessionMessagesRequest(c.Server, body)
  211. if err != nil {
  212. return nil, err
  213. }
  214. req = req.WithContext(ctx)
  215. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  216. return nil, err
  217. }
  218. return c.Client.Do(req)
  219. }
  220. func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  221. req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
  222. if err != nil {
  223. return nil, err
  224. }
  225. req = req.WithContext(ctx)
  226. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  227. return nil, err
  228. }
  229. return c.Client.Do(req)
  230. }
  231. func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  232. req, err := NewPostSessionShareRequest(c.Server, body)
  233. if err != nil {
  234. return nil, err
  235. }
  236. req = req.WithContext(ctx)
  237. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  238. return nil, err
  239. }
  240. return c.Client.Do(req)
  241. }
  242. // NewPostProviderListRequest generates requests for PostProviderList
  243. func NewPostProviderListRequest(server string) (*http.Request, error) {
  244. var err error
  245. serverURL, err := url.Parse(server)
  246. if err != nil {
  247. return nil, err
  248. }
  249. operationPath := fmt.Sprintf("/provider_list")
  250. if operationPath[0] == '/' {
  251. operationPath = "." + operationPath
  252. }
  253. queryURL, err := serverURL.Parse(operationPath)
  254. if err != nil {
  255. return nil, err
  256. }
  257. req, err := http.NewRequest("POST", queryURL.String(), nil)
  258. if err != nil {
  259. return nil, err
  260. }
  261. return req, nil
  262. }
  263. // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
  264. func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
  265. var bodyReader io.Reader
  266. buf, err := json.Marshal(body)
  267. if err != nil {
  268. return nil, err
  269. }
  270. bodyReader = bytes.NewReader(buf)
  271. return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
  272. }
  273. // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
  274. func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  275. var err error
  276. serverURL, err := url.Parse(server)
  277. if err != nil {
  278. return nil, err
  279. }
  280. operationPath := fmt.Sprintf("/session_chat")
  281. if operationPath[0] == '/' {
  282. operationPath = "." + operationPath
  283. }
  284. queryURL, err := serverURL.Parse(operationPath)
  285. if err != nil {
  286. return nil, err
  287. }
  288. req, err := http.NewRequest("POST", queryURL.String(), body)
  289. if err != nil {
  290. return nil, err
  291. }
  292. req.Header.Add("Content-Type", contentType)
  293. return req, nil
  294. }
  295. // NewPostSessionCreateRequest generates requests for PostSessionCreate
  296. func NewPostSessionCreateRequest(server string) (*http.Request, error) {
  297. var err error
  298. serverURL, err := url.Parse(server)
  299. if err != nil {
  300. return nil, err
  301. }
  302. operationPath := fmt.Sprintf("/session_create")
  303. if operationPath[0] == '/' {
  304. operationPath = "." + operationPath
  305. }
  306. queryURL, err := serverURL.Parse(operationPath)
  307. if err != nil {
  308. return nil, err
  309. }
  310. req, err := http.NewRequest("POST", queryURL.String(), nil)
  311. if err != nil {
  312. return nil, err
  313. }
  314. return req, nil
  315. }
  316. // NewPostSessionListRequest generates requests for PostSessionList
  317. func NewPostSessionListRequest(server string) (*http.Request, error) {
  318. var err error
  319. serverURL, err := url.Parse(server)
  320. if err != nil {
  321. return nil, err
  322. }
  323. operationPath := fmt.Sprintf("/session_list")
  324. if operationPath[0] == '/' {
  325. operationPath = "." + operationPath
  326. }
  327. queryURL, err := serverURL.Parse(operationPath)
  328. if err != nil {
  329. return nil, err
  330. }
  331. req, err := http.NewRequest("POST", queryURL.String(), nil)
  332. if err != nil {
  333. return nil, err
  334. }
  335. return req, nil
  336. }
  337. // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
  338. func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
  339. var bodyReader io.Reader
  340. buf, err := json.Marshal(body)
  341. if err != nil {
  342. return nil, err
  343. }
  344. bodyReader = bytes.NewReader(buf)
  345. return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
  346. }
  347. // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
  348. func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  349. var err error
  350. serverURL, err := url.Parse(server)
  351. if err != nil {
  352. return nil, err
  353. }
  354. operationPath := fmt.Sprintf("/session_messages")
  355. if operationPath[0] == '/' {
  356. operationPath = "." + operationPath
  357. }
  358. queryURL, err := serverURL.Parse(operationPath)
  359. if err != nil {
  360. return nil, err
  361. }
  362. req, err := http.NewRequest("POST", queryURL.String(), body)
  363. if err != nil {
  364. return nil, err
  365. }
  366. req.Header.Add("Content-Type", contentType)
  367. return req, nil
  368. }
  369. // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
  370. func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
  371. var bodyReader io.Reader
  372. buf, err := json.Marshal(body)
  373. if err != nil {
  374. return nil, err
  375. }
  376. bodyReader = bytes.NewReader(buf)
  377. return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
  378. }
  379. // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
  380. func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  381. var err error
  382. serverURL, err := url.Parse(server)
  383. if err != nil {
  384. return nil, err
  385. }
  386. operationPath := fmt.Sprintf("/session_share")
  387. if operationPath[0] == '/' {
  388. operationPath = "." + operationPath
  389. }
  390. queryURL, err := serverURL.Parse(operationPath)
  391. if err != nil {
  392. return nil, err
  393. }
  394. req, err := http.NewRequest("POST", queryURL.String(), body)
  395. if err != nil {
  396. return nil, err
  397. }
  398. req.Header.Add("Content-Type", contentType)
  399. return req, nil
  400. }
  401. func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
  402. for _, r := range c.RequestEditors {
  403. if err := r(ctx, req); err != nil {
  404. return err
  405. }
  406. }
  407. for _, r := range additionalEditors {
  408. if err := r(ctx, req); err != nil {
  409. return err
  410. }
  411. }
  412. return nil
  413. }
  414. // ClientWithResponses builds on ClientInterface to offer response payloads
  415. type ClientWithResponses struct {
  416. ClientInterface
  417. }
  418. // NewClientWithResponses creates a new ClientWithResponses, which wraps
  419. // Client with return type handling
  420. func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
  421. client, err := NewClient(server, opts...)
  422. if err != nil {
  423. return nil, err
  424. }
  425. return &ClientWithResponses{client}, nil
  426. }
  427. // WithBaseURL overrides the baseURL.
  428. func WithBaseURL(baseURL string) ClientOption {
  429. return func(c *Client) error {
  430. newBaseURL, err := url.Parse(baseURL)
  431. if err != nil {
  432. return err
  433. }
  434. c.Server = newBaseURL.String()
  435. return nil
  436. }
  437. }
  438. // ClientWithResponsesInterface is the interface specification for the client with responses above.
  439. type ClientWithResponsesInterface interface {
  440. // PostProviderListWithResponse request
  441. PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error)
  442. // PostSessionChatWithBodyWithResponse request with any body
  443. PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  444. PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  445. // PostSessionCreateWithResponse request
  446. PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
  447. // PostSessionListWithResponse request
  448. PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
  449. // PostSessionMessagesWithBodyWithResponse request with any body
  450. PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  451. PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  452. // PostSessionShareWithBodyWithResponse request with any body
  453. PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  454. PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  455. }
  456. type PostProviderListResponse struct {
  457. Body []byte
  458. HTTPResponse *http.Response
  459. JSON200 *map[string]ProviderInfo
  460. }
  461. // Status returns HTTPResponse.Status
  462. func (r PostProviderListResponse) Status() string {
  463. if r.HTTPResponse != nil {
  464. return r.HTTPResponse.Status
  465. }
  466. return http.StatusText(0)
  467. }
  468. // StatusCode returns HTTPResponse.StatusCode
  469. func (r PostProviderListResponse) StatusCode() int {
  470. if r.HTTPResponse != nil {
  471. return r.HTTPResponse.StatusCode
  472. }
  473. return 0
  474. }
  475. type PostSessionChatResponse struct {
  476. Body []byte
  477. HTTPResponse *http.Response
  478. }
  479. // Status returns HTTPResponse.Status
  480. func (r PostSessionChatResponse) Status() string {
  481. if r.HTTPResponse != nil {
  482. return r.HTTPResponse.Status
  483. }
  484. return http.StatusText(0)
  485. }
  486. // StatusCode returns HTTPResponse.StatusCode
  487. func (r PostSessionChatResponse) StatusCode() int {
  488. if r.HTTPResponse != nil {
  489. return r.HTTPResponse.StatusCode
  490. }
  491. return 0
  492. }
  493. type PostSessionCreateResponse struct {
  494. Body []byte
  495. HTTPResponse *http.Response
  496. JSON200 *SessionInfo
  497. }
  498. // Status returns HTTPResponse.Status
  499. func (r PostSessionCreateResponse) Status() string {
  500. if r.HTTPResponse != nil {
  501. return r.HTTPResponse.Status
  502. }
  503. return http.StatusText(0)
  504. }
  505. // StatusCode returns HTTPResponse.StatusCode
  506. func (r PostSessionCreateResponse) StatusCode() int {
  507. if r.HTTPResponse != nil {
  508. return r.HTTPResponse.StatusCode
  509. }
  510. return 0
  511. }
  512. type PostSessionListResponse struct {
  513. Body []byte
  514. HTTPResponse *http.Response
  515. JSON200 *[]struct {
  516. Id string `json:"id"`
  517. ShareID *string `json:"shareID,omitempty"`
  518. Title string `json:"title"`
  519. Tokens struct {
  520. Input float32 `json:"input"`
  521. Output float32 `json:"output"`
  522. Reasoning float32 `json:"reasoning"`
  523. } `json:"tokens"`
  524. }
  525. }
  526. // Status returns HTTPResponse.Status
  527. func (r PostSessionListResponse) Status() string {
  528. if r.HTTPResponse != nil {
  529. return r.HTTPResponse.Status
  530. }
  531. return http.StatusText(0)
  532. }
  533. // StatusCode returns HTTPResponse.StatusCode
  534. func (r PostSessionListResponse) StatusCode() int {
  535. if r.HTTPResponse != nil {
  536. return r.HTTPResponse.StatusCode
  537. }
  538. return 0
  539. }
  540. type PostSessionMessagesResponse struct {
  541. Body []byte
  542. HTTPResponse *http.Response
  543. JSON200 *interface{}
  544. }
  545. // Status returns HTTPResponse.Status
  546. func (r PostSessionMessagesResponse) Status() string {
  547. if r.HTTPResponse != nil {
  548. return r.HTTPResponse.Status
  549. }
  550. return http.StatusText(0)
  551. }
  552. // StatusCode returns HTTPResponse.StatusCode
  553. func (r PostSessionMessagesResponse) StatusCode() int {
  554. if r.HTTPResponse != nil {
  555. return r.HTTPResponse.StatusCode
  556. }
  557. return 0
  558. }
  559. type PostSessionShareResponse struct {
  560. Body []byte
  561. HTTPResponse *http.Response
  562. JSON200 *SessionInfo
  563. }
  564. // Status returns HTTPResponse.Status
  565. func (r PostSessionShareResponse) Status() string {
  566. if r.HTTPResponse != nil {
  567. return r.HTTPResponse.Status
  568. }
  569. return http.StatusText(0)
  570. }
  571. // StatusCode returns HTTPResponse.StatusCode
  572. func (r PostSessionShareResponse) StatusCode() int {
  573. if r.HTTPResponse != nil {
  574. return r.HTTPResponse.StatusCode
  575. }
  576. return 0
  577. }
  578. // PostProviderListWithResponse request returning *PostProviderListResponse
  579. func (c *ClientWithResponses) PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error) {
  580. rsp, err := c.PostProviderList(ctx, reqEditors...)
  581. if err != nil {
  582. return nil, err
  583. }
  584. return ParsePostProviderListResponse(rsp)
  585. }
  586. // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
  587. func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  588. rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
  589. if err != nil {
  590. return nil, err
  591. }
  592. return ParsePostSessionChatResponse(rsp)
  593. }
  594. func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  595. rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
  596. if err != nil {
  597. return nil, err
  598. }
  599. return ParsePostSessionChatResponse(rsp)
  600. }
  601. // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
  602. func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
  603. rsp, err := c.PostSessionCreate(ctx, reqEditors...)
  604. if err != nil {
  605. return nil, err
  606. }
  607. return ParsePostSessionCreateResponse(rsp)
  608. }
  609. // PostSessionListWithResponse request returning *PostSessionListResponse
  610. func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
  611. rsp, err := c.PostSessionList(ctx, reqEditors...)
  612. if err != nil {
  613. return nil, err
  614. }
  615. return ParsePostSessionListResponse(rsp)
  616. }
  617. // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
  618. func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  619. rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
  620. if err != nil {
  621. return nil, err
  622. }
  623. return ParsePostSessionMessagesResponse(rsp)
  624. }
  625. func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  626. rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
  627. if err != nil {
  628. return nil, err
  629. }
  630. return ParsePostSessionMessagesResponse(rsp)
  631. }
  632. // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
  633. func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  634. rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
  635. if err != nil {
  636. return nil, err
  637. }
  638. return ParsePostSessionShareResponse(rsp)
  639. }
  640. func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  641. rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
  642. if err != nil {
  643. return nil, err
  644. }
  645. return ParsePostSessionShareResponse(rsp)
  646. }
  647. // ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
  648. func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponse, error) {
  649. bodyBytes, err := io.ReadAll(rsp.Body)
  650. defer func() { _ = rsp.Body.Close() }()
  651. if err != nil {
  652. return nil, err
  653. }
  654. response := &PostProviderListResponse{
  655. Body: bodyBytes,
  656. HTTPResponse: rsp,
  657. }
  658. switch {
  659. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  660. var dest map[string]ProviderInfo
  661. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  662. return nil, err
  663. }
  664. response.JSON200 = &dest
  665. }
  666. return response, nil
  667. }
  668. // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
  669. func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
  670. bodyBytes, err := io.ReadAll(rsp.Body)
  671. defer func() { _ = rsp.Body.Close() }()
  672. if err != nil {
  673. return nil, err
  674. }
  675. response := &PostSessionChatResponse{
  676. Body: bodyBytes,
  677. HTTPResponse: rsp,
  678. }
  679. return response, nil
  680. }
  681. // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
  682. func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
  683. bodyBytes, err := io.ReadAll(rsp.Body)
  684. defer func() { _ = rsp.Body.Close() }()
  685. if err != nil {
  686. return nil, err
  687. }
  688. response := &PostSessionCreateResponse{
  689. Body: bodyBytes,
  690. HTTPResponse: rsp,
  691. }
  692. switch {
  693. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  694. var dest SessionInfo
  695. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  696. return nil, err
  697. }
  698. response.JSON200 = &dest
  699. }
  700. return response, nil
  701. }
  702. // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
  703. func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
  704. bodyBytes, err := io.ReadAll(rsp.Body)
  705. defer func() { _ = rsp.Body.Close() }()
  706. if err != nil {
  707. return nil, err
  708. }
  709. response := &PostSessionListResponse{
  710. Body: bodyBytes,
  711. HTTPResponse: rsp,
  712. }
  713. switch {
  714. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  715. var dest []struct {
  716. Id string `json:"id"`
  717. ShareID *string `json:"shareID,omitempty"`
  718. Title string `json:"title"`
  719. Tokens struct {
  720. Input float32 `json:"input"`
  721. Output float32 `json:"output"`
  722. Reasoning float32 `json:"reasoning"`
  723. } `json:"tokens"`
  724. }
  725. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  726. return nil, err
  727. }
  728. response.JSON200 = &dest
  729. }
  730. return response, nil
  731. }
  732. // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
  733. func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
  734. bodyBytes, err := io.ReadAll(rsp.Body)
  735. defer func() { _ = rsp.Body.Close() }()
  736. if err != nil {
  737. return nil, err
  738. }
  739. response := &PostSessionMessagesResponse{
  740. Body: bodyBytes,
  741. HTTPResponse: rsp,
  742. }
  743. switch {
  744. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  745. var dest interface{}
  746. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  747. return nil, err
  748. }
  749. response.JSON200 = &dest
  750. }
  751. return response, nil
  752. }
  753. // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
  754. func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
  755. bodyBytes, err := io.ReadAll(rsp.Body)
  756. defer func() { _ = rsp.Body.Close() }()
  757. if err != nil {
  758. return nil, err
  759. }
  760. response := &PostSessionShareResponse{
  761. Body: bodyBytes,
  762. HTTPResponse: rsp,
  763. }
  764. switch {
  765. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  766. var dest SessionInfo
  767. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  768. return nil, err
  769. }
  770. response.JSON200 = &dest
  771. }
  772. return response, nil
  773. }