generated-client.go 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  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. "github.com/oapi-codegen/runtime"
  15. )
  16. // Defines values for SessionMessageRole.
  17. const (
  18. Assistant SessionMessageRole = "assistant"
  19. System SessionMessageRole = "system"
  20. User SessionMessageRole = "user"
  21. )
  22. // ProviderInfo defines model for Provider.Info.
  23. type ProviderInfo struct {
  24. Models *map[string]struct {
  25. Attachment bool `json:"attachment"`
  26. ContextWindow float32 `json:"contextWindow"`
  27. Cost struct {
  28. Input float32 `json:"input"`
  29. InputCached float32 `json:"inputCached"`
  30. Output float32 `json:"output"`
  31. OutputCached float32 `json:"outputCached"`
  32. } `json:"cost"`
  33. MaxTokens float32 `json:"maxTokens"`
  34. Name *string `json:"name,omitempty"`
  35. } `json:"models,omitempty"`
  36. Options *map[string]interface{} `json:"options,omitempty"`
  37. }
  38. // SessionInfo defines model for Session.Info.
  39. type SessionInfo struct {
  40. Id string `json:"id"`
  41. ShareID *string `json:"shareID,omitempty"`
  42. Title string `json:"title"`
  43. Tokens struct {
  44. Input float32 `json:"input"`
  45. Output float32 `json:"output"`
  46. Reasoning float32 `json:"reasoning"`
  47. } `json:"tokens"`
  48. }
  49. // SessionMessage defines model for Session.Message.
  50. type SessionMessage struct {
  51. Id string `json:"id"`
  52. Metadata struct {
  53. SessionID string `json:"sessionID"`
  54. Time struct {
  55. Completed *float32 `json:"completed,omitempty"`
  56. Created float32 `json:"created"`
  57. } `json:"time"`
  58. Tool map[string]interface{} `json:"tool"`
  59. } `json:"metadata"`
  60. Parts []SessionMessagePart `json:"parts"`
  61. Role SessionMessageRole `json:"role"`
  62. }
  63. // SessionMessageRole defines model for SessionMessage.Role.
  64. type SessionMessageRole string
  65. // SessionMessagePart defines model for Session.Message.Part.
  66. type SessionMessagePart struct {
  67. union json.RawMessage
  68. }
  69. // SessionMessagePartData defines model for Session.Message.Part.Data.
  70. type SessionMessagePartData struct {
  71. Data *interface{} `json:"data,omitempty"`
  72. Id *string `json:"id,omitempty"`
  73. Type *interface{} `json:"type,omitempty"`
  74. }
  75. // SessionMessagePartFile defines model for Session.Message.Part.File.
  76. type SessionMessagePartFile struct {
  77. Filename *string `json:"filename,omitempty"`
  78. MediaType string `json:"mediaType"`
  79. Type string `json:"type"`
  80. Url string `json:"url"`
  81. }
  82. // SessionMessagePartReasoning defines model for Session.Message.Part.Reasoning.
  83. type SessionMessagePartReasoning struct {
  84. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  85. Text string `json:"text"`
  86. Type string `json:"type"`
  87. }
  88. // SessionMessagePartSourceUrl defines model for Session.Message.Part.SourceUrl.
  89. type SessionMessagePartSourceUrl struct {
  90. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  91. SourceId string `json:"sourceId"`
  92. Title *string `json:"title,omitempty"`
  93. Type string `json:"type"`
  94. Url string `json:"url"`
  95. }
  96. // SessionMessagePartStepStart defines model for Session.Message.Part.StepStart.
  97. type SessionMessagePartStepStart struct {
  98. Type string `json:"type"`
  99. }
  100. // SessionMessagePartText defines model for Session.Message.Part.Text.
  101. type SessionMessagePartText struct {
  102. Text string `json:"text"`
  103. Type string `json:"type"`
  104. }
  105. // SessionMessagePartToolInvocation defines model for Session.Message.Part.ToolInvocation.
  106. type SessionMessagePartToolInvocation struct {
  107. ToolInvocation SessionMessageToolInvocation `json:"toolInvocation"`
  108. Type string `json:"type"`
  109. }
  110. // SessionMessageToolInvocation defines model for Session.Message.ToolInvocation.
  111. type SessionMessageToolInvocation struct {
  112. union json.RawMessage
  113. }
  114. // SessionMessageToolInvocationToolCall defines model for Session.Message.ToolInvocation.ToolCall.
  115. type SessionMessageToolInvocationToolCall struct {
  116. Args map[string]interface{} `json:"args"`
  117. State string `json:"state"`
  118. Step *float32 `json:"step,omitempty"`
  119. ToolCallId string `json:"toolCallId"`
  120. ToolName string `json:"toolName"`
  121. }
  122. // SessionMessageToolInvocationToolPartialCall defines model for Session.Message.ToolInvocation.ToolPartialCall.
  123. type SessionMessageToolInvocationToolPartialCall struct {
  124. Args map[string]interface{} `json:"args"`
  125. State string `json:"state"`
  126. Step *float32 `json:"step,omitempty"`
  127. ToolCallId string `json:"toolCallId"`
  128. ToolName string `json:"toolName"`
  129. }
  130. // SessionMessageToolInvocationToolResult defines model for Session.Message.ToolInvocation.ToolResult.
  131. type SessionMessageToolInvocationToolResult struct {
  132. Args map[string]interface{} `json:"args"`
  133. Result string `json:"result"`
  134. State string `json:"state"`
  135. Step *float32 `json:"step,omitempty"`
  136. ToolCallId string `json:"toolCallId"`
  137. ToolName string `json:"toolName"`
  138. }
  139. // PostSessionChatJSONBody defines parameters for PostSessionChat.
  140. type PostSessionChatJSONBody struct {
  141. ModelID string `json:"modelID"`
  142. Parts []SessionMessagePart `json:"parts"`
  143. ProviderID string `json:"providerID"`
  144. SessionID string `json:"sessionID"`
  145. }
  146. // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
  147. type PostSessionMessagesJSONBody struct {
  148. SessionID string `json:"sessionID"`
  149. }
  150. // PostSessionShareJSONBody defines parameters for PostSessionShare.
  151. type PostSessionShareJSONBody struct {
  152. SessionID string `json:"sessionID"`
  153. }
  154. // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
  155. type PostSessionChatJSONRequestBody PostSessionChatJSONBody
  156. // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
  157. type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
  158. // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
  159. type PostSessionShareJSONRequestBody PostSessionShareJSONBody
  160. // AsSessionMessagePartText returns the union data inside the SessionMessagePart as a SessionMessagePartText
  161. func (t SessionMessagePart) AsSessionMessagePartText() (SessionMessagePartText, error) {
  162. var body SessionMessagePartText
  163. err := json.Unmarshal(t.union, &body)
  164. return body, err
  165. }
  166. // FromSessionMessagePartText overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartText
  167. func (t *SessionMessagePart) FromSessionMessagePartText(v SessionMessagePartText) error {
  168. b, err := json.Marshal(v)
  169. t.union = b
  170. return err
  171. }
  172. // MergeSessionMessagePartText performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartText
  173. func (t *SessionMessagePart) MergeSessionMessagePartText(v SessionMessagePartText) error {
  174. b, err := json.Marshal(v)
  175. if err != nil {
  176. return err
  177. }
  178. merged, err := runtime.JSONMerge(t.union, b)
  179. t.union = merged
  180. return err
  181. }
  182. // AsSessionMessagePartReasoning returns the union data inside the SessionMessagePart as a SessionMessagePartReasoning
  183. func (t SessionMessagePart) AsSessionMessagePartReasoning() (SessionMessagePartReasoning, error) {
  184. var body SessionMessagePartReasoning
  185. err := json.Unmarshal(t.union, &body)
  186. return body, err
  187. }
  188. // FromSessionMessagePartReasoning overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartReasoning
  189. func (t *SessionMessagePart) FromSessionMessagePartReasoning(v SessionMessagePartReasoning) error {
  190. b, err := json.Marshal(v)
  191. t.union = b
  192. return err
  193. }
  194. // MergeSessionMessagePartReasoning performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartReasoning
  195. func (t *SessionMessagePart) MergeSessionMessagePartReasoning(v SessionMessagePartReasoning) error {
  196. b, err := json.Marshal(v)
  197. if err != nil {
  198. return err
  199. }
  200. merged, err := runtime.JSONMerge(t.union, b)
  201. t.union = merged
  202. return err
  203. }
  204. // AsSessionMessagePartToolInvocation returns the union data inside the SessionMessagePart as a SessionMessagePartToolInvocation
  205. func (t SessionMessagePart) AsSessionMessagePartToolInvocation() (SessionMessagePartToolInvocation, error) {
  206. var body SessionMessagePartToolInvocation
  207. err := json.Unmarshal(t.union, &body)
  208. return body, err
  209. }
  210. // FromSessionMessagePartToolInvocation overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartToolInvocation
  211. func (t *SessionMessagePart) FromSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {
  212. b, err := json.Marshal(v)
  213. t.union = b
  214. return err
  215. }
  216. // MergeSessionMessagePartToolInvocation performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartToolInvocation
  217. func (t *SessionMessagePart) MergeSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {
  218. b, err := json.Marshal(v)
  219. if err != nil {
  220. return err
  221. }
  222. merged, err := runtime.JSONMerge(t.union, b)
  223. t.union = merged
  224. return err
  225. }
  226. // AsSessionMessagePartSourceUrl returns the union data inside the SessionMessagePart as a SessionMessagePartSourceUrl
  227. func (t SessionMessagePart) AsSessionMessagePartSourceUrl() (SessionMessagePartSourceUrl, error) {
  228. var body SessionMessagePartSourceUrl
  229. err := json.Unmarshal(t.union, &body)
  230. return body, err
  231. }
  232. // FromSessionMessagePartSourceUrl overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartSourceUrl
  233. func (t *SessionMessagePart) FromSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {
  234. b, err := json.Marshal(v)
  235. t.union = b
  236. return err
  237. }
  238. // MergeSessionMessagePartSourceUrl performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartSourceUrl
  239. func (t *SessionMessagePart) MergeSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {
  240. b, err := json.Marshal(v)
  241. if err != nil {
  242. return err
  243. }
  244. merged, err := runtime.JSONMerge(t.union, b)
  245. t.union = merged
  246. return err
  247. }
  248. // AsSessionMessagePartFile returns the union data inside the SessionMessagePart as a SessionMessagePartFile
  249. func (t SessionMessagePart) AsSessionMessagePartFile() (SessionMessagePartFile, error) {
  250. var body SessionMessagePartFile
  251. err := json.Unmarshal(t.union, &body)
  252. return body, err
  253. }
  254. // FromSessionMessagePartFile overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartFile
  255. func (t *SessionMessagePart) FromSessionMessagePartFile(v SessionMessagePartFile) error {
  256. b, err := json.Marshal(v)
  257. t.union = b
  258. return err
  259. }
  260. // MergeSessionMessagePartFile performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartFile
  261. func (t *SessionMessagePart) MergeSessionMessagePartFile(v SessionMessagePartFile) error {
  262. b, err := json.Marshal(v)
  263. if err != nil {
  264. return err
  265. }
  266. merged, err := runtime.JSONMerge(t.union, b)
  267. t.union = merged
  268. return err
  269. }
  270. // AsSessionMessagePartStepStart returns the union data inside the SessionMessagePart as a SessionMessagePartStepStart
  271. func (t SessionMessagePart) AsSessionMessagePartStepStart() (SessionMessagePartStepStart, error) {
  272. var body SessionMessagePartStepStart
  273. err := json.Unmarshal(t.union, &body)
  274. return body, err
  275. }
  276. // FromSessionMessagePartStepStart overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartStepStart
  277. func (t *SessionMessagePart) FromSessionMessagePartStepStart(v SessionMessagePartStepStart) error {
  278. b, err := json.Marshal(v)
  279. t.union = b
  280. return err
  281. }
  282. // MergeSessionMessagePartStepStart performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartStepStart
  283. func (t *SessionMessagePart) MergeSessionMessagePartStepStart(v SessionMessagePartStepStart) error {
  284. b, err := json.Marshal(v)
  285. if err != nil {
  286. return err
  287. }
  288. merged, err := runtime.JSONMerge(t.union, b)
  289. t.union = merged
  290. return err
  291. }
  292. // AsSessionMessagePartData returns the union data inside the SessionMessagePart as a SessionMessagePartData
  293. func (t SessionMessagePart) AsSessionMessagePartData() (SessionMessagePartData, error) {
  294. var body SessionMessagePartData
  295. err := json.Unmarshal(t.union, &body)
  296. return body, err
  297. }
  298. // FromSessionMessagePartData overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartData
  299. func (t *SessionMessagePart) FromSessionMessagePartData(v SessionMessagePartData) error {
  300. b, err := json.Marshal(v)
  301. t.union = b
  302. return err
  303. }
  304. // MergeSessionMessagePartData performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartData
  305. func (t *SessionMessagePart) MergeSessionMessagePartData(v SessionMessagePartData) error {
  306. b, err := json.Marshal(v)
  307. if err != nil {
  308. return err
  309. }
  310. merged, err := runtime.JSONMerge(t.union, b)
  311. t.union = merged
  312. return err
  313. }
  314. func (t SessionMessagePart) MarshalJSON() ([]byte, error) {
  315. b, err := t.union.MarshalJSON()
  316. return b, err
  317. }
  318. func (t *SessionMessagePart) UnmarshalJSON(b []byte) error {
  319. err := t.union.UnmarshalJSON(b)
  320. return err
  321. }
  322. // AsSessionMessageToolInvocationToolCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolCall
  323. func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolCall() (SessionMessageToolInvocationToolCall, error) {
  324. var body SessionMessageToolInvocationToolCall
  325. err := json.Unmarshal(t.union, &body)
  326. return body, err
  327. }
  328. // FromSessionMessageToolInvocationToolCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolCall
  329. func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {
  330. b, err := json.Marshal(v)
  331. t.union = b
  332. return err
  333. }
  334. // MergeSessionMessageToolInvocationToolCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolCall
  335. func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {
  336. b, err := json.Marshal(v)
  337. if err != nil {
  338. return err
  339. }
  340. merged, err := runtime.JSONMerge(t.union, b)
  341. t.union = merged
  342. return err
  343. }
  344. // AsSessionMessageToolInvocationToolPartialCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolPartialCall
  345. func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolPartialCall() (SessionMessageToolInvocationToolPartialCall, error) {
  346. var body SessionMessageToolInvocationToolPartialCall
  347. err := json.Unmarshal(t.union, &body)
  348. return body, err
  349. }
  350. // FromSessionMessageToolInvocationToolPartialCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolPartialCall
  351. func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {
  352. b, err := json.Marshal(v)
  353. t.union = b
  354. return err
  355. }
  356. // MergeSessionMessageToolInvocationToolPartialCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolPartialCall
  357. func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {
  358. b, err := json.Marshal(v)
  359. if err != nil {
  360. return err
  361. }
  362. merged, err := runtime.JSONMerge(t.union, b)
  363. t.union = merged
  364. return err
  365. }
  366. // AsSessionMessageToolInvocationToolResult returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolResult
  367. func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolResult() (SessionMessageToolInvocationToolResult, error) {
  368. var body SessionMessageToolInvocationToolResult
  369. err := json.Unmarshal(t.union, &body)
  370. return body, err
  371. }
  372. // FromSessionMessageToolInvocationToolResult overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolResult
  373. func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {
  374. b, err := json.Marshal(v)
  375. t.union = b
  376. return err
  377. }
  378. // MergeSessionMessageToolInvocationToolResult performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolResult
  379. func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {
  380. b, err := json.Marshal(v)
  381. if err != nil {
  382. return err
  383. }
  384. merged, err := runtime.JSONMerge(t.union, b)
  385. t.union = merged
  386. return err
  387. }
  388. func (t SessionMessageToolInvocation) MarshalJSON() ([]byte, error) {
  389. b, err := t.union.MarshalJSON()
  390. return b, err
  391. }
  392. func (t *SessionMessageToolInvocation) UnmarshalJSON(b []byte) error {
  393. err := t.union.UnmarshalJSON(b)
  394. return err
  395. }
  396. // RequestEditorFn is the function signature for the RequestEditor callback function
  397. type RequestEditorFn func(ctx context.Context, req *http.Request) error
  398. // Doer performs HTTP requests.
  399. //
  400. // The standard http.Client implements this interface.
  401. type HttpRequestDoer interface {
  402. Do(req *http.Request) (*http.Response, error)
  403. }
  404. // Client which conforms to the OpenAPI3 specification for this service.
  405. type Client struct {
  406. // The endpoint of the server conforming to this interface, with scheme,
  407. // https://api.deepmap.com for example. This can contain a path relative
  408. // to the server, such as https://api.deepmap.com/dev-test, and all the
  409. // paths in the swagger spec will be appended to the server.
  410. Server string
  411. // Doer for performing requests, typically a *http.Client with any
  412. // customized settings, such as certificate chains.
  413. Client HttpRequestDoer
  414. // A list of callbacks for modifying requests which are generated before sending over
  415. // the network.
  416. RequestEditors []RequestEditorFn
  417. }
  418. // ClientOption allows setting custom parameters during construction
  419. type ClientOption func(*Client) error
  420. // Creates a new Client, with reasonable defaults
  421. func NewClient(server string, opts ...ClientOption) (*Client, error) {
  422. // create a client with sane default values
  423. client := Client{
  424. Server: server,
  425. }
  426. // mutate client and add all optional params
  427. for _, o := range opts {
  428. if err := o(&client); err != nil {
  429. return nil, err
  430. }
  431. }
  432. // ensure the server URL always has a trailing slash
  433. if !strings.HasSuffix(client.Server, "/") {
  434. client.Server += "/"
  435. }
  436. // create httpClient, if not already present
  437. if client.Client == nil {
  438. client.Client = &http.Client{}
  439. }
  440. return &client, nil
  441. }
  442. // WithHTTPClient allows overriding the default Doer, which is
  443. // automatically created using http.Client. This is useful for tests.
  444. func WithHTTPClient(doer HttpRequestDoer) ClientOption {
  445. return func(c *Client) error {
  446. c.Client = doer
  447. return nil
  448. }
  449. }
  450. // WithRequestEditorFn allows setting up a callback function, which will be
  451. // called right before sending the request. This can be used to mutate the request.
  452. func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
  453. return func(c *Client) error {
  454. c.RequestEditors = append(c.RequestEditors, fn)
  455. return nil
  456. }
  457. }
  458. // The interface specification for the client above.
  459. type ClientInterface interface {
  460. // PostProviderList request
  461. PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  462. // PostSessionChatWithBody request with any body
  463. PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  464. PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  465. // PostSessionCreate request
  466. PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  467. // PostSessionList request
  468. PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  469. // PostSessionMessagesWithBody request with any body
  470. PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  471. PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  472. // PostSessionShareWithBody request with any body
  473. PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  474. PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  475. }
  476. func (c *Client) PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  477. req, err := NewPostProviderListRequest(c.Server)
  478. if err != nil {
  479. return nil, err
  480. }
  481. req = req.WithContext(ctx)
  482. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  483. return nil, err
  484. }
  485. return c.Client.Do(req)
  486. }
  487. func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  488. req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
  489. if err != nil {
  490. return nil, err
  491. }
  492. req = req.WithContext(ctx)
  493. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  494. return nil, err
  495. }
  496. return c.Client.Do(req)
  497. }
  498. func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  499. req, err := NewPostSessionChatRequest(c.Server, body)
  500. if err != nil {
  501. return nil, err
  502. }
  503. req = req.WithContext(ctx)
  504. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  505. return nil, err
  506. }
  507. return c.Client.Do(req)
  508. }
  509. func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  510. req, err := NewPostSessionCreateRequest(c.Server)
  511. if err != nil {
  512. return nil, err
  513. }
  514. req = req.WithContext(ctx)
  515. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  516. return nil, err
  517. }
  518. return c.Client.Do(req)
  519. }
  520. func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  521. req, err := NewPostSessionListRequest(c.Server)
  522. if err != nil {
  523. return nil, err
  524. }
  525. req = req.WithContext(ctx)
  526. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  527. return nil, err
  528. }
  529. return c.Client.Do(req)
  530. }
  531. func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  532. req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
  533. if err != nil {
  534. return nil, err
  535. }
  536. req = req.WithContext(ctx)
  537. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  538. return nil, err
  539. }
  540. return c.Client.Do(req)
  541. }
  542. func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  543. req, err := NewPostSessionMessagesRequest(c.Server, body)
  544. if err != nil {
  545. return nil, err
  546. }
  547. req = req.WithContext(ctx)
  548. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  549. return nil, err
  550. }
  551. return c.Client.Do(req)
  552. }
  553. func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  554. req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
  555. if err != nil {
  556. return nil, err
  557. }
  558. req = req.WithContext(ctx)
  559. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  560. return nil, err
  561. }
  562. return c.Client.Do(req)
  563. }
  564. func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  565. req, err := NewPostSessionShareRequest(c.Server, body)
  566. if err != nil {
  567. return nil, err
  568. }
  569. req = req.WithContext(ctx)
  570. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  571. return nil, err
  572. }
  573. return c.Client.Do(req)
  574. }
  575. // NewPostProviderListRequest generates requests for PostProviderList
  576. func NewPostProviderListRequest(server string) (*http.Request, error) {
  577. var err error
  578. serverURL, err := url.Parse(server)
  579. if err != nil {
  580. return nil, err
  581. }
  582. operationPath := fmt.Sprintf("/provider_list")
  583. if operationPath[0] == '/' {
  584. operationPath = "." + operationPath
  585. }
  586. queryURL, err := serverURL.Parse(operationPath)
  587. if err != nil {
  588. return nil, err
  589. }
  590. req, err := http.NewRequest("POST", queryURL.String(), nil)
  591. if err != nil {
  592. return nil, err
  593. }
  594. return req, nil
  595. }
  596. // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
  597. func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
  598. var bodyReader io.Reader
  599. buf, err := json.Marshal(body)
  600. if err != nil {
  601. return nil, err
  602. }
  603. bodyReader = bytes.NewReader(buf)
  604. return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
  605. }
  606. // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
  607. func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  608. var err error
  609. serverURL, err := url.Parse(server)
  610. if err != nil {
  611. return nil, err
  612. }
  613. operationPath := fmt.Sprintf("/session_chat")
  614. if operationPath[0] == '/' {
  615. operationPath = "." + operationPath
  616. }
  617. queryURL, err := serverURL.Parse(operationPath)
  618. if err != nil {
  619. return nil, err
  620. }
  621. req, err := http.NewRequest("POST", queryURL.String(), body)
  622. if err != nil {
  623. return nil, err
  624. }
  625. req.Header.Add("Content-Type", contentType)
  626. return req, nil
  627. }
  628. // NewPostSessionCreateRequest generates requests for PostSessionCreate
  629. func NewPostSessionCreateRequest(server string) (*http.Request, error) {
  630. var err error
  631. serverURL, err := url.Parse(server)
  632. if err != nil {
  633. return nil, err
  634. }
  635. operationPath := fmt.Sprintf("/session_create")
  636. if operationPath[0] == '/' {
  637. operationPath = "." + operationPath
  638. }
  639. queryURL, err := serverURL.Parse(operationPath)
  640. if err != nil {
  641. return nil, err
  642. }
  643. req, err := http.NewRequest("POST", queryURL.String(), nil)
  644. if err != nil {
  645. return nil, err
  646. }
  647. return req, nil
  648. }
  649. // NewPostSessionListRequest generates requests for PostSessionList
  650. func NewPostSessionListRequest(server string) (*http.Request, error) {
  651. var err error
  652. serverURL, err := url.Parse(server)
  653. if err != nil {
  654. return nil, err
  655. }
  656. operationPath := fmt.Sprintf("/session_list")
  657. if operationPath[0] == '/' {
  658. operationPath = "." + operationPath
  659. }
  660. queryURL, err := serverURL.Parse(operationPath)
  661. if err != nil {
  662. return nil, err
  663. }
  664. req, err := http.NewRequest("POST", queryURL.String(), nil)
  665. if err != nil {
  666. return nil, err
  667. }
  668. return req, nil
  669. }
  670. // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
  671. func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
  672. var bodyReader io.Reader
  673. buf, err := json.Marshal(body)
  674. if err != nil {
  675. return nil, err
  676. }
  677. bodyReader = bytes.NewReader(buf)
  678. return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
  679. }
  680. // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
  681. func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  682. var err error
  683. serverURL, err := url.Parse(server)
  684. if err != nil {
  685. return nil, err
  686. }
  687. operationPath := fmt.Sprintf("/session_messages")
  688. if operationPath[0] == '/' {
  689. operationPath = "." + operationPath
  690. }
  691. queryURL, err := serverURL.Parse(operationPath)
  692. if err != nil {
  693. return nil, err
  694. }
  695. req, err := http.NewRequest("POST", queryURL.String(), body)
  696. if err != nil {
  697. return nil, err
  698. }
  699. req.Header.Add("Content-Type", contentType)
  700. return req, nil
  701. }
  702. // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
  703. func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
  704. var bodyReader io.Reader
  705. buf, err := json.Marshal(body)
  706. if err != nil {
  707. return nil, err
  708. }
  709. bodyReader = bytes.NewReader(buf)
  710. return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
  711. }
  712. // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
  713. func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  714. var err error
  715. serverURL, err := url.Parse(server)
  716. if err != nil {
  717. return nil, err
  718. }
  719. operationPath := fmt.Sprintf("/session_share")
  720. if operationPath[0] == '/' {
  721. operationPath = "." + operationPath
  722. }
  723. queryURL, err := serverURL.Parse(operationPath)
  724. if err != nil {
  725. return nil, err
  726. }
  727. req, err := http.NewRequest("POST", queryURL.String(), body)
  728. if err != nil {
  729. return nil, err
  730. }
  731. req.Header.Add("Content-Type", contentType)
  732. return req, nil
  733. }
  734. func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
  735. for _, r := range c.RequestEditors {
  736. if err := r(ctx, req); err != nil {
  737. return err
  738. }
  739. }
  740. for _, r := range additionalEditors {
  741. if err := r(ctx, req); err != nil {
  742. return err
  743. }
  744. }
  745. return nil
  746. }
  747. // ClientWithResponses builds on ClientInterface to offer response payloads
  748. type ClientWithResponses struct {
  749. ClientInterface
  750. }
  751. // NewClientWithResponses creates a new ClientWithResponses, which wraps
  752. // Client with return type handling
  753. func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
  754. client, err := NewClient(server, opts...)
  755. if err != nil {
  756. return nil, err
  757. }
  758. return &ClientWithResponses{client}, nil
  759. }
  760. // WithBaseURL overrides the baseURL.
  761. func WithBaseURL(baseURL string) ClientOption {
  762. return func(c *Client) error {
  763. newBaseURL, err := url.Parse(baseURL)
  764. if err != nil {
  765. return err
  766. }
  767. c.Server = newBaseURL.String()
  768. return nil
  769. }
  770. }
  771. // ClientWithResponsesInterface is the interface specification for the client with responses above.
  772. type ClientWithResponsesInterface interface {
  773. // PostProviderListWithResponse request
  774. PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error)
  775. // PostSessionChatWithBodyWithResponse request with any body
  776. PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  777. PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  778. // PostSessionCreateWithResponse request
  779. PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
  780. // PostSessionListWithResponse request
  781. PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
  782. // PostSessionMessagesWithBodyWithResponse request with any body
  783. PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  784. PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  785. // PostSessionShareWithBodyWithResponse request with any body
  786. PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  787. PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  788. }
  789. type PostProviderListResponse struct {
  790. Body []byte
  791. HTTPResponse *http.Response
  792. JSON200 *map[string]ProviderInfo
  793. }
  794. // Status returns HTTPResponse.Status
  795. func (r PostProviderListResponse) Status() string {
  796. if r.HTTPResponse != nil {
  797. return r.HTTPResponse.Status
  798. }
  799. return http.StatusText(0)
  800. }
  801. // StatusCode returns HTTPResponse.StatusCode
  802. func (r PostProviderListResponse) StatusCode() int {
  803. if r.HTTPResponse != nil {
  804. return r.HTTPResponse.StatusCode
  805. }
  806. return 0
  807. }
  808. type PostSessionChatResponse struct {
  809. Body []byte
  810. HTTPResponse *http.Response
  811. }
  812. // Status returns HTTPResponse.Status
  813. func (r PostSessionChatResponse) Status() string {
  814. if r.HTTPResponse != nil {
  815. return r.HTTPResponse.Status
  816. }
  817. return http.StatusText(0)
  818. }
  819. // StatusCode returns HTTPResponse.StatusCode
  820. func (r PostSessionChatResponse) StatusCode() int {
  821. if r.HTTPResponse != nil {
  822. return r.HTTPResponse.StatusCode
  823. }
  824. return 0
  825. }
  826. type PostSessionCreateResponse struct {
  827. Body []byte
  828. HTTPResponse *http.Response
  829. JSON200 *SessionInfo
  830. }
  831. // Status returns HTTPResponse.Status
  832. func (r PostSessionCreateResponse) Status() string {
  833. if r.HTTPResponse != nil {
  834. return r.HTTPResponse.Status
  835. }
  836. return http.StatusText(0)
  837. }
  838. // StatusCode returns HTTPResponse.StatusCode
  839. func (r PostSessionCreateResponse) StatusCode() int {
  840. if r.HTTPResponse != nil {
  841. return r.HTTPResponse.StatusCode
  842. }
  843. return 0
  844. }
  845. type PostSessionListResponse struct {
  846. Body []byte
  847. HTTPResponse *http.Response
  848. JSON200 *[]struct {
  849. Id string `json:"id"`
  850. ShareID *string `json:"shareID,omitempty"`
  851. Title string `json:"title"`
  852. Tokens struct {
  853. Input float32 `json:"input"`
  854. Output float32 `json:"output"`
  855. Reasoning float32 `json:"reasoning"`
  856. } `json:"tokens"`
  857. }
  858. }
  859. // Status returns HTTPResponse.Status
  860. func (r PostSessionListResponse) Status() string {
  861. if r.HTTPResponse != nil {
  862. return r.HTTPResponse.Status
  863. }
  864. return http.StatusText(0)
  865. }
  866. // StatusCode returns HTTPResponse.StatusCode
  867. func (r PostSessionListResponse) StatusCode() int {
  868. if r.HTTPResponse != nil {
  869. return r.HTTPResponse.StatusCode
  870. }
  871. return 0
  872. }
  873. type PostSessionMessagesResponse struct {
  874. Body []byte
  875. HTTPResponse *http.Response
  876. JSON200 *[]SessionMessage
  877. }
  878. // Status returns HTTPResponse.Status
  879. func (r PostSessionMessagesResponse) Status() string {
  880. if r.HTTPResponse != nil {
  881. return r.HTTPResponse.Status
  882. }
  883. return http.StatusText(0)
  884. }
  885. // StatusCode returns HTTPResponse.StatusCode
  886. func (r PostSessionMessagesResponse) StatusCode() int {
  887. if r.HTTPResponse != nil {
  888. return r.HTTPResponse.StatusCode
  889. }
  890. return 0
  891. }
  892. type PostSessionShareResponse struct {
  893. Body []byte
  894. HTTPResponse *http.Response
  895. JSON200 *SessionInfo
  896. }
  897. // Status returns HTTPResponse.Status
  898. func (r PostSessionShareResponse) Status() string {
  899. if r.HTTPResponse != nil {
  900. return r.HTTPResponse.Status
  901. }
  902. return http.StatusText(0)
  903. }
  904. // StatusCode returns HTTPResponse.StatusCode
  905. func (r PostSessionShareResponse) StatusCode() int {
  906. if r.HTTPResponse != nil {
  907. return r.HTTPResponse.StatusCode
  908. }
  909. return 0
  910. }
  911. // PostProviderListWithResponse request returning *PostProviderListResponse
  912. func (c *ClientWithResponses) PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error) {
  913. rsp, err := c.PostProviderList(ctx, reqEditors...)
  914. if err != nil {
  915. return nil, err
  916. }
  917. return ParsePostProviderListResponse(rsp)
  918. }
  919. // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
  920. func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  921. rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
  922. if err != nil {
  923. return nil, err
  924. }
  925. return ParsePostSessionChatResponse(rsp)
  926. }
  927. func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  928. rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
  929. if err != nil {
  930. return nil, err
  931. }
  932. return ParsePostSessionChatResponse(rsp)
  933. }
  934. // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
  935. func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
  936. rsp, err := c.PostSessionCreate(ctx, reqEditors...)
  937. if err != nil {
  938. return nil, err
  939. }
  940. return ParsePostSessionCreateResponse(rsp)
  941. }
  942. // PostSessionListWithResponse request returning *PostSessionListResponse
  943. func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
  944. rsp, err := c.PostSessionList(ctx, reqEditors...)
  945. if err != nil {
  946. return nil, err
  947. }
  948. return ParsePostSessionListResponse(rsp)
  949. }
  950. // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
  951. func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  952. rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
  953. if err != nil {
  954. return nil, err
  955. }
  956. return ParsePostSessionMessagesResponse(rsp)
  957. }
  958. func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  959. rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
  960. if err != nil {
  961. return nil, err
  962. }
  963. return ParsePostSessionMessagesResponse(rsp)
  964. }
  965. // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
  966. func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  967. rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
  968. if err != nil {
  969. return nil, err
  970. }
  971. return ParsePostSessionShareResponse(rsp)
  972. }
  973. func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  974. rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
  975. if err != nil {
  976. return nil, err
  977. }
  978. return ParsePostSessionShareResponse(rsp)
  979. }
  980. // ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
  981. func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponse, error) {
  982. bodyBytes, err := io.ReadAll(rsp.Body)
  983. defer func() { _ = rsp.Body.Close() }()
  984. if err != nil {
  985. return nil, err
  986. }
  987. response := &PostProviderListResponse{
  988. Body: bodyBytes,
  989. HTTPResponse: rsp,
  990. }
  991. switch {
  992. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  993. var dest map[string]ProviderInfo
  994. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  995. return nil, err
  996. }
  997. response.JSON200 = &dest
  998. }
  999. return response, nil
  1000. }
  1001. // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
  1002. func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
  1003. bodyBytes, err := io.ReadAll(rsp.Body)
  1004. defer func() { _ = rsp.Body.Close() }()
  1005. if err != nil {
  1006. return nil, err
  1007. }
  1008. response := &PostSessionChatResponse{
  1009. Body: bodyBytes,
  1010. HTTPResponse: rsp,
  1011. }
  1012. return response, nil
  1013. }
  1014. // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
  1015. func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
  1016. bodyBytes, err := io.ReadAll(rsp.Body)
  1017. defer func() { _ = rsp.Body.Close() }()
  1018. if err != nil {
  1019. return nil, err
  1020. }
  1021. response := &PostSessionCreateResponse{
  1022. Body: bodyBytes,
  1023. HTTPResponse: rsp,
  1024. }
  1025. switch {
  1026. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1027. var dest SessionInfo
  1028. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1029. return nil, err
  1030. }
  1031. response.JSON200 = &dest
  1032. }
  1033. return response, nil
  1034. }
  1035. // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
  1036. func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
  1037. bodyBytes, err := io.ReadAll(rsp.Body)
  1038. defer func() { _ = rsp.Body.Close() }()
  1039. if err != nil {
  1040. return nil, err
  1041. }
  1042. response := &PostSessionListResponse{
  1043. Body: bodyBytes,
  1044. HTTPResponse: rsp,
  1045. }
  1046. switch {
  1047. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1048. var dest []struct {
  1049. Id string `json:"id"`
  1050. ShareID *string `json:"shareID,omitempty"`
  1051. Title string `json:"title"`
  1052. Tokens struct {
  1053. Input float32 `json:"input"`
  1054. Output float32 `json:"output"`
  1055. Reasoning float32 `json:"reasoning"`
  1056. } `json:"tokens"`
  1057. }
  1058. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1059. return nil, err
  1060. }
  1061. response.JSON200 = &dest
  1062. }
  1063. return response, nil
  1064. }
  1065. // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
  1066. func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
  1067. bodyBytes, err := io.ReadAll(rsp.Body)
  1068. defer func() { _ = rsp.Body.Close() }()
  1069. if err != nil {
  1070. return nil, err
  1071. }
  1072. response := &PostSessionMessagesResponse{
  1073. Body: bodyBytes,
  1074. HTTPResponse: rsp,
  1075. }
  1076. switch {
  1077. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1078. var dest []SessionMessage
  1079. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1080. return nil, err
  1081. }
  1082. response.JSON200 = &dest
  1083. }
  1084. return response, nil
  1085. }
  1086. // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
  1087. func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
  1088. bodyBytes, err := io.ReadAll(rsp.Body)
  1089. defer func() { _ = rsp.Body.Close() }()
  1090. if err != nil {
  1091. return nil, err
  1092. }
  1093. response := &PostSessionShareResponse{
  1094. Body: bodyBytes,
  1095. HTTPResponse: rsp,
  1096. }
  1097. switch {
  1098. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1099. var dest SessionInfo
  1100. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1101. return nil, err
  1102. }
  1103. response.JSON200 = &dest
  1104. }
  1105. return response, nil
  1106. }