session.go 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "net/http"
  8. "reflect"
  9. "github.com/sst/opencode-sdk-go/internal/apijson"
  10. "github.com/sst/opencode-sdk-go/internal/param"
  11. "github.com/sst/opencode-sdk-go/internal/requestconfig"
  12. "github.com/sst/opencode-sdk-go/option"
  13. "github.com/sst/opencode-sdk-go/shared"
  14. "github.com/tidwall/gjson"
  15. )
  16. // SessionService contains methods and other services that help with interacting
  17. // with the opencode API.
  18. //
  19. // Note, unlike clients, this service does not read variables from the environment
  20. // automatically. You should not instantiate this service directly, and instead use
  21. // the [NewSessionService] method instead.
  22. type SessionService struct {
  23. Options []option.RequestOption
  24. }
  25. // NewSessionService generates a new service that applies the given options to each
  26. // request. These options are applied after the parent client's options (if there
  27. // is one), and before any request-specific options.
  28. func NewSessionService(opts ...option.RequestOption) (r *SessionService) {
  29. r = &SessionService{}
  30. r.Options = opts
  31. return
  32. }
  33. // Create a new session
  34. func (r *SessionService) New(ctx context.Context, opts ...option.RequestOption) (res *Session, err error) {
  35. opts = append(r.Options[:], opts...)
  36. path := "session"
  37. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  38. return
  39. }
  40. // List all sessions
  41. func (r *SessionService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Session, err error) {
  42. opts = append(r.Options[:], opts...)
  43. path := "session"
  44. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  45. return
  46. }
  47. // Delete a session and all its data
  48. func (r *SessionService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error) {
  49. opts = append(r.Options[:], opts...)
  50. if id == "" {
  51. err = errors.New("missing required id parameter")
  52. return
  53. }
  54. path := fmt.Sprintf("session/%s", id)
  55. err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
  56. return
  57. }
  58. // Abort a session
  59. func (r *SessionService) Abort(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error) {
  60. opts = append(r.Options[:], opts...)
  61. if id == "" {
  62. err = errors.New("missing required id parameter")
  63. return
  64. }
  65. path := fmt.Sprintf("session/%s/abort", id)
  66. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  67. return
  68. }
  69. // Create and send a new message to a session
  70. func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatParams, opts ...option.RequestOption) (res *AssistantMessage, err error) {
  71. opts = append(r.Options[:], opts...)
  72. if id == "" {
  73. err = errors.New("missing required id parameter")
  74. return
  75. }
  76. path := fmt.Sprintf("session/%s/message", id)
  77. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  78. return
  79. }
  80. // Analyze the app and create an AGENTS.md file
  81. func (r *SessionService) Init(ctx context.Context, id string, body SessionInitParams, opts ...option.RequestOption) (res *bool, err error) {
  82. opts = append(r.Options[:], opts...)
  83. if id == "" {
  84. err = errors.New("missing required id parameter")
  85. return
  86. }
  87. path := fmt.Sprintf("session/%s/init", id)
  88. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  89. return
  90. }
  91. // List messages for a session
  92. func (r *SessionService) Messages(ctx context.Context, id string, opts ...option.RequestOption) (res *[]SessionMessagesResponse, err error) {
  93. opts = append(r.Options[:], opts...)
  94. if id == "" {
  95. err = errors.New("missing required id parameter")
  96. return
  97. }
  98. path := fmt.Sprintf("session/%s/message", id)
  99. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  100. return
  101. }
  102. // Revert a message
  103. func (r *SessionService) Revert(ctx context.Context, id string, body SessionRevertParams, opts ...option.RequestOption) (res *Session, err error) {
  104. opts = append(r.Options[:], opts...)
  105. if id == "" {
  106. err = errors.New("missing required id parameter")
  107. return
  108. }
  109. path := fmt.Sprintf("session/%s/revert", id)
  110. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  111. return
  112. }
  113. // Share a session
  114. func (r *SessionService) Share(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  115. opts = append(r.Options[:], opts...)
  116. if id == "" {
  117. err = errors.New("missing required id parameter")
  118. return
  119. }
  120. path := fmt.Sprintf("session/%s/share", id)
  121. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  122. return
  123. }
  124. // Summarize the session
  125. func (r *SessionService) Summarize(ctx context.Context, id string, body SessionSummarizeParams, opts ...option.RequestOption) (res *bool, err error) {
  126. opts = append(r.Options[:], opts...)
  127. if id == "" {
  128. err = errors.New("missing required id parameter")
  129. return
  130. }
  131. path := fmt.Sprintf("session/%s/summarize", id)
  132. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  133. return
  134. }
  135. // Restore all reverted messages
  136. func (r *SessionService) Unrevert(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  137. opts = append(r.Options[:], opts...)
  138. if id == "" {
  139. err = errors.New("missing required id parameter")
  140. return
  141. }
  142. path := fmt.Sprintf("session/%s/unrevert", id)
  143. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  144. return
  145. }
  146. // Unshare the session
  147. func (r *SessionService) Unshare(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  148. opts = append(r.Options[:], opts...)
  149. if id == "" {
  150. err = errors.New("missing required id parameter")
  151. return
  152. }
  153. path := fmt.Sprintf("session/%s/share", id)
  154. err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
  155. return
  156. }
  157. type AssistantMessage struct {
  158. ID string `json:"id,required"`
  159. Cost float64 `json:"cost,required"`
  160. ModelID string `json:"modelID,required"`
  161. Path AssistantMessagePath `json:"path,required"`
  162. ProviderID string `json:"providerID,required"`
  163. Role AssistantMessageRole `json:"role,required"`
  164. SessionID string `json:"sessionID,required"`
  165. System []string `json:"system,required"`
  166. Time AssistantMessageTime `json:"time,required"`
  167. Tokens AssistantMessageTokens `json:"tokens,required"`
  168. Error AssistantMessageError `json:"error"`
  169. Summary bool `json:"summary"`
  170. JSON assistantMessageJSON `json:"-"`
  171. }
  172. // assistantMessageJSON contains the JSON metadata for the struct
  173. // [AssistantMessage]
  174. type assistantMessageJSON struct {
  175. ID apijson.Field
  176. Cost apijson.Field
  177. ModelID apijson.Field
  178. Path apijson.Field
  179. ProviderID apijson.Field
  180. Role apijson.Field
  181. SessionID apijson.Field
  182. System apijson.Field
  183. Time apijson.Field
  184. Tokens apijson.Field
  185. Error apijson.Field
  186. Summary apijson.Field
  187. raw string
  188. ExtraFields map[string]apijson.Field
  189. }
  190. func (r *AssistantMessage) UnmarshalJSON(data []byte) (err error) {
  191. return apijson.UnmarshalRoot(data, r)
  192. }
  193. func (r assistantMessageJSON) RawJSON() string {
  194. return r.raw
  195. }
  196. func (r AssistantMessage) implementsMessage() {}
  197. type AssistantMessagePath struct {
  198. Cwd string `json:"cwd,required"`
  199. Root string `json:"root,required"`
  200. JSON assistantMessagePathJSON `json:"-"`
  201. }
  202. // assistantMessagePathJSON contains the JSON metadata for the struct
  203. // [AssistantMessagePath]
  204. type assistantMessagePathJSON struct {
  205. Cwd apijson.Field
  206. Root apijson.Field
  207. raw string
  208. ExtraFields map[string]apijson.Field
  209. }
  210. func (r *AssistantMessagePath) UnmarshalJSON(data []byte) (err error) {
  211. return apijson.UnmarshalRoot(data, r)
  212. }
  213. func (r assistantMessagePathJSON) RawJSON() string {
  214. return r.raw
  215. }
  216. type AssistantMessageRole string
  217. const (
  218. AssistantMessageRoleAssistant AssistantMessageRole = "assistant"
  219. )
  220. func (r AssistantMessageRole) IsKnown() bool {
  221. switch r {
  222. case AssistantMessageRoleAssistant:
  223. return true
  224. }
  225. return false
  226. }
  227. type AssistantMessageTime struct {
  228. Created float64 `json:"created,required"`
  229. Completed float64 `json:"completed"`
  230. JSON assistantMessageTimeJSON `json:"-"`
  231. }
  232. // assistantMessageTimeJSON contains the JSON metadata for the struct
  233. // [AssistantMessageTime]
  234. type assistantMessageTimeJSON struct {
  235. Created apijson.Field
  236. Completed apijson.Field
  237. raw string
  238. ExtraFields map[string]apijson.Field
  239. }
  240. func (r *AssistantMessageTime) UnmarshalJSON(data []byte) (err error) {
  241. return apijson.UnmarshalRoot(data, r)
  242. }
  243. func (r assistantMessageTimeJSON) RawJSON() string {
  244. return r.raw
  245. }
  246. type AssistantMessageTokens struct {
  247. Cache AssistantMessageTokensCache `json:"cache,required"`
  248. Input float64 `json:"input,required"`
  249. Output float64 `json:"output,required"`
  250. Reasoning float64 `json:"reasoning,required"`
  251. JSON assistantMessageTokensJSON `json:"-"`
  252. }
  253. // assistantMessageTokensJSON contains the JSON metadata for the struct
  254. // [AssistantMessageTokens]
  255. type assistantMessageTokensJSON struct {
  256. Cache apijson.Field
  257. Input apijson.Field
  258. Output apijson.Field
  259. Reasoning apijson.Field
  260. raw string
  261. ExtraFields map[string]apijson.Field
  262. }
  263. func (r *AssistantMessageTokens) UnmarshalJSON(data []byte) (err error) {
  264. return apijson.UnmarshalRoot(data, r)
  265. }
  266. func (r assistantMessageTokensJSON) RawJSON() string {
  267. return r.raw
  268. }
  269. type AssistantMessageTokensCache struct {
  270. Read float64 `json:"read,required"`
  271. Write float64 `json:"write,required"`
  272. JSON assistantMessageTokensCacheJSON `json:"-"`
  273. }
  274. // assistantMessageTokensCacheJSON contains the JSON metadata for the struct
  275. // [AssistantMessageTokensCache]
  276. type assistantMessageTokensCacheJSON struct {
  277. Read apijson.Field
  278. Write apijson.Field
  279. raw string
  280. ExtraFields map[string]apijson.Field
  281. }
  282. func (r *AssistantMessageTokensCache) UnmarshalJSON(data []byte) (err error) {
  283. return apijson.UnmarshalRoot(data, r)
  284. }
  285. func (r assistantMessageTokensCacheJSON) RawJSON() string {
  286. return r.raw
  287. }
  288. type AssistantMessageError struct {
  289. // This field can have the runtime type of [shared.ProviderAuthErrorData],
  290. // [shared.UnknownErrorData], [interface{}].
  291. Data interface{} `json:"data,required"`
  292. Name AssistantMessageErrorName `json:"name,required"`
  293. JSON assistantMessageErrorJSON `json:"-"`
  294. union AssistantMessageErrorUnion
  295. }
  296. // assistantMessageErrorJSON contains the JSON metadata for the struct
  297. // [AssistantMessageError]
  298. type assistantMessageErrorJSON struct {
  299. Data apijson.Field
  300. Name apijson.Field
  301. raw string
  302. ExtraFields map[string]apijson.Field
  303. }
  304. func (r assistantMessageErrorJSON) RawJSON() string {
  305. return r.raw
  306. }
  307. func (r *AssistantMessageError) UnmarshalJSON(data []byte) (err error) {
  308. *r = AssistantMessageError{}
  309. err = apijson.UnmarshalRoot(data, &r.union)
  310. if err != nil {
  311. return err
  312. }
  313. return apijson.Port(r.union, &r)
  314. }
  315. // AsUnion returns a [AssistantMessageErrorUnion] interface which you can cast to
  316. // the specific types for more type safety.
  317. //
  318. // Possible runtime types of the union are [shared.ProviderAuthError],
  319. // [shared.UnknownError], [AssistantMessageErrorMessageOutputLengthError],
  320. // [shared.MessageAbortedError].
  321. func (r AssistantMessageError) AsUnion() AssistantMessageErrorUnion {
  322. return r.union
  323. }
  324. // Union satisfied by [shared.ProviderAuthError], [shared.UnknownError],
  325. // [AssistantMessageErrorMessageOutputLengthError] or [shared.MessageAbortedError].
  326. type AssistantMessageErrorUnion interface {
  327. ImplementsAssistantMessageError()
  328. }
  329. func init() {
  330. apijson.RegisterUnion(
  331. reflect.TypeOf((*AssistantMessageErrorUnion)(nil)).Elem(),
  332. "name",
  333. apijson.UnionVariant{
  334. TypeFilter: gjson.JSON,
  335. Type: reflect.TypeOf(shared.ProviderAuthError{}),
  336. DiscriminatorValue: "ProviderAuthError",
  337. },
  338. apijson.UnionVariant{
  339. TypeFilter: gjson.JSON,
  340. Type: reflect.TypeOf(shared.UnknownError{}),
  341. DiscriminatorValue: "UnknownError",
  342. },
  343. apijson.UnionVariant{
  344. TypeFilter: gjson.JSON,
  345. Type: reflect.TypeOf(AssistantMessageErrorMessageOutputLengthError{}),
  346. DiscriminatorValue: "MessageOutputLengthError",
  347. },
  348. apijson.UnionVariant{
  349. TypeFilter: gjson.JSON,
  350. Type: reflect.TypeOf(shared.MessageAbortedError{}),
  351. DiscriminatorValue: "MessageAbortedError",
  352. },
  353. )
  354. }
  355. type AssistantMessageErrorMessageOutputLengthError struct {
  356. Data interface{} `json:"data,required"`
  357. Name AssistantMessageErrorMessageOutputLengthErrorName `json:"name,required"`
  358. JSON assistantMessageErrorMessageOutputLengthErrorJSON `json:"-"`
  359. }
  360. // assistantMessageErrorMessageOutputLengthErrorJSON contains the JSON metadata for
  361. // the struct [AssistantMessageErrorMessageOutputLengthError]
  362. type assistantMessageErrorMessageOutputLengthErrorJSON struct {
  363. Data apijson.Field
  364. Name apijson.Field
  365. raw string
  366. ExtraFields map[string]apijson.Field
  367. }
  368. func (r *AssistantMessageErrorMessageOutputLengthError) UnmarshalJSON(data []byte) (err error) {
  369. return apijson.UnmarshalRoot(data, r)
  370. }
  371. func (r assistantMessageErrorMessageOutputLengthErrorJSON) RawJSON() string {
  372. return r.raw
  373. }
  374. func (r AssistantMessageErrorMessageOutputLengthError) ImplementsAssistantMessageError() {}
  375. type AssistantMessageErrorMessageOutputLengthErrorName string
  376. const (
  377. AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError AssistantMessageErrorMessageOutputLengthErrorName = "MessageOutputLengthError"
  378. )
  379. func (r AssistantMessageErrorMessageOutputLengthErrorName) IsKnown() bool {
  380. switch r {
  381. case AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError:
  382. return true
  383. }
  384. return false
  385. }
  386. type AssistantMessageErrorName string
  387. const (
  388. AssistantMessageErrorNameProviderAuthError AssistantMessageErrorName = "ProviderAuthError"
  389. AssistantMessageErrorNameUnknownError AssistantMessageErrorName = "UnknownError"
  390. AssistantMessageErrorNameMessageOutputLengthError AssistantMessageErrorName = "MessageOutputLengthError"
  391. AssistantMessageErrorNameMessageAbortedError AssistantMessageErrorName = "MessageAbortedError"
  392. )
  393. func (r AssistantMessageErrorName) IsKnown() bool {
  394. switch r {
  395. case AssistantMessageErrorNameProviderAuthError, AssistantMessageErrorNameUnknownError, AssistantMessageErrorNameMessageOutputLengthError, AssistantMessageErrorNameMessageAbortedError:
  396. return true
  397. }
  398. return false
  399. }
  400. type FilePart struct {
  401. ID string `json:"id,required"`
  402. MessageID string `json:"messageID,required"`
  403. Mime string `json:"mime,required"`
  404. SessionID string `json:"sessionID,required"`
  405. Type FilePartType `json:"type,required"`
  406. URL string `json:"url,required"`
  407. Filename string `json:"filename"`
  408. Source FilePartSource `json:"source"`
  409. JSON filePartJSON `json:"-"`
  410. }
  411. // filePartJSON contains the JSON metadata for the struct [FilePart]
  412. type filePartJSON struct {
  413. ID apijson.Field
  414. MessageID apijson.Field
  415. Mime apijson.Field
  416. SessionID apijson.Field
  417. Type apijson.Field
  418. URL apijson.Field
  419. Filename apijson.Field
  420. Source apijson.Field
  421. raw string
  422. ExtraFields map[string]apijson.Field
  423. }
  424. func (r *FilePart) UnmarshalJSON(data []byte) (err error) {
  425. return apijson.UnmarshalRoot(data, r)
  426. }
  427. func (r filePartJSON) RawJSON() string {
  428. return r.raw
  429. }
  430. func (r FilePart) implementsPart() {}
  431. type FilePartType string
  432. const (
  433. FilePartTypeFile FilePartType = "file"
  434. )
  435. func (r FilePartType) IsKnown() bool {
  436. switch r {
  437. case FilePartTypeFile:
  438. return true
  439. }
  440. return false
  441. }
  442. type FilePartInputParam struct {
  443. Mime param.Field[string] `json:"mime,required"`
  444. Type param.Field[FilePartInputType] `json:"type,required"`
  445. URL param.Field[string] `json:"url,required"`
  446. ID param.Field[string] `json:"id"`
  447. Filename param.Field[string] `json:"filename"`
  448. Source param.Field[FilePartSourceUnionParam] `json:"source"`
  449. }
  450. func (r FilePartInputParam) MarshalJSON() (data []byte, err error) {
  451. return apijson.MarshalRoot(r)
  452. }
  453. func (r FilePartInputParam) implementsSessionChatParamsPartUnion() {}
  454. type FilePartInputType string
  455. const (
  456. FilePartInputTypeFile FilePartInputType = "file"
  457. )
  458. func (r FilePartInputType) IsKnown() bool {
  459. switch r {
  460. case FilePartInputTypeFile:
  461. return true
  462. }
  463. return false
  464. }
  465. type FilePartSource struct {
  466. Path string `json:"path,required"`
  467. Text FilePartSourceText `json:"text,required"`
  468. Type FilePartSourceType `json:"type,required"`
  469. Kind int64 `json:"kind"`
  470. Name string `json:"name"`
  471. // This field can have the runtime type of [SymbolSourceRange].
  472. Range interface{} `json:"range"`
  473. JSON filePartSourceJSON `json:"-"`
  474. union FilePartSourceUnion
  475. }
  476. // filePartSourceJSON contains the JSON metadata for the struct [FilePartSource]
  477. type filePartSourceJSON struct {
  478. Path apijson.Field
  479. Text apijson.Field
  480. Type apijson.Field
  481. Kind apijson.Field
  482. Name apijson.Field
  483. Range apijson.Field
  484. raw string
  485. ExtraFields map[string]apijson.Field
  486. }
  487. func (r filePartSourceJSON) RawJSON() string {
  488. return r.raw
  489. }
  490. func (r *FilePartSource) UnmarshalJSON(data []byte) (err error) {
  491. *r = FilePartSource{}
  492. err = apijson.UnmarshalRoot(data, &r.union)
  493. if err != nil {
  494. return err
  495. }
  496. return apijson.Port(r.union, &r)
  497. }
  498. // AsUnion returns a [FilePartSourceUnion] interface which you can cast to the
  499. // specific types for more type safety.
  500. //
  501. // Possible runtime types of the union are [FileSource], [SymbolSource].
  502. func (r FilePartSource) AsUnion() FilePartSourceUnion {
  503. return r.union
  504. }
  505. // Union satisfied by [FileSource] or [SymbolSource].
  506. type FilePartSourceUnion interface {
  507. implementsFilePartSource()
  508. }
  509. func init() {
  510. apijson.RegisterUnion(
  511. reflect.TypeOf((*FilePartSourceUnion)(nil)).Elem(),
  512. "type",
  513. apijson.UnionVariant{
  514. TypeFilter: gjson.JSON,
  515. Type: reflect.TypeOf(FileSource{}),
  516. DiscriminatorValue: "file",
  517. },
  518. apijson.UnionVariant{
  519. TypeFilter: gjson.JSON,
  520. Type: reflect.TypeOf(SymbolSource{}),
  521. DiscriminatorValue: "symbol",
  522. },
  523. )
  524. }
  525. type FilePartSourceType string
  526. const (
  527. FilePartSourceTypeFile FilePartSourceType = "file"
  528. FilePartSourceTypeSymbol FilePartSourceType = "symbol"
  529. )
  530. func (r FilePartSourceType) IsKnown() bool {
  531. switch r {
  532. case FilePartSourceTypeFile, FilePartSourceTypeSymbol:
  533. return true
  534. }
  535. return false
  536. }
  537. type FilePartSourceParam struct {
  538. Path param.Field[string] `json:"path,required"`
  539. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  540. Type param.Field[FilePartSourceType] `json:"type,required"`
  541. Kind param.Field[int64] `json:"kind"`
  542. Name param.Field[string] `json:"name"`
  543. Range param.Field[interface{}] `json:"range"`
  544. }
  545. func (r FilePartSourceParam) MarshalJSON() (data []byte, err error) {
  546. return apijson.MarshalRoot(r)
  547. }
  548. func (r FilePartSourceParam) implementsFilePartSourceUnionParam() {}
  549. // Satisfied by [FileSourceParam], [SymbolSourceParam], [FilePartSourceParam].
  550. type FilePartSourceUnionParam interface {
  551. implementsFilePartSourceUnionParam()
  552. }
  553. type FilePartSourceText struct {
  554. End int64 `json:"end,required"`
  555. Start int64 `json:"start,required"`
  556. Value string `json:"value,required"`
  557. JSON filePartSourceTextJSON `json:"-"`
  558. }
  559. // filePartSourceTextJSON contains the JSON metadata for the struct
  560. // [FilePartSourceText]
  561. type filePartSourceTextJSON struct {
  562. End apijson.Field
  563. Start apijson.Field
  564. Value apijson.Field
  565. raw string
  566. ExtraFields map[string]apijson.Field
  567. }
  568. func (r *FilePartSourceText) UnmarshalJSON(data []byte) (err error) {
  569. return apijson.UnmarshalRoot(data, r)
  570. }
  571. func (r filePartSourceTextJSON) RawJSON() string {
  572. return r.raw
  573. }
  574. type FilePartSourceTextParam struct {
  575. End param.Field[int64] `json:"end,required"`
  576. Start param.Field[int64] `json:"start,required"`
  577. Value param.Field[string] `json:"value,required"`
  578. }
  579. func (r FilePartSourceTextParam) MarshalJSON() (data []byte, err error) {
  580. return apijson.MarshalRoot(r)
  581. }
  582. type FileSource struct {
  583. Path string `json:"path,required"`
  584. Text FilePartSourceText `json:"text,required"`
  585. Type FileSourceType `json:"type,required"`
  586. JSON fileSourceJSON `json:"-"`
  587. }
  588. // fileSourceJSON contains the JSON metadata for the struct [FileSource]
  589. type fileSourceJSON struct {
  590. Path apijson.Field
  591. Text apijson.Field
  592. Type apijson.Field
  593. raw string
  594. ExtraFields map[string]apijson.Field
  595. }
  596. func (r *FileSource) UnmarshalJSON(data []byte) (err error) {
  597. return apijson.UnmarshalRoot(data, r)
  598. }
  599. func (r fileSourceJSON) RawJSON() string {
  600. return r.raw
  601. }
  602. func (r FileSource) implementsFilePartSource() {}
  603. type FileSourceType string
  604. const (
  605. FileSourceTypeFile FileSourceType = "file"
  606. )
  607. func (r FileSourceType) IsKnown() bool {
  608. switch r {
  609. case FileSourceTypeFile:
  610. return true
  611. }
  612. return false
  613. }
  614. type FileSourceParam struct {
  615. Path param.Field[string] `json:"path,required"`
  616. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  617. Type param.Field[FileSourceType] `json:"type,required"`
  618. }
  619. func (r FileSourceParam) MarshalJSON() (data []byte, err error) {
  620. return apijson.MarshalRoot(r)
  621. }
  622. func (r FileSourceParam) implementsFilePartSourceUnionParam() {}
  623. type Message struct {
  624. ID string `json:"id,required"`
  625. Role MessageRole `json:"role,required"`
  626. SessionID string `json:"sessionID,required"`
  627. // This field can have the runtime type of [UserMessageTime],
  628. // [AssistantMessageTime].
  629. Time interface{} `json:"time,required"`
  630. Cost float64 `json:"cost"`
  631. // This field can have the runtime type of [AssistantMessageError].
  632. Error interface{} `json:"error"`
  633. ModelID string `json:"modelID"`
  634. // This field can have the runtime type of [AssistantMessagePath].
  635. Path interface{} `json:"path"`
  636. ProviderID string `json:"providerID"`
  637. Summary bool `json:"summary"`
  638. // This field can have the runtime type of [[]string].
  639. System interface{} `json:"system"`
  640. // This field can have the runtime type of [AssistantMessageTokens].
  641. Tokens interface{} `json:"tokens"`
  642. JSON messageJSON `json:"-"`
  643. union MessageUnion
  644. }
  645. // messageJSON contains the JSON metadata for the struct [Message]
  646. type messageJSON struct {
  647. ID apijson.Field
  648. Role apijson.Field
  649. SessionID apijson.Field
  650. Time apijson.Field
  651. Cost apijson.Field
  652. Error apijson.Field
  653. ModelID apijson.Field
  654. Path apijson.Field
  655. ProviderID apijson.Field
  656. Summary apijson.Field
  657. System apijson.Field
  658. Tokens apijson.Field
  659. raw string
  660. ExtraFields map[string]apijson.Field
  661. }
  662. func (r messageJSON) RawJSON() string {
  663. return r.raw
  664. }
  665. func (r *Message) UnmarshalJSON(data []byte) (err error) {
  666. *r = Message{}
  667. err = apijson.UnmarshalRoot(data, &r.union)
  668. if err != nil {
  669. return err
  670. }
  671. return apijson.Port(r.union, &r)
  672. }
  673. // AsUnion returns a [MessageUnion] interface which you can cast to the specific
  674. // types for more type safety.
  675. //
  676. // Possible runtime types of the union are [UserMessage], [AssistantMessage].
  677. func (r Message) AsUnion() MessageUnion {
  678. return r.union
  679. }
  680. // Union satisfied by [UserMessage] or [AssistantMessage].
  681. type MessageUnion interface {
  682. implementsMessage()
  683. }
  684. func init() {
  685. apijson.RegisterUnion(
  686. reflect.TypeOf((*MessageUnion)(nil)).Elem(),
  687. "role",
  688. apijson.UnionVariant{
  689. TypeFilter: gjson.JSON,
  690. Type: reflect.TypeOf(UserMessage{}),
  691. DiscriminatorValue: "user",
  692. },
  693. apijson.UnionVariant{
  694. TypeFilter: gjson.JSON,
  695. Type: reflect.TypeOf(AssistantMessage{}),
  696. DiscriminatorValue: "assistant",
  697. },
  698. )
  699. }
  700. type MessageRole string
  701. const (
  702. MessageRoleUser MessageRole = "user"
  703. MessageRoleAssistant MessageRole = "assistant"
  704. )
  705. func (r MessageRole) IsKnown() bool {
  706. switch r {
  707. case MessageRoleUser, MessageRoleAssistant:
  708. return true
  709. }
  710. return false
  711. }
  712. type Part struct {
  713. ID string `json:"id,required"`
  714. MessageID string `json:"messageID,required"`
  715. SessionID string `json:"sessionID,required"`
  716. Type PartType `json:"type,required"`
  717. CallID string `json:"callID"`
  718. Cost float64 `json:"cost"`
  719. Filename string `json:"filename"`
  720. Mime string `json:"mime"`
  721. Snapshot string `json:"snapshot"`
  722. Source FilePartSource `json:"source"`
  723. // This field can have the runtime type of [ToolPartState].
  724. State interface{} `json:"state"`
  725. Synthetic bool `json:"synthetic"`
  726. Text string `json:"text"`
  727. // This field can have the runtime type of [TextPartTime].
  728. Time interface{} `json:"time"`
  729. // This field can have the runtime type of [StepFinishPartTokens].
  730. Tokens interface{} `json:"tokens"`
  731. Tool string `json:"tool"`
  732. URL string `json:"url"`
  733. JSON partJSON `json:"-"`
  734. union PartUnion
  735. }
  736. // partJSON contains the JSON metadata for the struct [Part]
  737. type partJSON struct {
  738. ID apijson.Field
  739. MessageID apijson.Field
  740. SessionID apijson.Field
  741. Type apijson.Field
  742. CallID apijson.Field
  743. Cost apijson.Field
  744. Filename apijson.Field
  745. Mime apijson.Field
  746. Snapshot apijson.Field
  747. Source apijson.Field
  748. State apijson.Field
  749. Synthetic apijson.Field
  750. Text apijson.Field
  751. Time apijson.Field
  752. Tokens apijson.Field
  753. Tool apijson.Field
  754. URL apijson.Field
  755. raw string
  756. ExtraFields map[string]apijson.Field
  757. }
  758. func (r partJSON) RawJSON() string {
  759. return r.raw
  760. }
  761. func (r *Part) UnmarshalJSON(data []byte) (err error) {
  762. *r = Part{}
  763. err = apijson.UnmarshalRoot(data, &r.union)
  764. if err != nil {
  765. return err
  766. }
  767. return apijson.Port(r.union, &r)
  768. }
  769. // AsUnion returns a [PartUnion] interface which you can cast to the specific types
  770. // for more type safety.
  771. //
  772. // Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
  773. // [StepStartPart], [StepFinishPart], [SnapshotPart].
  774. func (r Part) AsUnion() PartUnion {
  775. return r.union
  776. }
  777. // Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
  778. // [StepFinishPart] or [SnapshotPart].
  779. type PartUnion interface {
  780. implementsPart()
  781. }
  782. func init() {
  783. apijson.RegisterUnion(
  784. reflect.TypeOf((*PartUnion)(nil)).Elem(),
  785. "type",
  786. apijson.UnionVariant{
  787. TypeFilter: gjson.JSON,
  788. Type: reflect.TypeOf(TextPart{}),
  789. DiscriminatorValue: "text",
  790. },
  791. apijson.UnionVariant{
  792. TypeFilter: gjson.JSON,
  793. Type: reflect.TypeOf(FilePart{}),
  794. DiscriminatorValue: "file",
  795. },
  796. apijson.UnionVariant{
  797. TypeFilter: gjson.JSON,
  798. Type: reflect.TypeOf(ToolPart{}),
  799. DiscriminatorValue: "tool",
  800. },
  801. apijson.UnionVariant{
  802. TypeFilter: gjson.JSON,
  803. Type: reflect.TypeOf(StepStartPart{}),
  804. DiscriminatorValue: "step-start",
  805. },
  806. apijson.UnionVariant{
  807. TypeFilter: gjson.JSON,
  808. Type: reflect.TypeOf(StepFinishPart{}),
  809. DiscriminatorValue: "step-finish",
  810. },
  811. apijson.UnionVariant{
  812. TypeFilter: gjson.JSON,
  813. Type: reflect.TypeOf(SnapshotPart{}),
  814. DiscriminatorValue: "snapshot",
  815. },
  816. )
  817. }
  818. type PartType string
  819. const (
  820. PartTypeText PartType = "text"
  821. PartTypeFile PartType = "file"
  822. PartTypeTool PartType = "tool"
  823. PartTypeStepStart PartType = "step-start"
  824. PartTypeStepFinish PartType = "step-finish"
  825. PartTypeSnapshot PartType = "snapshot"
  826. )
  827. func (r PartType) IsKnown() bool {
  828. switch r {
  829. case PartTypeText, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish, PartTypeSnapshot:
  830. return true
  831. }
  832. return false
  833. }
  834. type Session struct {
  835. ID string `json:"id,required"`
  836. Time SessionTime `json:"time,required"`
  837. Title string `json:"title,required"`
  838. Version string `json:"version,required"`
  839. ParentID string `json:"parentID"`
  840. Revert SessionRevert `json:"revert"`
  841. Share SessionShare `json:"share"`
  842. JSON sessionJSON `json:"-"`
  843. }
  844. // sessionJSON contains the JSON metadata for the struct [Session]
  845. type sessionJSON struct {
  846. ID apijson.Field
  847. Time apijson.Field
  848. Title apijson.Field
  849. Version apijson.Field
  850. ParentID apijson.Field
  851. Revert apijson.Field
  852. Share apijson.Field
  853. raw string
  854. ExtraFields map[string]apijson.Field
  855. }
  856. func (r *Session) UnmarshalJSON(data []byte) (err error) {
  857. return apijson.UnmarshalRoot(data, r)
  858. }
  859. func (r sessionJSON) RawJSON() string {
  860. return r.raw
  861. }
  862. type SessionTime struct {
  863. Created float64 `json:"created,required"`
  864. Updated float64 `json:"updated,required"`
  865. JSON sessionTimeJSON `json:"-"`
  866. }
  867. // sessionTimeJSON contains the JSON metadata for the struct [SessionTime]
  868. type sessionTimeJSON struct {
  869. Created apijson.Field
  870. Updated apijson.Field
  871. raw string
  872. ExtraFields map[string]apijson.Field
  873. }
  874. func (r *SessionTime) UnmarshalJSON(data []byte) (err error) {
  875. return apijson.UnmarshalRoot(data, r)
  876. }
  877. func (r sessionTimeJSON) RawJSON() string {
  878. return r.raw
  879. }
  880. type SessionRevert struct {
  881. MessageID string `json:"messageID,required"`
  882. PartID string `json:"partID"`
  883. Snapshot string `json:"snapshot"`
  884. JSON sessionRevertJSON `json:"-"`
  885. }
  886. // sessionRevertJSON contains the JSON metadata for the struct [SessionRevert]
  887. type sessionRevertJSON struct {
  888. MessageID apijson.Field
  889. PartID apijson.Field
  890. Snapshot apijson.Field
  891. raw string
  892. ExtraFields map[string]apijson.Field
  893. }
  894. func (r *SessionRevert) UnmarshalJSON(data []byte) (err error) {
  895. return apijson.UnmarshalRoot(data, r)
  896. }
  897. func (r sessionRevertJSON) RawJSON() string {
  898. return r.raw
  899. }
  900. type SessionShare struct {
  901. URL string `json:"url,required"`
  902. JSON sessionShareJSON `json:"-"`
  903. }
  904. // sessionShareJSON contains the JSON metadata for the struct [SessionShare]
  905. type sessionShareJSON struct {
  906. URL apijson.Field
  907. raw string
  908. ExtraFields map[string]apijson.Field
  909. }
  910. func (r *SessionShare) UnmarshalJSON(data []byte) (err error) {
  911. return apijson.UnmarshalRoot(data, r)
  912. }
  913. func (r sessionShareJSON) RawJSON() string {
  914. return r.raw
  915. }
  916. type SnapshotPart struct {
  917. ID string `json:"id,required"`
  918. MessageID string `json:"messageID,required"`
  919. SessionID string `json:"sessionID,required"`
  920. Snapshot string `json:"snapshot,required"`
  921. Type SnapshotPartType `json:"type,required"`
  922. JSON snapshotPartJSON `json:"-"`
  923. }
  924. // snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
  925. type snapshotPartJSON struct {
  926. ID apijson.Field
  927. MessageID apijson.Field
  928. SessionID apijson.Field
  929. Snapshot apijson.Field
  930. Type apijson.Field
  931. raw string
  932. ExtraFields map[string]apijson.Field
  933. }
  934. func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
  935. return apijson.UnmarshalRoot(data, r)
  936. }
  937. func (r snapshotPartJSON) RawJSON() string {
  938. return r.raw
  939. }
  940. func (r SnapshotPart) implementsPart() {}
  941. type SnapshotPartType string
  942. const (
  943. SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
  944. )
  945. func (r SnapshotPartType) IsKnown() bool {
  946. switch r {
  947. case SnapshotPartTypeSnapshot:
  948. return true
  949. }
  950. return false
  951. }
  952. type StepFinishPart struct {
  953. ID string `json:"id,required"`
  954. Cost float64 `json:"cost,required"`
  955. MessageID string `json:"messageID,required"`
  956. SessionID string `json:"sessionID,required"`
  957. Tokens StepFinishPartTokens `json:"tokens,required"`
  958. Type StepFinishPartType `json:"type,required"`
  959. JSON stepFinishPartJSON `json:"-"`
  960. }
  961. // stepFinishPartJSON contains the JSON metadata for the struct [StepFinishPart]
  962. type stepFinishPartJSON struct {
  963. ID apijson.Field
  964. Cost apijson.Field
  965. MessageID apijson.Field
  966. SessionID apijson.Field
  967. Tokens apijson.Field
  968. Type apijson.Field
  969. raw string
  970. ExtraFields map[string]apijson.Field
  971. }
  972. func (r *StepFinishPart) UnmarshalJSON(data []byte) (err error) {
  973. return apijson.UnmarshalRoot(data, r)
  974. }
  975. func (r stepFinishPartJSON) RawJSON() string {
  976. return r.raw
  977. }
  978. func (r StepFinishPart) implementsPart() {}
  979. type StepFinishPartTokens struct {
  980. Cache StepFinishPartTokensCache `json:"cache,required"`
  981. Input float64 `json:"input,required"`
  982. Output float64 `json:"output,required"`
  983. Reasoning float64 `json:"reasoning,required"`
  984. JSON stepFinishPartTokensJSON `json:"-"`
  985. }
  986. // stepFinishPartTokensJSON contains the JSON metadata for the struct
  987. // [StepFinishPartTokens]
  988. type stepFinishPartTokensJSON struct {
  989. Cache apijson.Field
  990. Input apijson.Field
  991. Output apijson.Field
  992. Reasoning apijson.Field
  993. raw string
  994. ExtraFields map[string]apijson.Field
  995. }
  996. func (r *StepFinishPartTokens) UnmarshalJSON(data []byte) (err error) {
  997. return apijson.UnmarshalRoot(data, r)
  998. }
  999. func (r stepFinishPartTokensJSON) RawJSON() string {
  1000. return r.raw
  1001. }
  1002. type StepFinishPartTokensCache struct {
  1003. Read float64 `json:"read,required"`
  1004. Write float64 `json:"write,required"`
  1005. JSON stepFinishPartTokensCacheJSON `json:"-"`
  1006. }
  1007. // stepFinishPartTokensCacheJSON contains the JSON metadata for the struct
  1008. // [StepFinishPartTokensCache]
  1009. type stepFinishPartTokensCacheJSON struct {
  1010. Read apijson.Field
  1011. Write apijson.Field
  1012. raw string
  1013. ExtraFields map[string]apijson.Field
  1014. }
  1015. func (r *StepFinishPartTokensCache) UnmarshalJSON(data []byte) (err error) {
  1016. return apijson.UnmarshalRoot(data, r)
  1017. }
  1018. func (r stepFinishPartTokensCacheJSON) RawJSON() string {
  1019. return r.raw
  1020. }
  1021. type StepFinishPartType string
  1022. const (
  1023. StepFinishPartTypeStepFinish StepFinishPartType = "step-finish"
  1024. )
  1025. func (r StepFinishPartType) IsKnown() bool {
  1026. switch r {
  1027. case StepFinishPartTypeStepFinish:
  1028. return true
  1029. }
  1030. return false
  1031. }
  1032. type StepStartPart struct {
  1033. ID string `json:"id,required"`
  1034. MessageID string `json:"messageID,required"`
  1035. SessionID string `json:"sessionID,required"`
  1036. Type StepStartPartType `json:"type,required"`
  1037. JSON stepStartPartJSON `json:"-"`
  1038. }
  1039. // stepStartPartJSON contains the JSON metadata for the struct [StepStartPart]
  1040. type stepStartPartJSON struct {
  1041. ID apijson.Field
  1042. MessageID apijson.Field
  1043. SessionID apijson.Field
  1044. Type apijson.Field
  1045. raw string
  1046. ExtraFields map[string]apijson.Field
  1047. }
  1048. func (r *StepStartPart) UnmarshalJSON(data []byte) (err error) {
  1049. return apijson.UnmarshalRoot(data, r)
  1050. }
  1051. func (r stepStartPartJSON) RawJSON() string {
  1052. return r.raw
  1053. }
  1054. func (r StepStartPart) implementsPart() {}
  1055. type StepStartPartType string
  1056. const (
  1057. StepStartPartTypeStepStart StepStartPartType = "step-start"
  1058. )
  1059. func (r StepStartPartType) IsKnown() bool {
  1060. switch r {
  1061. case StepStartPartTypeStepStart:
  1062. return true
  1063. }
  1064. return false
  1065. }
  1066. type SymbolSource struct {
  1067. Kind int64 `json:"kind,required"`
  1068. Name string `json:"name,required"`
  1069. Path string `json:"path,required"`
  1070. Range SymbolSourceRange `json:"range,required"`
  1071. Text FilePartSourceText `json:"text,required"`
  1072. Type SymbolSourceType `json:"type,required"`
  1073. JSON symbolSourceJSON `json:"-"`
  1074. }
  1075. // symbolSourceJSON contains the JSON metadata for the struct [SymbolSource]
  1076. type symbolSourceJSON struct {
  1077. Kind apijson.Field
  1078. Name apijson.Field
  1079. Path apijson.Field
  1080. Range apijson.Field
  1081. Text apijson.Field
  1082. Type apijson.Field
  1083. raw string
  1084. ExtraFields map[string]apijson.Field
  1085. }
  1086. func (r *SymbolSource) UnmarshalJSON(data []byte) (err error) {
  1087. return apijson.UnmarshalRoot(data, r)
  1088. }
  1089. func (r symbolSourceJSON) RawJSON() string {
  1090. return r.raw
  1091. }
  1092. func (r SymbolSource) implementsFilePartSource() {}
  1093. type SymbolSourceRange struct {
  1094. End SymbolSourceRangeEnd `json:"end,required"`
  1095. Start SymbolSourceRangeStart `json:"start,required"`
  1096. JSON symbolSourceRangeJSON `json:"-"`
  1097. }
  1098. // symbolSourceRangeJSON contains the JSON metadata for the struct
  1099. // [SymbolSourceRange]
  1100. type symbolSourceRangeJSON struct {
  1101. End apijson.Field
  1102. Start apijson.Field
  1103. raw string
  1104. ExtraFields map[string]apijson.Field
  1105. }
  1106. func (r *SymbolSourceRange) UnmarshalJSON(data []byte) (err error) {
  1107. return apijson.UnmarshalRoot(data, r)
  1108. }
  1109. func (r symbolSourceRangeJSON) RawJSON() string {
  1110. return r.raw
  1111. }
  1112. type SymbolSourceRangeEnd struct {
  1113. Character float64 `json:"character,required"`
  1114. Line float64 `json:"line,required"`
  1115. JSON symbolSourceRangeEndJSON `json:"-"`
  1116. }
  1117. // symbolSourceRangeEndJSON contains the JSON metadata for the struct
  1118. // [SymbolSourceRangeEnd]
  1119. type symbolSourceRangeEndJSON struct {
  1120. Character apijson.Field
  1121. Line apijson.Field
  1122. raw string
  1123. ExtraFields map[string]apijson.Field
  1124. }
  1125. func (r *SymbolSourceRangeEnd) UnmarshalJSON(data []byte) (err error) {
  1126. return apijson.UnmarshalRoot(data, r)
  1127. }
  1128. func (r symbolSourceRangeEndJSON) RawJSON() string {
  1129. return r.raw
  1130. }
  1131. type SymbolSourceRangeStart struct {
  1132. Character float64 `json:"character,required"`
  1133. Line float64 `json:"line,required"`
  1134. JSON symbolSourceRangeStartJSON `json:"-"`
  1135. }
  1136. // symbolSourceRangeStartJSON contains the JSON metadata for the struct
  1137. // [SymbolSourceRangeStart]
  1138. type symbolSourceRangeStartJSON struct {
  1139. Character apijson.Field
  1140. Line apijson.Field
  1141. raw string
  1142. ExtraFields map[string]apijson.Field
  1143. }
  1144. func (r *SymbolSourceRangeStart) UnmarshalJSON(data []byte) (err error) {
  1145. return apijson.UnmarshalRoot(data, r)
  1146. }
  1147. func (r symbolSourceRangeStartJSON) RawJSON() string {
  1148. return r.raw
  1149. }
  1150. type SymbolSourceType string
  1151. const (
  1152. SymbolSourceTypeSymbol SymbolSourceType = "symbol"
  1153. )
  1154. func (r SymbolSourceType) IsKnown() bool {
  1155. switch r {
  1156. case SymbolSourceTypeSymbol:
  1157. return true
  1158. }
  1159. return false
  1160. }
  1161. type SymbolSourceParam struct {
  1162. Kind param.Field[int64] `json:"kind,required"`
  1163. Name param.Field[string] `json:"name,required"`
  1164. Path param.Field[string] `json:"path,required"`
  1165. Range param.Field[SymbolSourceRangeParam] `json:"range,required"`
  1166. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  1167. Type param.Field[SymbolSourceType] `json:"type,required"`
  1168. }
  1169. func (r SymbolSourceParam) MarshalJSON() (data []byte, err error) {
  1170. return apijson.MarshalRoot(r)
  1171. }
  1172. func (r SymbolSourceParam) implementsFilePartSourceUnionParam() {}
  1173. type SymbolSourceRangeParam struct {
  1174. End param.Field[SymbolSourceRangeEndParam] `json:"end,required"`
  1175. Start param.Field[SymbolSourceRangeStartParam] `json:"start,required"`
  1176. }
  1177. func (r SymbolSourceRangeParam) MarshalJSON() (data []byte, err error) {
  1178. return apijson.MarshalRoot(r)
  1179. }
  1180. type SymbolSourceRangeEndParam struct {
  1181. Character param.Field[float64] `json:"character,required"`
  1182. Line param.Field[float64] `json:"line,required"`
  1183. }
  1184. func (r SymbolSourceRangeEndParam) MarshalJSON() (data []byte, err error) {
  1185. return apijson.MarshalRoot(r)
  1186. }
  1187. type SymbolSourceRangeStartParam struct {
  1188. Character param.Field[float64] `json:"character,required"`
  1189. Line param.Field[float64] `json:"line,required"`
  1190. }
  1191. func (r SymbolSourceRangeStartParam) MarshalJSON() (data []byte, err error) {
  1192. return apijson.MarshalRoot(r)
  1193. }
  1194. type TextPart struct {
  1195. ID string `json:"id,required"`
  1196. MessageID string `json:"messageID,required"`
  1197. SessionID string `json:"sessionID,required"`
  1198. Text string `json:"text,required"`
  1199. Type TextPartType `json:"type,required"`
  1200. Synthetic bool `json:"synthetic"`
  1201. Time TextPartTime `json:"time"`
  1202. JSON textPartJSON `json:"-"`
  1203. }
  1204. // textPartJSON contains the JSON metadata for the struct [TextPart]
  1205. type textPartJSON struct {
  1206. ID apijson.Field
  1207. MessageID apijson.Field
  1208. SessionID apijson.Field
  1209. Text apijson.Field
  1210. Type apijson.Field
  1211. Synthetic apijson.Field
  1212. Time apijson.Field
  1213. raw string
  1214. ExtraFields map[string]apijson.Field
  1215. }
  1216. func (r *TextPart) UnmarshalJSON(data []byte) (err error) {
  1217. return apijson.UnmarshalRoot(data, r)
  1218. }
  1219. func (r textPartJSON) RawJSON() string {
  1220. return r.raw
  1221. }
  1222. func (r TextPart) implementsPart() {}
  1223. type TextPartType string
  1224. const (
  1225. TextPartTypeText TextPartType = "text"
  1226. )
  1227. func (r TextPartType) IsKnown() bool {
  1228. switch r {
  1229. case TextPartTypeText:
  1230. return true
  1231. }
  1232. return false
  1233. }
  1234. type TextPartTime struct {
  1235. Start float64 `json:"start,required"`
  1236. End float64 `json:"end"`
  1237. JSON textPartTimeJSON `json:"-"`
  1238. }
  1239. // textPartTimeJSON contains the JSON metadata for the struct [TextPartTime]
  1240. type textPartTimeJSON struct {
  1241. Start apijson.Field
  1242. End apijson.Field
  1243. raw string
  1244. ExtraFields map[string]apijson.Field
  1245. }
  1246. func (r *TextPartTime) UnmarshalJSON(data []byte) (err error) {
  1247. return apijson.UnmarshalRoot(data, r)
  1248. }
  1249. func (r textPartTimeJSON) RawJSON() string {
  1250. return r.raw
  1251. }
  1252. type TextPartInputParam struct {
  1253. Text param.Field[string] `json:"text,required"`
  1254. Type param.Field[TextPartInputType] `json:"type,required"`
  1255. ID param.Field[string] `json:"id"`
  1256. Synthetic param.Field[bool] `json:"synthetic"`
  1257. Time param.Field[TextPartInputTimeParam] `json:"time"`
  1258. }
  1259. func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
  1260. return apijson.MarshalRoot(r)
  1261. }
  1262. func (r TextPartInputParam) implementsSessionChatParamsPartUnion() {}
  1263. type TextPartInputType string
  1264. const (
  1265. TextPartInputTypeText TextPartInputType = "text"
  1266. )
  1267. func (r TextPartInputType) IsKnown() bool {
  1268. switch r {
  1269. case TextPartInputTypeText:
  1270. return true
  1271. }
  1272. return false
  1273. }
  1274. type TextPartInputTimeParam struct {
  1275. Start param.Field[float64] `json:"start,required"`
  1276. End param.Field[float64] `json:"end"`
  1277. }
  1278. func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
  1279. return apijson.MarshalRoot(r)
  1280. }
  1281. type ToolPart struct {
  1282. ID string `json:"id,required"`
  1283. CallID string `json:"callID,required"`
  1284. MessageID string `json:"messageID,required"`
  1285. SessionID string `json:"sessionID,required"`
  1286. State ToolPartState `json:"state,required"`
  1287. Tool string `json:"tool,required"`
  1288. Type ToolPartType `json:"type,required"`
  1289. JSON toolPartJSON `json:"-"`
  1290. }
  1291. // toolPartJSON contains the JSON metadata for the struct [ToolPart]
  1292. type toolPartJSON struct {
  1293. ID apijson.Field
  1294. CallID apijson.Field
  1295. MessageID apijson.Field
  1296. SessionID apijson.Field
  1297. State apijson.Field
  1298. Tool apijson.Field
  1299. Type apijson.Field
  1300. raw string
  1301. ExtraFields map[string]apijson.Field
  1302. }
  1303. func (r *ToolPart) UnmarshalJSON(data []byte) (err error) {
  1304. return apijson.UnmarshalRoot(data, r)
  1305. }
  1306. func (r toolPartJSON) RawJSON() string {
  1307. return r.raw
  1308. }
  1309. func (r ToolPart) implementsPart() {}
  1310. type ToolPartState struct {
  1311. Status ToolPartStateStatus `json:"status,required"`
  1312. Error string `json:"error"`
  1313. // This field can have the runtime type of [interface{}], [map[string]interface{}].
  1314. Input interface{} `json:"input"`
  1315. // This field can have the runtime type of [map[string]interface{}].
  1316. Metadata interface{} `json:"metadata"`
  1317. Output string `json:"output"`
  1318. // This field can have the runtime type of [ToolStateRunningTime],
  1319. // [ToolStateCompletedTime], [ToolStateErrorTime].
  1320. Time interface{} `json:"time"`
  1321. Title string `json:"title"`
  1322. JSON toolPartStateJSON `json:"-"`
  1323. union ToolPartStateUnion
  1324. }
  1325. // toolPartStateJSON contains the JSON metadata for the struct [ToolPartState]
  1326. type toolPartStateJSON struct {
  1327. Status apijson.Field
  1328. Error apijson.Field
  1329. Input apijson.Field
  1330. Metadata apijson.Field
  1331. Output apijson.Field
  1332. Time apijson.Field
  1333. Title apijson.Field
  1334. raw string
  1335. ExtraFields map[string]apijson.Field
  1336. }
  1337. func (r toolPartStateJSON) RawJSON() string {
  1338. return r.raw
  1339. }
  1340. func (r *ToolPartState) UnmarshalJSON(data []byte) (err error) {
  1341. *r = ToolPartState{}
  1342. err = apijson.UnmarshalRoot(data, &r.union)
  1343. if err != nil {
  1344. return err
  1345. }
  1346. return apijson.Port(r.union, &r)
  1347. }
  1348. // AsUnion returns a [ToolPartStateUnion] interface which you can cast to the
  1349. // specific types for more type safety.
  1350. //
  1351. // Possible runtime types of the union are [ToolStatePending], [ToolStateRunning],
  1352. // [ToolStateCompleted], [ToolStateError].
  1353. func (r ToolPartState) AsUnion() ToolPartStateUnion {
  1354. return r.union
  1355. }
  1356. // Union satisfied by [ToolStatePending], [ToolStateRunning], [ToolStateCompleted]
  1357. // or [ToolStateError].
  1358. type ToolPartStateUnion interface {
  1359. implementsToolPartState()
  1360. }
  1361. func init() {
  1362. apijson.RegisterUnion(
  1363. reflect.TypeOf((*ToolPartStateUnion)(nil)).Elem(),
  1364. "status",
  1365. apijson.UnionVariant{
  1366. TypeFilter: gjson.JSON,
  1367. Type: reflect.TypeOf(ToolStatePending{}),
  1368. DiscriminatorValue: "pending",
  1369. },
  1370. apijson.UnionVariant{
  1371. TypeFilter: gjson.JSON,
  1372. Type: reflect.TypeOf(ToolStateRunning{}),
  1373. DiscriminatorValue: "running",
  1374. },
  1375. apijson.UnionVariant{
  1376. TypeFilter: gjson.JSON,
  1377. Type: reflect.TypeOf(ToolStateCompleted{}),
  1378. DiscriminatorValue: "completed",
  1379. },
  1380. apijson.UnionVariant{
  1381. TypeFilter: gjson.JSON,
  1382. Type: reflect.TypeOf(ToolStateError{}),
  1383. DiscriminatorValue: "error",
  1384. },
  1385. )
  1386. }
  1387. type ToolPartStateStatus string
  1388. const (
  1389. ToolPartStateStatusPending ToolPartStateStatus = "pending"
  1390. ToolPartStateStatusRunning ToolPartStateStatus = "running"
  1391. ToolPartStateStatusCompleted ToolPartStateStatus = "completed"
  1392. ToolPartStateStatusError ToolPartStateStatus = "error"
  1393. )
  1394. func (r ToolPartStateStatus) IsKnown() bool {
  1395. switch r {
  1396. case ToolPartStateStatusPending, ToolPartStateStatusRunning, ToolPartStateStatusCompleted, ToolPartStateStatusError:
  1397. return true
  1398. }
  1399. return false
  1400. }
  1401. type ToolPartType string
  1402. const (
  1403. ToolPartTypeTool ToolPartType = "tool"
  1404. )
  1405. func (r ToolPartType) IsKnown() bool {
  1406. switch r {
  1407. case ToolPartTypeTool:
  1408. return true
  1409. }
  1410. return false
  1411. }
  1412. type ToolStateCompleted struct {
  1413. Input map[string]interface{} `json:"input,required"`
  1414. Metadata map[string]interface{} `json:"metadata,required"`
  1415. Output string `json:"output,required"`
  1416. Status ToolStateCompletedStatus `json:"status,required"`
  1417. Time ToolStateCompletedTime `json:"time,required"`
  1418. Title string `json:"title,required"`
  1419. JSON toolStateCompletedJSON `json:"-"`
  1420. }
  1421. // toolStateCompletedJSON contains the JSON metadata for the struct
  1422. // [ToolStateCompleted]
  1423. type toolStateCompletedJSON struct {
  1424. Input apijson.Field
  1425. Metadata apijson.Field
  1426. Output apijson.Field
  1427. Status apijson.Field
  1428. Time apijson.Field
  1429. Title apijson.Field
  1430. raw string
  1431. ExtraFields map[string]apijson.Field
  1432. }
  1433. func (r *ToolStateCompleted) UnmarshalJSON(data []byte) (err error) {
  1434. return apijson.UnmarshalRoot(data, r)
  1435. }
  1436. func (r toolStateCompletedJSON) RawJSON() string {
  1437. return r.raw
  1438. }
  1439. func (r ToolStateCompleted) implementsToolPartState() {}
  1440. type ToolStateCompletedStatus string
  1441. const (
  1442. ToolStateCompletedStatusCompleted ToolStateCompletedStatus = "completed"
  1443. )
  1444. func (r ToolStateCompletedStatus) IsKnown() bool {
  1445. switch r {
  1446. case ToolStateCompletedStatusCompleted:
  1447. return true
  1448. }
  1449. return false
  1450. }
  1451. type ToolStateCompletedTime struct {
  1452. End float64 `json:"end,required"`
  1453. Start float64 `json:"start,required"`
  1454. JSON toolStateCompletedTimeJSON `json:"-"`
  1455. }
  1456. // toolStateCompletedTimeJSON contains the JSON metadata for the struct
  1457. // [ToolStateCompletedTime]
  1458. type toolStateCompletedTimeJSON struct {
  1459. End apijson.Field
  1460. Start apijson.Field
  1461. raw string
  1462. ExtraFields map[string]apijson.Field
  1463. }
  1464. func (r *ToolStateCompletedTime) UnmarshalJSON(data []byte) (err error) {
  1465. return apijson.UnmarshalRoot(data, r)
  1466. }
  1467. func (r toolStateCompletedTimeJSON) RawJSON() string {
  1468. return r.raw
  1469. }
  1470. type ToolStateError struct {
  1471. Error string `json:"error,required"`
  1472. Input map[string]interface{} `json:"input,required"`
  1473. Status ToolStateErrorStatus `json:"status,required"`
  1474. Time ToolStateErrorTime `json:"time,required"`
  1475. JSON toolStateErrorJSON `json:"-"`
  1476. }
  1477. // toolStateErrorJSON contains the JSON metadata for the struct [ToolStateError]
  1478. type toolStateErrorJSON struct {
  1479. Error apijson.Field
  1480. Input apijson.Field
  1481. Status apijson.Field
  1482. Time apijson.Field
  1483. raw string
  1484. ExtraFields map[string]apijson.Field
  1485. }
  1486. func (r *ToolStateError) UnmarshalJSON(data []byte) (err error) {
  1487. return apijson.UnmarshalRoot(data, r)
  1488. }
  1489. func (r toolStateErrorJSON) RawJSON() string {
  1490. return r.raw
  1491. }
  1492. func (r ToolStateError) implementsToolPartState() {}
  1493. type ToolStateErrorStatus string
  1494. const (
  1495. ToolStateErrorStatusError ToolStateErrorStatus = "error"
  1496. )
  1497. func (r ToolStateErrorStatus) IsKnown() bool {
  1498. switch r {
  1499. case ToolStateErrorStatusError:
  1500. return true
  1501. }
  1502. return false
  1503. }
  1504. type ToolStateErrorTime struct {
  1505. End float64 `json:"end,required"`
  1506. Start float64 `json:"start,required"`
  1507. JSON toolStateErrorTimeJSON `json:"-"`
  1508. }
  1509. // toolStateErrorTimeJSON contains the JSON metadata for the struct
  1510. // [ToolStateErrorTime]
  1511. type toolStateErrorTimeJSON struct {
  1512. End apijson.Field
  1513. Start apijson.Field
  1514. raw string
  1515. ExtraFields map[string]apijson.Field
  1516. }
  1517. func (r *ToolStateErrorTime) UnmarshalJSON(data []byte) (err error) {
  1518. return apijson.UnmarshalRoot(data, r)
  1519. }
  1520. func (r toolStateErrorTimeJSON) RawJSON() string {
  1521. return r.raw
  1522. }
  1523. type ToolStatePending struct {
  1524. Status ToolStatePendingStatus `json:"status,required"`
  1525. JSON toolStatePendingJSON `json:"-"`
  1526. }
  1527. // toolStatePendingJSON contains the JSON metadata for the struct
  1528. // [ToolStatePending]
  1529. type toolStatePendingJSON struct {
  1530. Status apijson.Field
  1531. raw string
  1532. ExtraFields map[string]apijson.Field
  1533. }
  1534. func (r *ToolStatePending) UnmarshalJSON(data []byte) (err error) {
  1535. return apijson.UnmarshalRoot(data, r)
  1536. }
  1537. func (r toolStatePendingJSON) RawJSON() string {
  1538. return r.raw
  1539. }
  1540. func (r ToolStatePending) implementsToolPartState() {}
  1541. type ToolStatePendingStatus string
  1542. const (
  1543. ToolStatePendingStatusPending ToolStatePendingStatus = "pending"
  1544. )
  1545. func (r ToolStatePendingStatus) IsKnown() bool {
  1546. switch r {
  1547. case ToolStatePendingStatusPending:
  1548. return true
  1549. }
  1550. return false
  1551. }
  1552. type ToolStateRunning struct {
  1553. Status ToolStateRunningStatus `json:"status,required"`
  1554. Time ToolStateRunningTime `json:"time,required"`
  1555. Input interface{} `json:"input"`
  1556. Metadata map[string]interface{} `json:"metadata"`
  1557. Title string `json:"title"`
  1558. JSON toolStateRunningJSON `json:"-"`
  1559. }
  1560. // toolStateRunningJSON contains the JSON metadata for the struct
  1561. // [ToolStateRunning]
  1562. type toolStateRunningJSON struct {
  1563. Status apijson.Field
  1564. Time apijson.Field
  1565. Input apijson.Field
  1566. Metadata apijson.Field
  1567. Title apijson.Field
  1568. raw string
  1569. ExtraFields map[string]apijson.Field
  1570. }
  1571. func (r *ToolStateRunning) UnmarshalJSON(data []byte) (err error) {
  1572. return apijson.UnmarshalRoot(data, r)
  1573. }
  1574. func (r toolStateRunningJSON) RawJSON() string {
  1575. return r.raw
  1576. }
  1577. func (r ToolStateRunning) implementsToolPartState() {}
  1578. type ToolStateRunningStatus string
  1579. const (
  1580. ToolStateRunningStatusRunning ToolStateRunningStatus = "running"
  1581. )
  1582. func (r ToolStateRunningStatus) IsKnown() bool {
  1583. switch r {
  1584. case ToolStateRunningStatusRunning:
  1585. return true
  1586. }
  1587. return false
  1588. }
  1589. type ToolStateRunningTime struct {
  1590. Start float64 `json:"start,required"`
  1591. JSON toolStateRunningTimeJSON `json:"-"`
  1592. }
  1593. // toolStateRunningTimeJSON contains the JSON metadata for the struct
  1594. // [ToolStateRunningTime]
  1595. type toolStateRunningTimeJSON struct {
  1596. Start apijson.Field
  1597. raw string
  1598. ExtraFields map[string]apijson.Field
  1599. }
  1600. func (r *ToolStateRunningTime) UnmarshalJSON(data []byte) (err error) {
  1601. return apijson.UnmarshalRoot(data, r)
  1602. }
  1603. func (r toolStateRunningTimeJSON) RawJSON() string {
  1604. return r.raw
  1605. }
  1606. type UserMessage struct {
  1607. ID string `json:"id,required"`
  1608. Role UserMessageRole `json:"role,required"`
  1609. SessionID string `json:"sessionID,required"`
  1610. Time UserMessageTime `json:"time,required"`
  1611. JSON userMessageJSON `json:"-"`
  1612. }
  1613. // userMessageJSON contains the JSON metadata for the struct [UserMessage]
  1614. type userMessageJSON struct {
  1615. ID apijson.Field
  1616. Role apijson.Field
  1617. SessionID apijson.Field
  1618. Time apijson.Field
  1619. raw string
  1620. ExtraFields map[string]apijson.Field
  1621. }
  1622. func (r *UserMessage) UnmarshalJSON(data []byte) (err error) {
  1623. return apijson.UnmarshalRoot(data, r)
  1624. }
  1625. func (r userMessageJSON) RawJSON() string {
  1626. return r.raw
  1627. }
  1628. func (r UserMessage) implementsMessage() {}
  1629. type UserMessageRole string
  1630. const (
  1631. UserMessageRoleUser UserMessageRole = "user"
  1632. )
  1633. func (r UserMessageRole) IsKnown() bool {
  1634. switch r {
  1635. case UserMessageRoleUser:
  1636. return true
  1637. }
  1638. return false
  1639. }
  1640. type UserMessageTime struct {
  1641. Created float64 `json:"created,required"`
  1642. JSON userMessageTimeJSON `json:"-"`
  1643. }
  1644. // userMessageTimeJSON contains the JSON metadata for the struct [UserMessageTime]
  1645. type userMessageTimeJSON struct {
  1646. Created apijson.Field
  1647. raw string
  1648. ExtraFields map[string]apijson.Field
  1649. }
  1650. func (r *UserMessageTime) UnmarshalJSON(data []byte) (err error) {
  1651. return apijson.UnmarshalRoot(data, r)
  1652. }
  1653. func (r userMessageTimeJSON) RawJSON() string {
  1654. return r.raw
  1655. }
  1656. type SessionMessagesResponse struct {
  1657. Info Message `json:"info,required"`
  1658. Parts []Part `json:"parts,required"`
  1659. JSON sessionMessagesResponseJSON `json:"-"`
  1660. }
  1661. // sessionMessagesResponseJSON contains the JSON metadata for the struct
  1662. // [SessionMessagesResponse]
  1663. type sessionMessagesResponseJSON struct {
  1664. Info apijson.Field
  1665. Parts apijson.Field
  1666. raw string
  1667. ExtraFields map[string]apijson.Field
  1668. }
  1669. func (r *SessionMessagesResponse) UnmarshalJSON(data []byte) (err error) {
  1670. return apijson.UnmarshalRoot(data, r)
  1671. }
  1672. func (r sessionMessagesResponseJSON) RawJSON() string {
  1673. return r.raw
  1674. }
  1675. type SessionChatParams struct {
  1676. ModelID param.Field[string] `json:"modelID,required"`
  1677. Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
  1678. ProviderID param.Field[string] `json:"providerID,required"`
  1679. MessageID param.Field[string] `json:"messageID"`
  1680. Mode param.Field[string] `json:"mode"`
  1681. Tools param.Field[map[string]bool] `json:"tools"`
  1682. }
  1683. func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
  1684. return apijson.MarshalRoot(r)
  1685. }
  1686. type SessionChatParamsPart struct {
  1687. Type param.Field[SessionChatParamsPartsType] `json:"type,required"`
  1688. ID param.Field[string] `json:"id"`
  1689. Filename param.Field[string] `json:"filename"`
  1690. Mime param.Field[string] `json:"mime"`
  1691. Source param.Field[FilePartSourceUnionParam] `json:"source"`
  1692. Synthetic param.Field[bool] `json:"synthetic"`
  1693. Text param.Field[string] `json:"text"`
  1694. Time param.Field[interface{}] `json:"time"`
  1695. URL param.Field[string] `json:"url"`
  1696. }
  1697. func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
  1698. return apijson.MarshalRoot(r)
  1699. }
  1700. func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
  1701. // Satisfied by [TextPartInputParam], [FilePartInputParam],
  1702. // [SessionChatParamsPart].
  1703. type SessionChatParamsPartUnion interface {
  1704. implementsSessionChatParamsPartUnion()
  1705. }
  1706. type SessionChatParamsPartsType string
  1707. const (
  1708. SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
  1709. SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
  1710. )
  1711. func (r SessionChatParamsPartsType) IsKnown() bool {
  1712. switch r {
  1713. case SessionChatParamsPartsTypeText, SessionChatParamsPartsTypeFile:
  1714. return true
  1715. }
  1716. return false
  1717. }
  1718. type SessionInitParams struct {
  1719. MessageID param.Field[string] `json:"messageID,required"`
  1720. ModelID param.Field[string] `json:"modelID,required"`
  1721. ProviderID param.Field[string] `json:"providerID,required"`
  1722. }
  1723. func (r SessionInitParams) MarshalJSON() (data []byte, err error) {
  1724. return apijson.MarshalRoot(r)
  1725. }
  1726. type SessionRevertParams struct {
  1727. MessageID param.Field[string] `json:"messageID,required"`
  1728. PartID param.Field[string] `json:"partID"`
  1729. }
  1730. func (r SessionRevertParams) MarshalJSON() (data []byte, err error) {
  1731. return apijson.MarshalRoot(r)
  1732. }
  1733. type SessionSummarizeParams struct {
  1734. ModelID param.Field[string] `json:"modelID,required"`
  1735. ProviderID param.Field[string] `json:"providerID,required"`
  1736. }
  1737. func (r SessionSummarizeParams) MarshalJSON() (data []byte, err error) {
  1738. return apijson.MarshalRoot(r)
  1739. }