generated-client.go 43 KB

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