@effect/ai 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/Chat/package.json +6 -0
  2. package/EmbeddingModel/package.json +6 -0
  3. package/IdGenerator/package.json +6 -0
  4. package/LanguageModel/package.json +6 -0
  5. package/Model/package.json +6 -0
  6. package/Prompt/package.json +6 -0
  7. package/Response/package.json +6 -0
  8. package/Telemetry/package.json +6 -0
  9. package/Tool/package.json +6 -0
  10. package/Toolkit/package.json +6 -0
  11. package/dist/cjs/AiError.js +575 -11
  12. package/dist/cjs/AiError.js.map +1 -1
  13. package/dist/cjs/Chat.js +302 -0
  14. package/dist/cjs/Chat.js.map +1 -0
  15. package/dist/cjs/EmbeddingModel.js +184 -0
  16. package/dist/cjs/EmbeddingModel.js.map +1 -0
  17. package/dist/cjs/IdGenerator.js +255 -0
  18. package/dist/cjs/IdGenerator.js.map +1 -0
  19. package/dist/cjs/LanguageModel.js +584 -0
  20. package/dist/cjs/LanguageModel.js.map +1 -0
  21. package/dist/cjs/McpServer.js +12 -4
  22. package/dist/cjs/McpServer.js.map +1 -1
  23. package/dist/cjs/Model.js +118 -0
  24. package/dist/cjs/Model.js.map +1 -0
  25. package/dist/cjs/Prompt.js +649 -0
  26. package/dist/cjs/Prompt.js.map +1 -0
  27. package/dist/cjs/Response.js +635 -0
  28. package/dist/cjs/Response.js.map +1 -0
  29. package/dist/cjs/Telemetry.js +176 -0
  30. package/dist/cjs/Telemetry.js.map +1 -0
  31. package/dist/cjs/Tokenizer.js +87 -8
  32. package/dist/cjs/Tokenizer.js.map +1 -1
  33. package/dist/cjs/Tool.js +556 -0
  34. package/dist/cjs/Tool.js.map +1 -0
  35. package/dist/cjs/Toolkit.js +279 -0
  36. package/dist/cjs/Toolkit.js.map +1 -0
  37. package/dist/cjs/index.js +21 -19
  38. package/dist/dts/AiError.d.ts +577 -9
  39. package/dist/dts/AiError.d.ts.map +1 -1
  40. package/dist/dts/Chat.d.ts +356 -0
  41. package/dist/dts/Chat.d.ts.map +1 -0
  42. package/dist/dts/EmbeddingModel.d.ts +153 -0
  43. package/dist/dts/EmbeddingModel.d.ts.map +1 -0
  44. package/dist/dts/IdGenerator.d.ts +272 -0
  45. package/dist/dts/IdGenerator.d.ts.map +1 -0
  46. package/dist/dts/LanguageModel.d.ts +458 -0
  47. package/dist/dts/LanguageModel.d.ts.map +1 -0
  48. package/dist/dts/McpSchema.d.ts +25 -25
  49. package/dist/dts/McpServer.d.ts +6 -4
  50. package/dist/dts/McpServer.d.ts.map +1 -1
  51. package/dist/dts/Model.d.ts +124 -0
  52. package/dist/dts/Model.d.ts.map +1 -0
  53. package/dist/dts/Prompt.d.ts +1119 -0
  54. package/dist/dts/Prompt.d.ts.map +1 -0
  55. package/dist/dts/Response.d.ts +1519 -0
  56. package/dist/dts/Response.d.ts.map +1 -0
  57. package/dist/dts/Telemetry.d.ts +520 -0
  58. package/dist/dts/Telemetry.d.ts.map +1 -0
  59. package/dist/dts/Tokenizer.d.ts +131 -13
  60. package/dist/dts/Tokenizer.d.ts.map +1 -1
  61. package/dist/dts/Tool.d.ts +876 -0
  62. package/dist/dts/Tool.d.ts.map +1 -0
  63. package/dist/dts/Toolkit.d.ts +310 -0
  64. package/dist/dts/Toolkit.d.ts.map +1 -0
  65. package/dist/dts/index.d.ts +498 -13
  66. package/dist/dts/index.d.ts.map +1 -1
  67. package/dist/esm/AiError.js +570 -10
  68. package/dist/esm/AiError.js.map +1 -1
  69. package/dist/esm/Chat.js +291 -0
  70. package/dist/esm/Chat.js.map +1 -0
  71. package/dist/esm/EmbeddingModel.js +173 -0
  72. package/dist/esm/EmbeddingModel.js.map +1 -0
  73. package/dist/esm/IdGenerator.js +245 -0
  74. package/dist/esm/IdGenerator.js.map +1 -0
  75. package/dist/esm/LanguageModel.js +572 -0
  76. package/dist/esm/LanguageModel.js.map +1 -0
  77. package/dist/esm/McpServer.js +12 -4
  78. package/dist/esm/McpServer.js.map +1 -1
  79. package/dist/esm/Model.js +108 -0
  80. package/dist/esm/Model.js.map +1 -0
  81. package/dist/esm/Prompt.js +633 -0
  82. package/dist/esm/Prompt.js.map +1 -0
  83. package/dist/esm/Response.js +619 -0
  84. package/dist/esm/Response.js.map +1 -0
  85. package/dist/esm/Telemetry.js +166 -0
  86. package/dist/esm/Telemetry.js.map +1 -0
  87. package/dist/esm/Tokenizer.js +87 -8
  88. package/dist/esm/Tokenizer.js.map +1 -1
  89. package/dist/esm/Tool.js +534 -0
  90. package/dist/esm/Tool.js.map +1 -0
  91. package/dist/esm/Toolkit.js +269 -0
  92. package/dist/esm/Toolkit.js.map +1 -0
  93. package/dist/esm/index.js +498 -13
  94. package/dist/esm/index.js.map +1 -1
  95. package/package.json +76 -68
  96. package/src/AiError.ts +739 -9
  97. package/src/Chat.ts +546 -0
  98. package/src/EmbeddingModel.ts +311 -0
  99. package/src/IdGenerator.ts +320 -0
  100. package/src/LanguageModel.ts +1074 -0
  101. package/src/McpServer.ts +337 -194
  102. package/src/Model.ts +155 -0
  103. package/src/Prompt.ts +1616 -0
  104. package/src/Response.ts +2131 -0
  105. package/src/Telemetry.ts +655 -0
  106. package/src/Tokenizer.ts +145 -24
  107. package/src/Tool.ts +1267 -0
  108. package/src/Toolkit.ts +516 -0
  109. package/src/index.ts +499 -13
  110. package/AiChat/package.json +0 -6
  111. package/AiEmbeddingModel/package.json +0 -6
  112. package/AiInput/package.json +0 -6
  113. package/AiLanguageModel/package.json +0 -6
  114. package/AiModel/package.json +0 -6
  115. package/AiResponse/package.json +0 -6
  116. package/AiTelemetry/package.json +0 -6
  117. package/AiTool/package.json +0 -6
  118. package/AiToolkit/package.json +0 -6
  119. package/dist/cjs/AiChat.js +0 -122
  120. package/dist/cjs/AiChat.js.map +0 -1
  121. package/dist/cjs/AiEmbeddingModel.js +0 -109
  122. package/dist/cjs/AiEmbeddingModel.js.map +0 -1
  123. package/dist/cjs/AiInput.js +0 -458
  124. package/dist/cjs/AiInput.js.map +0 -1
  125. package/dist/cjs/AiLanguageModel.js +0 -351
  126. package/dist/cjs/AiLanguageModel.js.map +0 -1
  127. package/dist/cjs/AiModel.js +0 -37
  128. package/dist/cjs/AiModel.js.map +0 -1
  129. package/dist/cjs/AiResponse.js +0 -681
  130. package/dist/cjs/AiResponse.js.map +0 -1
  131. package/dist/cjs/AiTelemetry.js +0 -58
  132. package/dist/cjs/AiTelemetry.js.map +0 -1
  133. package/dist/cjs/AiTool.js +0 -150
  134. package/dist/cjs/AiTool.js.map +0 -1
  135. package/dist/cjs/AiToolkit.js +0 -157
  136. package/dist/cjs/AiToolkit.js.map +0 -1
  137. package/dist/cjs/internal/common.js +0 -21
  138. package/dist/cjs/internal/common.js.map +0 -1
  139. package/dist/dts/AiChat.d.ts +0 -101
  140. package/dist/dts/AiChat.d.ts.map +0 -1
  141. package/dist/dts/AiEmbeddingModel.d.ts +0 -65
  142. package/dist/dts/AiEmbeddingModel.d.ts.map +0 -1
  143. package/dist/dts/AiInput.d.ts +0 -590
  144. package/dist/dts/AiInput.d.ts.map +0 -1
  145. package/dist/dts/AiLanguageModel.d.ts +0 -302
  146. package/dist/dts/AiLanguageModel.d.ts.map +0 -1
  147. package/dist/dts/AiModel.d.ts +0 -25
  148. package/dist/dts/AiModel.d.ts.map +0 -1
  149. package/dist/dts/AiResponse.d.ts +0 -863
  150. package/dist/dts/AiResponse.d.ts.map +0 -1
  151. package/dist/dts/AiTelemetry.d.ts +0 -242
  152. package/dist/dts/AiTelemetry.d.ts.map +0 -1
  153. package/dist/dts/AiTool.d.ts +0 -334
  154. package/dist/dts/AiTool.d.ts.map +0 -1
  155. package/dist/dts/AiToolkit.d.ts +0 -96
  156. package/dist/dts/AiToolkit.d.ts.map +0 -1
  157. package/dist/dts/internal/common.d.ts +0 -2
  158. package/dist/dts/internal/common.d.ts.map +0 -1
  159. package/dist/esm/AiChat.js +0 -111
  160. package/dist/esm/AiChat.js.map +0 -1
  161. package/dist/esm/AiEmbeddingModel.js +0 -98
  162. package/dist/esm/AiEmbeddingModel.js.map +0 -1
  163. package/dist/esm/AiInput.js +0 -433
  164. package/dist/esm/AiInput.js.map +0 -1
  165. package/dist/esm/AiLanguageModel.js +0 -340
  166. package/dist/esm/AiLanguageModel.js.map +0 -1
  167. package/dist/esm/AiModel.js +0 -29
  168. package/dist/esm/AiModel.js.map +0 -1
  169. package/dist/esm/AiResponse.js +0 -657
  170. package/dist/esm/AiResponse.js.map +0 -1
  171. package/dist/esm/AiTelemetry.js +0 -48
  172. package/dist/esm/AiTelemetry.js.map +0 -1
  173. package/dist/esm/AiTool.js +0 -134
  174. package/dist/esm/AiTool.js.map +0 -1
  175. package/dist/esm/AiToolkit.js +0 -147
  176. package/dist/esm/AiToolkit.js.map +0 -1
  177. package/dist/esm/internal/common.js +0 -14
  178. package/dist/esm/internal/common.js.map +0 -1
  179. package/src/AiChat.ts +0 -251
  180. package/src/AiEmbeddingModel.ts +0 -169
  181. package/src/AiInput.ts +0 -602
  182. package/src/AiLanguageModel.ts +0 -685
  183. package/src/AiModel.ts +0 -53
  184. package/src/AiResponse.ts +0 -986
  185. package/src/AiTelemetry.ts +0 -333
  186. package/src/AiTool.ts +0 -579
  187. package/src/AiToolkit.ts +0 -265
  188. package/src/internal/common.ts +0 -12
@@ -0,0 +1,1519 @@
1
+ import type * as DateTime from "effect/DateTime";
2
+ import type * as Option from "effect/Option";
3
+ import * as Schema from "effect/Schema";
4
+ import type * as Tool from "./Tool.js";
5
+ import type * as Toolkit from "./Toolkit.js";
6
+ /**
7
+ * Unique identifier for Response Part instances.
8
+ *
9
+ * @since 1.0.0
10
+ * @category Type Ids
11
+ */
12
+ export declare const PartTypeId = "~effect/ai/Content/Part";
13
+ /**
14
+ * Type-level representation of the Response Part identifier.
15
+ *
16
+ * @since 1.0.0
17
+ * @category Type Ids
18
+ */
19
+ export type PartTypeId = typeof PartTypeId;
20
+ /**
21
+ * Type guard to check if a value is a Response Part.
22
+ *
23
+ * @since 1.0.0
24
+ * @category Guards
25
+ */
26
+ export declare const isPart: (u: unknown) => u is AnyPart;
27
+ /**
28
+ * Union type representing all possible response content parts.
29
+ *
30
+ * @since 1.0.0
31
+ * @category Models
32
+ */
33
+ export type AnyPart = TextPart | TextStartPart | TextDeltaPart | TextEndPart | ReasoningPart | ReasoningStartPart | ReasoningDeltaPart | ReasoningEndPart | ToolParamsStartPart | ToolParamsDeltaPart | ToolParamsEndPart | ToolCallPart<any, any> | ToolResultPart<any, any> | FilePart | DocumentSourcePart | UrlSourcePart | ResponseMetadataPart | FinishPart | ErrorPart;
34
+ /**
35
+ * Encoded representation of all possible response content parts for serialization.
36
+ *
37
+ * @since 1.0.0
38
+ * @category Models
39
+ */
40
+ export type AnyPartEncoded = TextPartEncoded | TextStartPartEncoded | TextDeltaPartEncoded | TextEndPartEncoded | ReasoningPartEncoded | ReasoningStartPartEncoded | ReasoningDeltaPartEncoded | ReasoningEndPartEncoded | ToolParamsStartPartEncoded | ToolParamsDeltaPartEncoded | ToolParamsEndPartEncoded | ToolCallPartEncoded | ToolResultPartEncoded | FilePartEncoded | DocumentSourcePartEncoded | UrlSourcePartEncoded | ResponseMetadataPartEncoded | FinishPartEncoded | ErrorPartEncoded;
41
+ /**
42
+ * Union type for all response parts with tool-specific typing.
43
+ *
44
+ * @since 1.0.0
45
+ * @category Models
46
+ */
47
+ export type AllParts<Tools extends Record<string, Tool.Any>> = TextPart | TextStartPart | TextDeltaPart | TextEndPart | ReasoningPart | ReasoningStartPart | ReasoningDeltaPart | ReasoningEndPart | ToolParamsStartPart | ToolParamsDeltaPart | ToolParamsEndPart | ToolCallParts<Tools> | ToolResultParts<Tools> | FilePart | DocumentSourcePart | UrlSourcePart | ResponseMetadataPart | FinishPart | ErrorPart;
48
+ /**
49
+ * Encoded representation of all response parts for serialization.
50
+ *
51
+ * @since 1.0.0
52
+ * @category Models
53
+ */
54
+ export type AllPartsEncoded = TextPartEncoded | TextStartPartEncoded | TextDeltaPartEncoded | TextEndPartEncoded | ReasoningPartEncoded | ReasoningStartPartEncoded | ReasoningDeltaPartEncoded | ReasoningEndPartEncoded | ToolParamsStartPartEncoded | ToolParamsDeltaPartEncoded | ToolParamsEndPartEncoded | ToolCallPartEncoded | ToolResultPartEncoded | FilePartEncoded | DocumentSourcePartEncoded | UrlSourcePartEncoded | ResponseMetadataPartEncoded | FinishPartEncoded | ErrorPartEncoded;
55
+ /**
56
+ * Creates a Schema for all response parts based on a toolkit.
57
+ *
58
+ * Generates a schema that includes all possible response parts, with tool call
59
+ * and tool result parts dynamically created based on the provided toolkit.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * import { Response, Tool, Toolkit } from "@effect/ai"
64
+ * import { Schema } from "effect"
65
+ *
66
+ * const myToolkit = Toolkit.make(
67
+ * Tool.make("GetWeather", {
68
+ * parameters: { city: Schema.String },
69
+ * success: Schema.Struct({ temperature: Schema.Number })
70
+ * })
71
+ * )
72
+ *
73
+ * const allPartsSchema = Response.AllParts(myToolkit)
74
+ * ```
75
+ *
76
+ * @since 1.0.0
77
+ * @category Schemas
78
+ */
79
+ export declare const AllParts: <T extends Toolkit.Any | Toolkit.WithHandler<any>>(toolkit: T) => Schema.Schema<AllParts<Toolkit.Tools<T>>, AllParts<Toolkit.Tools<T>>>;
80
+ /**
81
+ * A type for representing non-streaming response parts with tool-specific
82
+ * typing.
83
+ *
84
+ * @template Tools - Record of tools with their schemas
85
+ *
86
+ * @since 1.0.0
87
+ * @category Models
88
+ */
89
+ export type Part<Tools extends Record<string, Tool.Any>> = TextPart | ReasoningPart | ToolCallParts<Tools> | ToolResultParts<Tools> | FilePart | DocumentSourcePart | UrlSourcePart | ResponseMetadataPart | FinishPart;
90
+ /**
91
+ * Encoded representation of non-streaming response parts for serialization.
92
+ *
93
+ * @since 1.0.0
94
+ * @category Models
95
+ */
96
+ export type PartEncoded = TextPartEncoded | ReasoningPartEncoded | ReasoningDeltaPartEncoded | ReasoningEndPartEncoded | ToolCallPartEncoded | ToolResultPartEncoded | FilePartEncoded | DocumentSourcePartEncoded | UrlSourcePartEncoded | ResponseMetadataPartEncoded | FinishPartEncoded;
97
+ /**
98
+ * Creates a Schema for non-streaming response parts based on a toolkit.
99
+ *
100
+ * @since 1.0.0
101
+ * @category Schemas
102
+ */
103
+ export declare const Part: <T extends Toolkit.Any | Toolkit.WithHandler<any>>(toolkit: T) => Schema.Schema<Part<Toolkit.Tools<T>>, PartEncoded>;
104
+ /**
105
+ * A type for representing streaming response parts with tool-specific typing.
106
+ *
107
+ * @template Tools - Record of tools with their schemas
108
+ *
109
+ * @since 1.0.0
110
+ * @category Models
111
+ */
112
+ export type StreamPart<Tools extends Record<string, Tool.Any>> = TextStartPart | TextDeltaPart | TextEndPart | ReasoningStartPart | ReasoningDeltaPart | ReasoningEndPart | ToolParamsStartPart | ToolParamsDeltaPart | ToolParamsEndPart | ToolCallParts<Tools> | ToolResultParts<Tools> | FilePart | DocumentSourcePart | UrlSourcePart | ResponseMetadataPart | FinishPart | ErrorPart;
113
+ /**
114
+ * Encoded representation of streaming response parts for serialization.
115
+ *
116
+ * @since 1.0.0
117
+ * @category Models
118
+ */
119
+ export type StreamPartEncoded = TextStartPartEncoded | TextDeltaPartEncoded | TextEndPartEncoded | ReasoningStartPartEncoded | ReasoningDeltaPartEncoded | ReasoningEndPartEncoded | ToolParamsStartPartEncoded | ToolParamsDeltaPartEncoded | ToolParamsEndPartEncoded | ToolCallPartEncoded | ToolResultPartEncoded | FilePartEncoded | DocumentSourcePartEncoded | UrlSourcePartEncoded | ResponseMetadataPartEncoded | FinishPartEncoded | ErrorPartEncoded;
120
+ /**
121
+ * Creates a Schema for streaming response parts based on a toolkit.
122
+ *
123
+ * @since 1.0.0
124
+ * @category Schemas
125
+ */
126
+ export declare const StreamPart: <T extends Toolkit.Any | Toolkit.WithHandler<any>>(toolkit: T) => Schema.Schema<StreamPart<Toolkit.Tools<T>>, StreamPartEncoded>;
127
+ /**
128
+ * Utility type that extracts tool call parts from a set of tools.
129
+ *
130
+ * @template Tools - Record of tools with their schemas
131
+ *
132
+ * @since 1.0.0
133
+ * @category Utility Types
134
+ */
135
+ export type ToolCallParts<Tools extends Record<string, Tool.Any>> = {
136
+ [Name in keyof Tools]: Name extends string ? ToolCallPart<Name, Tool.ParametersSchema<Tools[Name]>["fields"]> : never;
137
+ }[keyof Tools];
138
+ /**
139
+ * Utility type that extracts tool result parts from a set of tools.
140
+ *
141
+ * @template Tools - Record of tools with their schemas
142
+ *
143
+ * @since 1.0.0
144
+ * @category Utility Types
145
+ */
146
+ export type ToolResultParts<Tools extends Record<string, Tool.Any>> = {
147
+ [Name in keyof Tools]: Name extends string ? ToolResultPart<Name, Tool.Success<Tools[Name]>> : never;
148
+ }[keyof Tools];
149
+ /**
150
+ * Schema for provider-specific metadata which can be attached to response parts.
151
+ *
152
+ * Provider-specific metadata is namespaced by provider and has the structure:
153
+ *
154
+ * ```
155
+ * {
156
+ * "<provider-specific-key>": {
157
+ * // Provider-specific metadata
158
+ * }
159
+ * }
160
+ * ```
161
+ *
162
+ * @since 1.0.0
163
+ * @category Schemas
164
+ */
165
+ export declare const ProviderMetadata: Schema.Record$<typeof Schema.String, Schema.UndefinedOr<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>>;
166
+ /**
167
+ * @since 1.0.0
168
+ * @category Models
169
+ */
170
+ export type ProviderMetadata = typeof ProviderMetadata.Type;
171
+ /**
172
+ * Base interface for all response content parts.
173
+ *
174
+ * Provides common structure including type identifier and optional metadata.
175
+ *
176
+ * @template Type - String literal type for the part type
177
+ *
178
+ * @since 1.0.0
179
+ * @category Models
180
+ */
181
+ export interface BasePart<Type extends string, Metadata extends ProviderMetadata> {
182
+ readonly [PartTypeId]: PartTypeId;
183
+ /**
184
+ * The type of this response part.
185
+ */
186
+ readonly type: Type;
187
+ /**
188
+ * Optional provider-specific metadata for this part.
189
+ */
190
+ readonly metadata: Metadata;
191
+ }
192
+ /**
193
+ * Base interface for encoded response content parts.
194
+ *
195
+ * @template Type - String literal type for the part type
196
+ *
197
+ * @since 1.0.0
198
+ * @category Models
199
+ */
200
+ export interface BasePartEncoded<Type extends string, Metadata extends ProviderMetadata> {
201
+ /**
202
+ * The type of this response part.
203
+ */
204
+ readonly type: Type;
205
+ /**
206
+ * Optional provider-specific metadata for this part.
207
+ */
208
+ readonly metadata?: Metadata | undefined;
209
+ }
210
+ /**
211
+ * Creates a new response content part of the specified type.
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * import { Response } from "@effect/ai"
216
+ *
217
+ * const textPart = Response.makePart("text", {
218
+ * text: "Hello, world!"
219
+ * })
220
+ *
221
+ * const toolCallPart = Response.makePart("tool-call", {
222
+ * id: "call_123",
223
+ * name: "get_weather",
224
+ * params: { city: "San Francisco" },
225
+ * providerExecuted: false
226
+ * })
227
+ * ```
228
+ *
229
+ * @since 1.0.0
230
+ * @category Constructors
231
+ */
232
+ export declare const makePart: <const Type extends AnyPart["type"]>(
233
+ /**
234
+ * The type of part to create.
235
+ */
236
+ type: Type,
237
+ /**
238
+ * Parameters specific to the part type being created.
239
+ */
240
+ params: Omit<Extract<AnyPart, {
241
+ type: Type;
242
+ }>, PartTypeId | "type" | "metadata"> & {
243
+ /**
244
+ * Optional provider-specific metadata for this part.
245
+ */
246
+ readonly metadata?: Extract<AnyPart, {
247
+ type: Type;
248
+ }>["metadata"] | undefined;
249
+ }) => Extract<AnyPart, {
250
+ type: Type;
251
+ }>;
252
+ /**
253
+ * Response part representing plain text content.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * import { Response } from "@effect/ai"
258
+ *
259
+ * const textPart: Response.TextPart = Response.makePart("text", {
260
+ * text: "The answer to your question is 42.",
261
+ * })
262
+ * ```
263
+ *
264
+ * @since 1.0.0
265
+ * @category Models
266
+ */
267
+ export interface TextPart extends BasePart<"text", TextPartMetadata> {
268
+ /**
269
+ * The text content.
270
+ */
271
+ readonly text: string;
272
+ }
273
+ /**
274
+ * Encoded representation of text parts for serialization.
275
+ *
276
+ * @since 1.0.0
277
+ * @category Models
278
+ */
279
+ export interface TextPartEncoded extends BasePartEncoded<"text", TextPartMetadata> {
280
+ /**
281
+ * The text content.
282
+ */
283
+ readonly text: string;
284
+ }
285
+ /**
286
+ * Represents provider-specific metadata that can be associated with a
287
+ * `TextPart` through module augmentation.
288
+ *
289
+ * @since 1.0.0
290
+ * @category ProviderOptions
291
+ */
292
+ export interface TextPartMetadata extends ProviderMetadata {
293
+ }
294
+ /**
295
+ * Schema for validation and encoding of text parts.
296
+ *
297
+ * @since 1.0.0
298
+ * @category Schemas
299
+ */
300
+ export declare const TextPart: Schema.Schema<TextPart, TextPartEncoded>;
301
+ /**
302
+ * Response part indicating the start of streaming text content.
303
+ *
304
+ * Marks the beginning of a text chunk with a unique identifier.
305
+ *
306
+ * @since 1.0.0
307
+ * @category Models
308
+ */
309
+ export interface TextStartPart extends BasePart<"text-start", TextStartPartMetadata> {
310
+ /**
311
+ * Unique identifier for this text chunk.
312
+ */
313
+ readonly id: string;
314
+ }
315
+ /**
316
+ * Encoded representation of text start parts for serialization.
317
+ *
318
+ * @since 1.0.0
319
+ * @category Models
320
+ */
321
+ export interface TextStartPartEncoded extends BasePartEncoded<"text-start", TextStartPartMetadata> {
322
+ /**
323
+ * Unique identifier for this text chunk.
324
+ */
325
+ readonly id: string;
326
+ }
327
+ /**
328
+ * Represents provider-specific metadata that can be associated with a
329
+ * `TextStartPart` through module augmentation.
330
+ *
331
+ * @since 1.0.0
332
+ * @category ProviderOptions
333
+ */
334
+ export interface TextStartPartMetadata extends ProviderMetadata {
335
+ }
336
+ /**
337
+ * Schema for validation and encoding of text start parts.
338
+ *
339
+ * @since 1.0.0
340
+ * @category Schemas
341
+ */
342
+ export declare const TextStartPart: Schema.Schema<TextStartPart, TextStartPartEncoded>;
343
+ /**
344
+ * Response part containing incremental text content to be added to the existing
345
+ * text chunk with the same unique identifier.
346
+ *
347
+ * @since 1.0.0
348
+ * @category Models
349
+ */
350
+ export interface TextDeltaPart extends BasePart<"text-delta", TextDeltaPartMetadata> {
351
+ /**
352
+ * Unique identifier matching the corresponding text chunk.
353
+ */
354
+ readonly id: string;
355
+ /**
356
+ * The incremental text content to add.
357
+ */
358
+ readonly delta: string;
359
+ }
360
+ /**
361
+ * Encoded representation of text delta parts for serialization.
362
+ *
363
+ * @since 1.0.0
364
+ * @category Models
365
+ */
366
+ export interface TextDeltaPartEncoded extends BasePartEncoded<"text-delta", TextDeltaPartMetadata> {
367
+ /**
368
+ * Unique identifier matching the corresponding text chunk.
369
+ */
370
+ readonly id: string;
371
+ /**
372
+ * The incremental text content to add.
373
+ */
374
+ readonly delta: string;
375
+ }
376
+ /**
377
+ * Represents provider-specific metadata that can be associated with a
378
+ * `TextDeltaPart` through module augmentation.
379
+ *
380
+ * @since 1.0.0
381
+ * @category ProviderOptions
382
+ */
383
+ export interface TextDeltaPartMetadata extends ProviderMetadata {
384
+ }
385
+ /**
386
+ * Schema for validation and encoding of text delta parts.
387
+ *
388
+ * @since 1.0.0
389
+ * @category Schemas
390
+ */
391
+ export declare const TextDeltaPart: Schema.Schema<TextDeltaPart, TextDeltaPartEncoded>;
392
+ /**
393
+ * Response part indicating the end of streaming text content.
394
+ *
395
+ * Marks the completion of a text chunk.
396
+ *
397
+ * @since 1.0.0
398
+ * @category Models
399
+ */
400
+ export interface TextEndPart extends BasePart<"text-end", TextEndPartMetadata> {
401
+ /**
402
+ * Unique identifier matching the corresponding text chunk.
403
+ */
404
+ readonly id: string;
405
+ }
406
+ /**
407
+ * Encoded representation of text end parts for serialization.
408
+ *
409
+ * @since 1.0.0
410
+ * @category Models
411
+ */
412
+ export interface TextEndPartEncoded extends BasePartEncoded<"text-end", TextEndPartMetadata> {
413
+ /**
414
+ * Unique identifier matching the corresponding text chunk.
415
+ */
416
+ readonly id: string;
417
+ }
418
+ /**
419
+ * Represents provider-specific metadata that can be associated with a
420
+ * `TextEndPart` through module augmentation.
421
+ *
422
+ * @since 1.0.0
423
+ * @category ProviderOptions
424
+ */
425
+ export interface TextEndPartMetadata extends ProviderMetadata {
426
+ }
427
+ /**
428
+ * Schema for validation and encoding of text end parts.
429
+ *
430
+ * @since 1.0.0
431
+ * @category Schemas
432
+ */
433
+ export declare const TextEndPart: Schema.Schema<TextEndPart, TextEndPartEncoded>;
434
+ /**
435
+ * Response part representing reasoning or chain-of-thought content.
436
+ *
437
+ * Contains the internal reasoning process or explanation from the large
438
+ * language model.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { Response } from "@effect/ai"
443
+ *
444
+ * const reasoningPart: Response.ReasoningPart = Response.makePart("reasoning", {
445
+ * text: "Let me think step by step: First I need to analyze the user's question...",
446
+ * })
447
+ * ```
448
+ *
449
+ * @since 1.0.0
450
+ * @category Models
451
+ */
452
+ export interface ReasoningPart extends BasePart<"reasoning", ReasoningPartMetadata> {
453
+ /**
454
+ * The reasoning or thought process text.
455
+ */
456
+ readonly text: string;
457
+ }
458
+ /**
459
+ * Encoded representation of reasoning parts for serialization.
460
+ *
461
+ * @since 1.0.0
462
+ * @category Models
463
+ */
464
+ export interface ReasoningPartEncoded extends BasePartEncoded<"reasoning", ReasoningPartMetadata> {
465
+ /**
466
+ * The reasoning or thought process text.
467
+ */
468
+ readonly text: string;
469
+ }
470
+ /**
471
+ * Represents provider-specific metadata that can be associated with a
472
+ * `ReasoningPart` through module augmentation.
473
+ *
474
+ * @since 1.0.0
475
+ * @category ProviderOptions
476
+ */
477
+ export interface ReasoningPartMetadata extends ProviderMetadata {
478
+ }
479
+ /**
480
+ * Schema for validation and encoding of reasoning parts.
481
+ *
482
+ * @since 1.0.0
483
+ * @category Schemas
484
+ */
485
+ export declare const ReasoningPart: Schema.Schema<ReasoningPart, ReasoningPartEncoded>;
486
+ /**
487
+ * Response part indicating the start of streaming reasoning content.
488
+ *
489
+ * Marks the beginning of a reasoning chunk with a unique identifier.
490
+ *
491
+ * @since 1.0.0
492
+ * @category Models
493
+ */
494
+ export interface ReasoningStartPart extends BasePart<"reasoning-start", ReasoningStartPartMetadata> {
495
+ /**
496
+ * Unique identifier for this reasoning chunk.
497
+ */
498
+ readonly id: string;
499
+ }
500
+ /**
501
+ * Encoded representation of reasoning start parts for serialization.
502
+ *
503
+ * @since 1.0.0
504
+ * @category Models
505
+ */
506
+ export interface ReasoningStartPartEncoded extends BasePartEncoded<"reasoning-start", ReasoningStartPartMetadata> {
507
+ /**
508
+ * Unique identifier for this reasoning stream.
509
+ */
510
+ readonly id: string;
511
+ }
512
+ /**
513
+ * Represents provider-specific metadata that can be associated with a
514
+ * `ReasoningStartPart` through module augmentation.
515
+ *
516
+ * @since 1.0.0
517
+ * @category ProviderOptions
518
+ */
519
+ export interface ReasoningStartPartMetadata extends ProviderMetadata {
520
+ }
521
+ /**
522
+ * Schema for validation and encoding of reasoning start parts.
523
+ *
524
+ * @since 1.0.0
525
+ * @category Schemas
526
+ */
527
+ export declare const ReasoningStartPart: Schema.Schema<ReasoningStartPart, ReasoningStartPartEncoded>;
528
+ /**
529
+ * Response part containing incremental reasoning content to be added to the
530
+ * existing chunk of reasoning text with the same unique identifier.
531
+ *
532
+ * @since 1.0.0
533
+ * @category Models
534
+ */
535
+ export interface ReasoningDeltaPart extends BasePart<"reasoning-delta", ReasoningDeltaPartMetadata> {
536
+ /**
537
+ * Unique identifier matching the corresponding reasoning chunk.
538
+ */
539
+ readonly id: string;
540
+ /**
541
+ * The incremental reasoning content to add.
542
+ */
543
+ readonly delta: string;
544
+ }
545
+ /**
546
+ * Encoded representation of reasoning delta parts for serialization.
547
+ *
548
+ * @since 1.0.0
549
+ * @category Models
550
+ */
551
+ export interface ReasoningDeltaPartEncoded extends BasePartEncoded<"reasoning-delta", ReasoningDeltaPartMetadata> {
552
+ /**
553
+ * Unique identifier matching the corresponding reasoning chunk.
554
+ */
555
+ readonly id: string;
556
+ /**
557
+ * The incremental reasoning content to add.
558
+ */
559
+ readonly delta: string;
560
+ }
561
+ /**
562
+ * Represents provider-specific metadata that can be associated with a
563
+ * `ReasoningDeltaPart` through module augmentation.
564
+ *
565
+ * @since 1.0.0
566
+ * @category ProviderOptions
567
+ */
568
+ export interface ReasoningDeltaPartMetadata extends ProviderMetadata {
569
+ }
570
+ /**
571
+ * Schema for validation and encoding of reasoning delta parts.
572
+ *
573
+ * @since 1.0.0
574
+ * @category Schemas
575
+ */
576
+ export declare const ReasoningDeltaPart: Schema.Schema<ReasoningDeltaPart, ReasoningDeltaPartEncoded>;
577
+ /**
578
+ * Response part indicating the end of streaming reasoning content.
579
+ *
580
+ * Marks the completion of a chunk of reasoning content.
581
+ *
582
+ * @since 1.0.0
583
+ * @category Models
584
+ */
585
+ export interface ReasoningEndPart extends BasePart<"reasoning-end", ReasoningEndPartMetadata> {
586
+ /**
587
+ * Unique identifier matching the corresponding reasoning chunk.
588
+ */
589
+ readonly id: string;
590
+ }
591
+ /**
592
+ * Encoded representation of reasoning end parts for serialization.
593
+ *
594
+ * @since 1.0.0
595
+ * @category Models
596
+ */
597
+ export interface ReasoningEndPartEncoded extends BasePartEncoded<"reasoning-end", ReasoningEndPartMetadata> {
598
+ /**
599
+ * Unique identifier matching the corresponding reasoning chunk.
600
+ */
601
+ readonly id: string;
602
+ }
603
+ /**
604
+ * Represents provider-specific metadata that can be associated with a
605
+ * `ReasoningEndPart` through module augmentation.
606
+ *
607
+ * @since 1.0.0
608
+ * @category ProviderOptions
609
+ */
610
+ export interface ReasoningEndPartMetadata extends ProviderMetadata {
611
+ }
612
+ /**
613
+ * Schema for validation and encoding of reasoning end parts.
614
+ *
615
+ * @since 1.0.0
616
+ * @category Schemas
617
+ */
618
+ export declare const ReasoningEndPart: Schema.Schema<ReasoningEndPart, ReasoningEndPartEncoded>;
619
+ /**
620
+ * Response part indicating the start of streaming tool parameters.
621
+ *
622
+ * Marks the beginning of tool parameter streaming with metadata about the tool
623
+ * call.
624
+ *
625
+ * @since 1.0.0
626
+ * @category Models
627
+ */
628
+ export interface ToolParamsStartPart extends BasePart<"tool-params-start", ToolParamsStartPartMetadata> {
629
+ /**
630
+ * Unique identifier for this tool parameter chunk.
631
+ */
632
+ readonly id: string;
633
+ /**
634
+ * Name of the tool being called, which corresponds to the name of the tool
635
+ * in the `Toolkit` included with the request.
636
+ */
637
+ readonly name: string;
638
+ /**
639
+ * Optional provider-specific name for the tool, which can be useful when the
640
+ * name of the tool in the `Toolkit` and the name of the tool used by the
641
+ * model are different.
642
+ *
643
+ * This is usually happens only with provider-defined tools which require a
644
+ * user-space handler.
645
+ */
646
+ readonly providerName?: string | undefined;
647
+ /**
648
+ * Whether the tool was executed by the provider (true) or framework (false).
649
+ */
650
+ readonly providerExecuted: boolean;
651
+ }
652
+ /**
653
+ * Encoded representation of tool params start parts for serialization.
654
+ *
655
+ * @since 1.0.0
656
+ * @category Models
657
+ */
658
+ export interface ToolParamsStartPartEncoded extends BasePartEncoded<"tool-params-start", ToolParamsStartPartMetadata> {
659
+ /**
660
+ * Unique identifier for this tool parameter chunk.
661
+ */
662
+ readonly id: string;
663
+ /**
664
+ * Name of the tool being called, which corresponds to the name of the tool
665
+ * in the `Toolkit` included with the request.
666
+ */
667
+ readonly name: string;
668
+ /**
669
+ * Optional provider-specific name for the tool, which can be useful when the
670
+ * name of the tool in the `Toolkit` and the name of the tool used by the
671
+ * model are different.
672
+ *
673
+ * This is usually happens only with provider-defined tools which require a
674
+ * user-space handler.
675
+ */
676
+ readonly providerName?: string | undefined;
677
+ /**
678
+ * Whether the tool was executed by the provider (true) or framework (false).
679
+ */
680
+ readonly providerExecuted?: boolean;
681
+ }
682
+ /**
683
+ * Represents provider-specific metadata that can be associated with a
684
+ * `ToolParamsStartPart` through module augmentation.
685
+ *
686
+ * @since 1.0.0
687
+ * @category ProviderOptions
688
+ */
689
+ export interface ToolParamsStartPartMetadata extends ProviderMetadata {
690
+ }
691
+ /**
692
+ * Schema for validation and encoding of tool params start parts.
693
+ *
694
+ * @since 1.0.0
695
+ * @category Schemas
696
+ */
697
+ export declare const ToolParamsStartPart: Schema.Schema<ToolParamsStartPart, ToolParamsStartPartEncoded>;
698
+ /**
699
+ * Response part containing incremental tool parameter content.
700
+ *
701
+ * Represents a chunk of tool parameters being streamed, containing the
702
+ * incremental JSON content that forms the tool parameters.
703
+ *
704
+ * @since 1.0.0
705
+ * @category Models
706
+ */
707
+ export interface ToolParamsDeltaPart extends BasePart<"tool-params-delta", ToolParamsDeltaPartMetadata> {
708
+ /**
709
+ * Unique identifier matching the corresponding tool parameter chunk.
710
+ */
711
+ readonly id: string;
712
+ /**
713
+ * The incremental parameter content (typically JSON fragment) to add.
714
+ */
715
+ readonly delta: string;
716
+ }
717
+ /**
718
+ * Encoded representation of tool params delta parts for serialization.
719
+ *
720
+ * @since 1.0.0
721
+ * @category Models
722
+ */
723
+ export interface ToolParamsDeltaPartEncoded extends BasePartEncoded<"tool-params-delta", ToolParamsDeltaPartMetadata> {
724
+ /**
725
+ * Unique identifier matching the corresponding tool parameter chunk.
726
+ */
727
+ readonly id: string;
728
+ /**
729
+ * The incremental parameter content (typically JSON fragment) to add.
730
+ */
731
+ readonly delta: string;
732
+ }
733
+ /**
734
+ * Represents provider-specific metadata that can be associated with a
735
+ * `ToolParamsDeltaPart` through module augmentation.
736
+ *
737
+ * @since 1.0.0
738
+ * @category ProviderOptions
739
+ */
740
+ export interface ToolParamsDeltaPartMetadata extends ProviderMetadata {
741
+ }
742
+ /**
743
+ * Schema for validation and encoding of tool params delta parts.
744
+ *
745
+ * @since 1.0.0
746
+ * @category Schemas
747
+ */
748
+ export declare const ToolParamsDeltaPart: Schema.Schema<ToolParamsDeltaPart, ToolParamsDeltaPartEncoded>;
749
+ /**
750
+ * Response part indicating the end of streaming tool parameters.
751
+ *
752
+ * Marks the completion of a tool parameter stream, indicating that all
753
+ * parameter data has been sent and the tool call is ready to be executed.
754
+ *
755
+ * @since 1.0.0
756
+ * @category Models
757
+ */
758
+ export interface ToolParamsEndPart extends BasePart<"tool-params-end", ToolParamsEndPartMetadata> {
759
+ /**
760
+ * Unique identifier matching the corresponding tool parameter chunk.
761
+ */
762
+ readonly id: string;
763
+ }
764
+ /**
765
+ * Encoded representation of tool params end parts for serialization.
766
+ *
767
+ * @since 1.0.0
768
+ * @category Models
769
+ */
770
+ export interface ToolParamsEndPartEncoded extends BasePartEncoded<"tool-params-end", ToolParamsEndPartMetadata> {
771
+ /**
772
+ * Unique identifier matching the corresponding tool parameter stream.
773
+ */
774
+ readonly id: string;
775
+ }
776
+ /**
777
+ * Represents provider-specific metadata that can be associated with a
778
+ * `ToolParamsEndPart` through module augmentation.
779
+ *
780
+ * @since 1.0.0
781
+ * @category ProviderOptions
782
+ */
783
+ export interface ToolParamsEndPartMetadata extends ProviderMetadata {
784
+ }
785
+ /**
786
+ * Schema for validation and encoding of tool params end parts.
787
+ *
788
+ * @since 1.0.0
789
+ * @category Schemas
790
+ */
791
+ export declare const ToolParamsEndPart: Schema.Schema<ToolParamsEndPart, ToolParamsEndPartEncoded>;
792
+ /**
793
+ * Response part representing a tool call request.
794
+ *
795
+ * @example
796
+ * ```ts
797
+ * import { Response } from "@effect/ai"
798
+ * import { Schema } from "effect"
799
+ *
800
+ * const weatherParams = Schema.Struct({
801
+ * city: Schema.String,
802
+ * units: Schema.optional(Schema.Literal("celsius", "fahrenheit"))
803
+ * })
804
+ *
805
+ * const toolCallPart: Response.ToolCallPart<
806
+ * "get_weather",
807
+ * typeof weatherParams.fields
808
+ * > = Response.makePart("tool-call", {
809
+ * id: "call_123",
810
+ * name: "get_weather",
811
+ * params: { city: "San Francisco", units: "celsius" },
812
+ * providerExecuted: false,
813
+ * })
814
+ * ```
815
+ *
816
+ * @template Name - String literal type for the tool name
817
+ * @template Params - Schema fields type for the tool parameters
818
+ *
819
+ * @since 1.0.0
820
+ * @category Models
821
+ */
822
+ export interface ToolCallPart<Name extends string, Params extends Schema.Struct.Fields> extends BasePart<"tool-call", ToolCallPartMetadata> {
823
+ /**
824
+ * Unique identifier for this tool call.
825
+ */
826
+ readonly id: string;
827
+ /**
828
+ * Name of the tool being called, which corresponds to the name of the tool
829
+ * in the `Toolkit` included with the request.
830
+ */
831
+ readonly name: Name;
832
+ /**
833
+ * Parameters to pass to the tool.
834
+ */
835
+ readonly params: Schema.Struct.Type<Params>;
836
+ /**
837
+ * Optional provider-specific name for the tool, which can be useful when the
838
+ * name of the tool in the `Toolkit` and the name of the tool used by the
839
+ * model are different.
840
+ *
841
+ * This is usually happens only with provider-defined tools which require a
842
+ * user-space handler.
843
+ */
844
+ readonly providerName?: string | undefined;
845
+ /**
846
+ * Whether the tool was executed by the provider (true) or framework (false).
847
+ */
848
+ readonly providerExecuted: boolean;
849
+ }
850
+ /**
851
+ * Encoded representation of tool call parts for serialization.
852
+ *
853
+ * @since 1.0.0
854
+ * @category Models
855
+ */
856
+ export interface ToolCallPartEncoded extends BasePartEncoded<"tool-call", ToolCallPartMetadata> {
857
+ /**
858
+ * Unique identifier for this tool call.
859
+ */
860
+ readonly id: string;
861
+ /**
862
+ * Name of the tool being called, which corresponds to the name of the tool
863
+ * in the `Toolkit` included with the request.
864
+ */
865
+ readonly name: string;
866
+ /**
867
+ * Parameters to pass to the tool.
868
+ */
869
+ readonly params: unknown;
870
+ /**
871
+ * Optional provider-specific name for the tool, which can be useful when the
872
+ * name of the tool in the `Toolkit` and the name of the tool used by the
873
+ * model are different.
874
+ *
875
+ * This is usually happens only with provider-defined tools which require a
876
+ * user-space handler.
877
+ */
878
+ readonly providerName?: string | undefined;
879
+ /**
880
+ * Whether the tool was executed by the provider (true) or framework (false).
881
+ */
882
+ readonly providerExecuted?: boolean | undefined;
883
+ }
884
+ /**
885
+ * Represents provider-specific metadata that can be associated with a
886
+ * `ToolCallPart` through module augmentation.
887
+ *
888
+ * @since 1.0.0
889
+ * @category ProviderOptions
890
+ */
891
+ export interface ToolCallPartMetadata extends ProviderMetadata {
892
+ }
893
+ /**
894
+ * Creates a Schema for tool call parts with specific tool name and parameters.
895
+ *
896
+ * @since 1.0.0
897
+ * @category Schemas
898
+ */
899
+ export declare const ToolCallPart: <const Name extends string, Params extends Schema.Struct.Fields>(
900
+ /**
901
+ * Name of the tool.
902
+ */
903
+ name: Name,
904
+ /**
905
+ * Schema for the tool parameters.
906
+ */
907
+ params: Schema.Struct<Params>) => Schema.Schema<ToolCallPart<Name, Params>, ToolCallPartEncoded>;
908
+ /**
909
+ * Response part representing the result of a tool call.
910
+ *
911
+ * @example
912
+ * ```ts
913
+ * import { Response } from "@effect/ai"
914
+ *
915
+ * interface WeatherData {
916
+ * temperature: number
917
+ * condition: string
918
+ * humidity: number
919
+ * }
920
+ *
921
+ * const toolResultPart: Response.ToolResultPart<
922
+ * "get_weather",
923
+ * WeatherData
924
+ * > = Response.makePart("tool-result", {
925
+ * id: "call_123",
926
+ * name: "get_weather",
927
+ * result: {
928
+ * temperature: 22,
929
+ * condition: "sunny",
930
+ * humidity: 65
931
+ * },
932
+ * encodedResult: {
933
+ * temperature: 22,
934
+ * condition: "sunny",
935
+ * humidity: 65
936
+ * },
937
+ * providerExecuted: false
938
+ * })
939
+ * ```
940
+ *
941
+ * @template Name - String literal type for the tool name
942
+ * @template Result - Type of the tool result
943
+ *
944
+ * @since 1.0.0
945
+ * @category Models
946
+ */
947
+ export interface ToolResultPart<Name extends string, Result> extends BasePart<"tool-result", ToolResultPartMetadata> {
948
+ /**
949
+ * Unique identifier matching the original tool call.
950
+ */
951
+ readonly id: string;
952
+ /**
953
+ * Name of the tool being called, which corresponds to the name of the tool
954
+ * in the `Toolkit` included with the request.
955
+ */
956
+ readonly name: Name;
957
+ /**
958
+ * The decoded result returned by the tool execution.
959
+ */
960
+ readonly result: Result;
961
+ /**
962
+ * The encoded result for serialization purposes.
963
+ */
964
+ readonly encodedResult: unknown;
965
+ /**
966
+ * Optional provider-specific name for the tool, which can be useful when the
967
+ * name of the tool in the `Toolkit` and the name of the tool used by the
968
+ * model are different.
969
+ *
970
+ * This is usually happens only with provider-defined tools which require a
971
+ * user-space handler.
972
+ */
973
+ readonly providerName?: string | undefined;
974
+ /**
975
+ * Whether the tool was executed by the provider (true) or framework (false).
976
+ */
977
+ readonly providerExecuted: boolean;
978
+ }
979
+ /**
980
+ * Encoded representation of tool result parts for serialization.
981
+ *
982
+ * @since 1.0.0
983
+ * @category Models
984
+ */
985
+ export interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", ToolResultPartMetadata> {
986
+ /**
987
+ * Unique identifier matching the original tool call.
988
+ */
989
+ readonly id: string;
990
+ /**
991
+ * Name of the tool being called, which corresponds to the name of the tool
992
+ * in the `Toolkit` included with the request.
993
+ */
994
+ readonly name: string;
995
+ /**
996
+ * The result returned by the tool execution.
997
+ */
998
+ readonly result: unknown;
999
+ /**
1000
+ * Optional provider-specific name for the tool, which can be useful when the
1001
+ * name of the tool in the `Toolkit` and the name of the tool used by the
1002
+ * model are different.
1003
+ *
1004
+ * This is usually happens only with provider-defined tools which require a
1005
+ * user-space handler.
1006
+ */
1007
+ readonly providerName?: string | undefined;
1008
+ /**
1009
+ * Whether the tool was executed by the provider (true) or framework (false).
1010
+ */
1011
+ readonly providerExecuted?: boolean | undefined;
1012
+ }
1013
+ /**
1014
+ * Represents provider-specific metadata that can be associated with a
1015
+ * `ToolResultPart` through module augmentation.
1016
+ *
1017
+ * @since 1.0.0
1018
+ * @category ProviderOptions
1019
+ */
1020
+ export interface ToolResultPartMetadata extends ProviderMetadata {
1021
+ }
1022
+ /**
1023
+ * Creates a Schema for tool result parts with specific tool name and result type.
1024
+ *
1025
+ * @since 1.0.0
1026
+ * @category Schemas
1027
+ */
1028
+ export declare const ToolResultPart: <const Name extends string, Result extends Schema.Schema.Any>(
1029
+ /**
1030
+ * Name of the tool.
1031
+ */
1032
+ name: Name,
1033
+ /**
1034
+ * Schema for the tool result.
1035
+ */
1036
+ result: Result) => Schema.Schema<ToolResultPart<Name, Schema.Schema.Type<Result>>, ToolResultPartEncoded>;
1037
+ /**
1038
+ * Response part representing a file attachment.
1039
+ *
1040
+ * Supports various file types including images, documents, and binary data.
1041
+ *
1042
+ * @example
1043
+ * ```ts
1044
+ * import { Response } from "@effect/ai"
1045
+ *
1046
+ * const imagePart: Response.FilePart = Response.makePart("file", {
1047
+ * mediaType: "image/jpeg",
1048
+ * data: new Uint8Array([1, 2, 3]),
1049
+ * })
1050
+ * ```
1051
+ *
1052
+ * @since 1.0.0
1053
+ * @category Models
1054
+ */
1055
+ export interface FilePart extends BasePart<"file", FilePartMetadata> {
1056
+ /**
1057
+ * MIME type of the file (e.g., "image/jpeg", "application/pdf").
1058
+ */
1059
+ readonly mediaType: string;
1060
+ /**
1061
+ * File data as a byte array.
1062
+ */
1063
+ readonly data: Uint8Array;
1064
+ }
1065
+ /**
1066
+ * Encoded representation of file parts for serialization.
1067
+ *
1068
+ * @since 1.0.0
1069
+ * @category Models
1070
+ */
1071
+ export interface FilePartEncoded extends BasePartEncoded<"file", FilePartMetadata> {
1072
+ /**
1073
+ * MIME type of the file (e.g., "image/jpeg", "application/pdf").
1074
+ */
1075
+ readonly mediaType: string;
1076
+ /**
1077
+ * File data as a base64 string.
1078
+ */
1079
+ readonly data: string;
1080
+ }
1081
+ /**
1082
+ * Represents provider-specific metadata that can be associated with a
1083
+ * `FilePart` through module augmentation.
1084
+ *
1085
+ * @since 1.0.0
1086
+ * @category ProviderOptions
1087
+ */
1088
+ export interface FilePartMetadata extends ProviderMetadata {
1089
+ }
1090
+ /**
1091
+ * Schema for validation and encoding of file parts.
1092
+ *
1093
+ * @since 1.0.0
1094
+ * @category Schemas
1095
+ */
1096
+ export declare const FilePart: Schema.Schema<FilePart, FilePartEncoded>;
1097
+ /**
1098
+ * Response part representing a document source reference.
1099
+ *
1100
+ * Used to reference documents that were used in generating the response.
1101
+ *
1102
+ * @since 1.0.0
1103
+ * @category Models
1104
+ */
1105
+ export interface DocumentSourcePart extends BasePart<"source", DocumentSourcePartMetadata> {
1106
+ /**
1107
+ * Type discriminator for document sources.
1108
+ */
1109
+ readonly sourceType: "document";
1110
+ /**
1111
+ * Unique identifier for the document.
1112
+ */
1113
+ readonly id: string;
1114
+ /**
1115
+ * MIME type of the document.
1116
+ */
1117
+ readonly mediaType: string;
1118
+ /**
1119
+ * Display title of the document.
1120
+ */
1121
+ readonly title: string;
1122
+ /**
1123
+ * Optional filename of the document.
1124
+ */
1125
+ readonly fileName?: string;
1126
+ }
1127
+ /**
1128
+ * Encoded representation of document source parts for serialization.
1129
+ *
1130
+ * @since 1.0.0
1131
+ * @category Models
1132
+ */
1133
+ export interface DocumentSourcePartEncoded extends BasePartEncoded<"source", DocumentSourcePartMetadata> {
1134
+ /**
1135
+ * Type discriminator for document sources.
1136
+ */
1137
+ readonly sourceType: "document";
1138
+ /**
1139
+ * Unique identifier for the document.
1140
+ */
1141
+ readonly id: string;
1142
+ /**
1143
+ * MIME type of the document.
1144
+ */
1145
+ readonly mediaType: string;
1146
+ /**
1147
+ * Display title of the document.
1148
+ */
1149
+ readonly title: string;
1150
+ /**
1151
+ * Optional filename of the document.
1152
+ */
1153
+ readonly fileName?: string;
1154
+ }
1155
+ /**
1156
+ * Represents provider-specific metadata that can be associated with a
1157
+ * `DocumentSourcePart` through module augmentation.
1158
+ *
1159
+ * @since 1.0.0
1160
+ * @category ProviderOptions
1161
+ */
1162
+ export interface DocumentSourcePartMetadata extends ProviderMetadata {
1163
+ }
1164
+ /**
1165
+ * Schema for validation and encoding of document source parts.
1166
+ *
1167
+ * @since 1.0.0
1168
+ * @category Schemas
1169
+ */
1170
+ export declare const DocumentSourcePart: Schema.Schema<DocumentSourcePart, DocumentSourcePartEncoded>;
1171
+ /**
1172
+ * Response part representing a URL source reference.
1173
+ *
1174
+ * Used to reference web URLs that were used in generating the response.
1175
+ *
1176
+ * @since 1.0.0
1177
+ * @category Models
1178
+ */
1179
+ export interface UrlSourcePart extends BasePart<"source", UrlSourcePartMetadata> {
1180
+ /**
1181
+ * Type discriminator for URL sources.
1182
+ */
1183
+ readonly sourceType: "url";
1184
+ /**
1185
+ * Unique identifier for the URL.
1186
+ */
1187
+ readonly id: string;
1188
+ /**
1189
+ * The URL that was referenced.
1190
+ */
1191
+ readonly url: URL;
1192
+ /**
1193
+ * Display title of the URL content.
1194
+ */
1195
+ readonly title: string;
1196
+ }
1197
+ /**
1198
+ * Encoded representation of URL source parts for serialization.
1199
+ *
1200
+ * @since 1.0.0
1201
+ * @category Models
1202
+ */
1203
+ export interface UrlSourcePartEncoded extends BasePartEncoded<"source", UrlSourcePartMetadata> {
1204
+ /**
1205
+ * Type discriminator for URL sources.
1206
+ */
1207
+ readonly sourceType: "url";
1208
+ /**
1209
+ * Unique identifier for the URL.
1210
+ */
1211
+ readonly id: string;
1212
+ /**
1213
+ * The URL that was referenced as a string.
1214
+ */
1215
+ readonly url: string;
1216
+ /**
1217
+ * Display title of the URL content.
1218
+ */
1219
+ readonly title: string;
1220
+ }
1221
+ /**
1222
+ * Represents provider-specific metadata that can be associated with a
1223
+ * `UrlSourcePart` through module augmentation.
1224
+ *
1225
+ * @since 1.0.0
1226
+ * @category ProviderOptions
1227
+ */
1228
+ export interface UrlSourcePartMetadata extends ProviderMetadata {
1229
+ }
1230
+ /**
1231
+ * Schema for validation and encoding of url source parts.
1232
+ *
1233
+ * @since 1.0.0
1234
+ * @category Schemas
1235
+ */
1236
+ export declare const UrlSourcePart: Schema.Schema<UrlSourcePart, UrlSourcePartEncoded>;
1237
+ /**
1238
+ * Response part containing metadata about the large language model response.
1239
+ *
1240
+ * @example
1241
+ * ```ts
1242
+ * import { Response } from "@effect/ai"
1243
+ * import { Option, DateTime } from "effect"
1244
+ *
1245
+ * const metadataPart: Response.ResponseMetadataPart = Response.makePart("response-metadata", {
1246
+ * id: Option.some("resp_123"),
1247
+ * modelId: Option.some("gpt-4"),
1248
+ * timestamp: Option.some(DateTime.unsafeNow())
1249
+ * })
1250
+ * ```
1251
+ *
1252
+ * @since 1.0.0
1253
+ * @category Models
1254
+ */
1255
+ export interface ResponseMetadataPart extends BasePart<"response-metadata", ResponseMetadataPartMetadata> {
1256
+ /**
1257
+ * Optional unique identifier for this specific response.
1258
+ */
1259
+ readonly id: Option.Option<string>;
1260
+ /**
1261
+ * Optional identifier of the AI model that generated the response.
1262
+ */
1263
+ readonly modelId: Option.Option<string>;
1264
+ /**
1265
+ * Optional timestamp when the response was generated.
1266
+ */
1267
+ readonly timestamp: Option.Option<DateTime.Utc>;
1268
+ }
1269
+ /**
1270
+ * Encoded representation of response metadata parts for serialization.
1271
+ *
1272
+ * @since 1.0.0
1273
+ * @category Models
1274
+ */
1275
+ export interface ResponseMetadataPartEncoded extends BasePartEncoded<"response-metadata", ResponseMetadataPartMetadata> {
1276
+ /**
1277
+ * Optional unique identifier for this specific response.
1278
+ */
1279
+ readonly id?: string | undefined;
1280
+ /**
1281
+ * Optional identifier of the AI model that generated the response.
1282
+ */
1283
+ readonly modelId?: string | undefined;
1284
+ /**
1285
+ * Optional timestamp when the response was generated.
1286
+ */
1287
+ readonly timestamp?: string | undefined;
1288
+ }
1289
+ /**
1290
+ * Represents provider-specific metadata that can be associated with a
1291
+ * `ResponseMetadataPart` through module augmentation.
1292
+ *
1293
+ * @since 1.0.0
1294
+ * @category ProviderOptions
1295
+ */
1296
+ export interface ResponseMetadataPartMetadata extends ProviderMetadata {
1297
+ }
1298
+ /**
1299
+ * Schema for validation and encoding of response metadata parts.
1300
+ *
1301
+ * @since 1.0.0
1302
+ * @category Schemas
1303
+ */
1304
+ export declare const ResponseMetadataPart: Schema.Schema<ResponseMetadataPart, ResponseMetadataPartEncoded>;
1305
+ /**
1306
+ * Represents the reason why a model finished generation of a response.
1307
+ *
1308
+ * Possible finish reasons:
1309
+ * - `"stop"`: The model generated a stop sequence.
1310
+ * - `"length"`: The model exceeded its token budget.
1311
+ * - `"content-filter"`: The model generated content which violated a content filter.
1312
+ * - `"tool-calls"`: The model triggered a tool call.
1313
+ * - `"error"`: The model encountered an error.
1314
+ * - `"pause"`: The model requested to pause execution.
1315
+ * - `"other"`: The model stopped for a reason not supported by this protocol.
1316
+ * - `"unknown"`: The model did not specify a finish reason.
1317
+ *
1318
+ * @since 1.0.0
1319
+ * @category Models
1320
+ */
1321
+ export declare const FinishReason: Schema.Literal<[
1322
+ "stop",
1323
+ "length",
1324
+ "content-filter",
1325
+ "tool-calls",
1326
+ "error",
1327
+ "pause",
1328
+ "other",
1329
+ "unknown"
1330
+ ]>;
1331
+ /**
1332
+ * @since 1.0.0
1333
+ * @category Models
1334
+ */
1335
+ export type FinishReason = typeof FinishReason.Type;
1336
+ declare const Usage_base: Schema.Class<Usage, {
1337
+ /**
1338
+ * The number of tokens sent in the request to the model.
1339
+ */
1340
+ inputTokens: Schema.UndefinedOr<typeof Schema.Number>;
1341
+ /**
1342
+ * The number of tokens that the model generated for the request.
1343
+ */
1344
+ outputTokens: Schema.UndefinedOr<typeof Schema.Number>;
1345
+ /**
1346
+ * The total of number of input tokens and output tokens as reported by the
1347
+ * large language model provider.
1348
+ *
1349
+ * **NOTE**: This value may differ from the sum of `inputTokens` and
1350
+ * `outputTokens` due to inclusion of reasoning tokens or other
1351
+ * provider-specific overhead.
1352
+ */
1353
+ totalTokens: Schema.UndefinedOr<typeof Schema.Number>;
1354
+ /**
1355
+ * The number of reasoning tokens that the model used to generate the output
1356
+ * for the request.
1357
+ */
1358
+ reasoningTokens: Schema.optional<typeof Schema.Number>;
1359
+ /**
1360
+ * The number of input tokens read from the prompt cache for the request.
1361
+ */
1362
+ cachedInputTokens: Schema.optional<typeof Schema.Number>;
1363
+ }, Schema.Struct.Encoded<{
1364
+ /**
1365
+ * The number of tokens sent in the request to the model.
1366
+ */
1367
+ inputTokens: Schema.UndefinedOr<typeof Schema.Number>;
1368
+ /**
1369
+ * The number of tokens that the model generated for the request.
1370
+ */
1371
+ outputTokens: Schema.UndefinedOr<typeof Schema.Number>;
1372
+ /**
1373
+ * The total of number of input tokens and output tokens as reported by the
1374
+ * large language model provider.
1375
+ *
1376
+ * **NOTE**: This value may differ from the sum of `inputTokens` and
1377
+ * `outputTokens` due to inclusion of reasoning tokens or other
1378
+ * provider-specific overhead.
1379
+ */
1380
+ totalTokens: Schema.UndefinedOr<typeof Schema.Number>;
1381
+ /**
1382
+ * The number of reasoning tokens that the model used to generate the output
1383
+ * for the request.
1384
+ */
1385
+ reasoningTokens: Schema.optional<typeof Schema.Number>;
1386
+ /**
1387
+ * The number of input tokens read from the prompt cache for the request.
1388
+ */
1389
+ cachedInputTokens: Schema.optional<typeof Schema.Number>;
1390
+ }>, never, {
1391
+ readonly inputTokens: number | undefined;
1392
+ } & {
1393
+ readonly outputTokens: number | undefined;
1394
+ } & {
1395
+ readonly totalTokens: number | undefined;
1396
+ } & {
1397
+ readonly reasoningTokens?: number | undefined;
1398
+ } & {
1399
+ readonly cachedInputTokens?: number | undefined;
1400
+ }, {}, {}>;
1401
+ /**
1402
+ * Represents usage information for a request to a large language model provider.
1403
+ *
1404
+ * If the model provider returns additional usage information than what is
1405
+ * specified here, you can generally find that information under the provider
1406
+ * metadata of the finish part of the response.
1407
+ *
1408
+ * @since 1.0.0
1409
+ * @category Models
1410
+ */
1411
+ export declare class Usage extends Usage_base {
1412
+ }
1413
+ /**
1414
+ * Response part indicating the completion of a response generation.
1415
+ *
1416
+ * @example
1417
+ * ```ts
1418
+ * import { Response } from "@effect/ai"
1419
+ *
1420
+ * const finishPart: Response.FinishPart = Response.makePart("finish", {
1421
+ * reason: "stop",
1422
+ * usage: {
1423
+ * inputTokens: 50,
1424
+ * outputTokens: 25,
1425
+ * totalTokens: 75
1426
+ * }
1427
+ * })
1428
+ * ```
1429
+ *
1430
+ * @since 1.0.0
1431
+ * @category Models
1432
+ */
1433
+ export interface FinishPart extends BasePart<"finish", FinishPartMetadata> {
1434
+ /**
1435
+ * The reason why the model finished generating the response.
1436
+ */
1437
+ readonly reason: FinishReason;
1438
+ /**
1439
+ * Token usage statistics for the request.
1440
+ */
1441
+ readonly usage: Usage;
1442
+ }
1443
+ /**
1444
+ * Encoded representation of finish parts for serialization.
1445
+ *
1446
+ * @since 1.0.0
1447
+ * @category Models
1448
+ */
1449
+ export interface FinishPartEncoded extends BasePartEncoded<"finish", FinishPartMetadata> {
1450
+ /**
1451
+ * The reason why the model finished generating the response.
1452
+ */
1453
+ readonly reason: typeof FinishReason.Encoded;
1454
+ /**
1455
+ * Token usage statistics for the request.
1456
+ */
1457
+ readonly usage: typeof Usage.Encoded;
1458
+ }
1459
+ /**
1460
+ * Represents provider-specific metadata that can be associated with a
1461
+ * `FinishPart` through module augmentation.
1462
+ *
1463
+ * @since 1.0.0
1464
+ * @category ProviderOptions
1465
+ */
1466
+ export interface FinishPartMetadata extends ProviderMetadata {
1467
+ }
1468
+ /**
1469
+ * Schema for validation and encoding of finish parts.
1470
+ *
1471
+ * @since 1.0.0
1472
+ * @category Schemas
1473
+ */
1474
+ export declare const FinishPart: Schema.Schema<FinishPart, FinishPartEncoded>;
1475
+ /**
1476
+ * Response part indicating that an error occurred generating the response.
1477
+ *
1478
+ * @example
1479
+ * ```ts
1480
+ * import { Response } from "@effect/ai"
1481
+ *
1482
+ * const errorPart: Response.ErrorPart = Response.makePart("error", {
1483
+ * error: new Error("boom")
1484
+ * })
1485
+ * ```
1486
+ *
1487
+ * @since 1.0.0
1488
+ * @category Models
1489
+ */
1490
+ export interface ErrorPart extends BasePart<"error", ErrorPartMetadata> {
1491
+ readonly error: unknown;
1492
+ }
1493
+ /**
1494
+ * Encoded representation of error parts for serialization.
1495
+ *
1496
+ * @since 1.0.0
1497
+ * @category Models
1498
+ */
1499
+ export interface ErrorPartEncoded extends BasePartEncoded<"error", ErrorPartMetadata> {
1500
+ readonly error: unknown;
1501
+ }
1502
+ /**
1503
+ * Represents provider-specific metadata that can be associated with a
1504
+ * `ErrorPart` through module augmentation.
1505
+ *
1506
+ * @since 1.0.0
1507
+ * @category ProviderOptions
1508
+ */
1509
+ export interface ErrorPartMetadata extends ProviderMetadata {
1510
+ }
1511
+ /**
1512
+ * Schema for validation and encoding of error parts.
1513
+ *
1514
+ * @since 1.0.0
1515
+ * @category Schemas
1516
+ */
1517
+ export declare const ErrorPart: Schema.Schema<ErrorPart, ErrorPartEncoded>;
1518
+ export {};
1519
+ //# sourceMappingURL=Response.d.ts.map