generated-client.go 43 KB

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