session.go 56 KB

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