generated-client.go 48 KB

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