@effect/ai 0.14.1 → 0.16.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 (134) hide show
  1. package/AiEmbeddingModel/package.json +6 -0
  2. package/AiLanguageModel/package.json +6 -0
  3. package/AiTool/package.json +6 -0
  4. package/dist/cjs/AiChat.js +65 -86
  5. package/dist/cjs/AiChat.js.map +1 -1
  6. package/dist/cjs/{Embeddings.js → AiEmbeddingModel.js} +12 -12
  7. package/dist/cjs/AiEmbeddingModel.js.map +1 -0
  8. package/dist/cjs/AiError.js +8 -1
  9. package/dist/cjs/AiError.js.map +1 -1
  10. package/dist/cjs/AiInput.js +335 -248
  11. package/dist/cjs/AiInput.js.map +1 -1
  12. package/dist/cjs/AiLanguageModel.js +311 -0
  13. package/dist/cjs/AiLanguageModel.js.map +1 -0
  14. package/dist/cjs/AiModel.js +11 -5
  15. package/dist/cjs/AiModel.js.map +1 -1
  16. package/dist/cjs/AiPlan.js +10 -3
  17. package/dist/cjs/AiPlan.js.map +1 -1
  18. package/dist/cjs/AiResponse.js +481 -165
  19. package/dist/cjs/AiResponse.js.map +1 -1
  20. package/dist/cjs/AiTelemetry.js +10 -3
  21. package/dist/cjs/AiTelemetry.js.map +1 -1
  22. package/dist/cjs/AiTool.js +93 -0
  23. package/dist/cjs/AiTool.js.map +1 -0
  24. package/dist/cjs/AiToolkit.js +121 -98
  25. package/dist/cjs/AiToolkit.js.map +1 -1
  26. package/dist/cjs/Tokenizer.js +14 -16
  27. package/dist/cjs/Tokenizer.js.map +1 -1
  28. package/dist/cjs/index.js +7 -9
  29. package/dist/cjs/internal/aiPlan.js +6 -9
  30. package/dist/cjs/internal/aiPlan.js.map +1 -1
  31. package/dist/cjs/internal/common.js +22 -0
  32. package/dist/cjs/internal/common.js.map +1 -0
  33. package/dist/dts/AiChat.d.ts +58 -44
  34. package/dist/dts/AiChat.d.ts.map +1 -1
  35. package/dist/dts/{Embeddings.d.ts → AiEmbeddingModel.d.ts} +13 -14
  36. package/dist/dts/AiEmbeddingModel.d.ts.map +1 -0
  37. package/dist/dts/AiError.d.ts +4 -3
  38. package/dist/dts/AiError.d.ts.map +1 -1
  39. package/dist/dts/AiInput.d.ts +441 -146
  40. package/dist/dts/AiInput.d.ts.map +1 -1
  41. package/dist/dts/AiLanguageModel.d.ts +263 -0
  42. package/dist/dts/AiLanguageModel.d.ts.map +1 -0
  43. package/dist/dts/AiModel.d.ts +21 -20
  44. package/dist/dts/AiModel.d.ts.map +1 -1
  45. package/dist/dts/AiPlan.d.ts +90 -26
  46. package/dist/dts/AiPlan.d.ts.map +1 -1
  47. package/dist/dts/AiResponse.d.ts +711 -100
  48. package/dist/dts/AiResponse.d.ts.map +1 -1
  49. package/dist/dts/AiTelemetry.d.ts +175 -157
  50. package/dist/dts/AiTelemetry.d.ts.map +1 -1
  51. package/dist/dts/AiTool.d.ts +288 -0
  52. package/dist/dts/AiTool.d.ts.map +1 -0
  53. package/dist/dts/AiToolkit.d.ts +50 -111
  54. package/dist/dts/AiToolkit.d.ts.map +1 -1
  55. package/dist/dts/Tokenizer.d.ts +8 -6
  56. package/dist/dts/Tokenizer.d.ts.map +1 -1
  57. package/dist/dts/index.d.ts +8 -12
  58. package/dist/dts/index.d.ts.map +1 -1
  59. package/dist/dts/internal/common.d.ts +2 -0
  60. package/dist/dts/internal/common.d.ts.map +1 -0
  61. package/dist/esm/AiChat.js +62 -83
  62. package/dist/esm/AiChat.js.map +1 -1
  63. package/dist/esm/{Embeddings.js → AiEmbeddingModel.js} +10 -10
  64. package/dist/esm/AiEmbeddingModel.js.map +1 -0
  65. package/dist/esm/AiError.js +8 -1
  66. package/dist/esm/AiError.js.map +1 -1
  67. package/dist/esm/AiInput.js +316 -238
  68. package/dist/esm/AiInput.js.map +1 -1
  69. package/dist/esm/AiLanguageModel.js +300 -0
  70. package/dist/esm/AiLanguageModel.js.map +1 -0
  71. package/dist/esm/AiModel.js +11 -5
  72. package/dist/esm/AiModel.js.map +1 -1
  73. package/dist/esm/AiPlan.js +8 -2
  74. package/dist/esm/AiPlan.js.map +1 -1
  75. package/dist/esm/AiResponse.js +467 -162
  76. package/dist/esm/AiResponse.js.map +1 -1
  77. package/dist/esm/AiTelemetry.js +8 -2
  78. package/dist/esm/AiTelemetry.js.map +1 -1
  79. package/dist/esm/AiTool.js +82 -0
  80. package/dist/esm/AiTool.js.map +1 -0
  81. package/dist/esm/AiToolkit.js +118 -96
  82. package/dist/esm/AiToolkit.js.map +1 -1
  83. package/dist/esm/Tokenizer.js +14 -16
  84. package/dist/esm/Tokenizer.js.map +1 -1
  85. package/dist/esm/index.js +8 -12
  86. package/dist/esm/index.js.map +1 -1
  87. package/dist/esm/internal/aiPlan.js +4 -7
  88. package/dist/esm/internal/aiPlan.js.map +1 -1
  89. package/dist/esm/internal/common.js +14 -0
  90. package/dist/esm/internal/common.js.map +1 -0
  91. package/package.json +28 -36
  92. package/src/AiChat.ts +182 -207
  93. package/src/{Embeddings.ts → AiEmbeddingModel.ts} +19 -18
  94. package/src/AiError.ts +8 -1
  95. package/src/AiInput.ts +434 -313
  96. package/src/AiLanguageModel.ts +569 -0
  97. package/src/AiModel.ts +47 -29
  98. package/src/AiPlan.ts +102 -30
  99. package/src/AiResponse.ts +743 -187
  100. package/src/AiTelemetry.ts +214 -197
  101. package/src/AiTool.ts +496 -0
  102. package/src/AiToolkit.ts +200 -240
  103. package/src/Tokenizer.ts +18 -22
  104. package/src/index.ts +9 -14
  105. package/src/internal/aiPlan.ts +12 -14
  106. package/src/internal/common.ts +12 -0
  107. package/AiModels/package.json +0 -6
  108. package/AiRole/package.json +0 -6
  109. package/Completions/package.json +0 -6
  110. package/Embeddings/package.json +0 -6
  111. package/dist/cjs/AiModels.js +0 -54
  112. package/dist/cjs/AiModels.js.map +0 -1
  113. package/dist/cjs/AiRole.js +0 -106
  114. package/dist/cjs/AiRole.js.map +0 -1
  115. package/dist/cjs/Completions.js +0 -256
  116. package/dist/cjs/Completions.js.map +0 -1
  117. package/dist/cjs/Embeddings.js.map +0 -1
  118. package/dist/dts/AiModels.d.ts +0 -34
  119. package/dist/dts/AiModels.d.ts.map +0 -1
  120. package/dist/dts/AiRole.d.ts +0 -111
  121. package/dist/dts/AiRole.d.ts.map +0 -1
  122. package/dist/dts/Completions.d.ts +0 -128
  123. package/dist/dts/Completions.d.ts.map +0 -1
  124. package/dist/dts/Embeddings.d.ts.map +0 -1
  125. package/dist/esm/AiModels.js +0 -44
  126. package/dist/esm/AiModels.js.map +0 -1
  127. package/dist/esm/AiRole.js +0 -93
  128. package/dist/esm/AiRole.js.map +0 -1
  129. package/dist/esm/Completions.js +0 -245
  130. package/dist/esm/Completions.js.map +0 -1
  131. package/dist/esm/Embeddings.js.map +0 -1
  132. package/src/AiModels.ts +0 -77
  133. package/src/AiRole.ts +0 -122
  134. package/src/Completions.ts +0 -434
@@ -1,288 +1,583 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as AiResponse from "./AiResponse.js";
1
3
  /**
2
4
  * @since 1.0.0
5
+ * @category Type Ids
3
6
  */
4
- import type { PlatformError } from "@effect/platform/Error";
5
- import * as FileSystem from "@effect/platform/FileSystem";
6
- import * as Path from "@effect/platform/Path";
7
- import * as Chunk from "effect/Chunk";
8
- import * as Context from "effect/Context";
9
- import * as Effect from "effect/Effect";
10
- import * as Option from "effect/Option";
11
- import * as Schema_ from "effect/Schema";
12
- import { AiResponse, WithResolved } from "./AiResponse.js";
13
- import * as AiRole from "./AiRole.js";
7
+ export declare const TypeId: unique symbol;
14
8
  /**
15
9
  * @since 1.0.0
16
- * @category parts
10
+ * @category Type Ids
17
11
  */
18
- export declare const PartTypeId: unique symbol;
12
+ export type TypeId = typeof TypeId;
13
+ declare const AiInput_base: Schema.Class<AiInput, {
14
+ messages: Schema.Array$<Schema.suspend<UserMessage | AssistantMessage | ToolMessage, {
15
+ readonly _tag: "UserMessage";
16
+ readonly parts: readonly ({
17
+ readonly _tag: "TextPart";
18
+ readonly text: string;
19
+ } | {
20
+ readonly _tag: "ImagePart";
21
+ readonly data: string;
22
+ readonly mediaType?: string | undefined;
23
+ } | {
24
+ readonly _tag: "ImageUrlPart";
25
+ readonly url: string;
26
+ } | {
27
+ readonly _tag: "FilePart";
28
+ readonly data: string;
29
+ readonly name?: string | undefined;
30
+ readonly mediaType?: string | undefined;
31
+ } | {
32
+ readonly _tag: "FileUrlPart";
33
+ readonly url: string;
34
+ })[];
35
+ readonly userName?: string | undefined;
36
+ } | {
37
+ readonly _tag: "AssistantMessage";
38
+ readonly parts: readonly ({
39
+ readonly _tag: "TextPart";
40
+ readonly text: string;
41
+ } | {
42
+ readonly _tag: "ReasoningPart";
43
+ readonly reasoningText: string;
44
+ readonly signature?: string | undefined;
45
+ } | {
46
+ readonly _tag: "RedactedReasoningPart";
47
+ readonly redactedText: string;
48
+ } | {
49
+ readonly _tag: "ToolCallPart";
50
+ readonly name: string;
51
+ readonly id: string;
52
+ readonly params: unknown;
53
+ })[];
54
+ } | {
55
+ readonly _tag: "ToolMessage";
56
+ readonly parts: readonly {
57
+ readonly _tag: "ToolCallResultPart";
58
+ readonly id: string;
59
+ readonly result: unknown;
60
+ }[];
61
+ }, never>>;
62
+ }, Schema.Struct.Encoded<{
63
+ messages: Schema.Array$<Schema.suspend<UserMessage | AssistantMessage | ToolMessage, {
64
+ readonly _tag: "UserMessage";
65
+ readonly parts: readonly ({
66
+ readonly _tag: "TextPart";
67
+ readonly text: string;
68
+ } | {
69
+ readonly _tag: "ImagePart";
70
+ readonly data: string;
71
+ readonly mediaType?: string | undefined;
72
+ } | {
73
+ readonly _tag: "ImageUrlPart";
74
+ readonly url: string;
75
+ } | {
76
+ readonly _tag: "FilePart";
77
+ readonly data: string;
78
+ readonly name?: string | undefined;
79
+ readonly mediaType?: string | undefined;
80
+ } | {
81
+ readonly _tag: "FileUrlPart";
82
+ readonly url: string;
83
+ })[];
84
+ readonly userName?: string | undefined;
85
+ } | {
86
+ readonly _tag: "AssistantMessage";
87
+ readonly parts: readonly ({
88
+ readonly _tag: "TextPart";
89
+ readonly text: string;
90
+ } | {
91
+ readonly _tag: "ReasoningPart";
92
+ readonly reasoningText: string;
93
+ readonly signature?: string | undefined;
94
+ } | {
95
+ readonly _tag: "RedactedReasoningPart";
96
+ readonly redactedText: string;
97
+ } | {
98
+ readonly _tag: "ToolCallPart";
99
+ readonly name: string;
100
+ readonly id: string;
101
+ readonly params: unknown;
102
+ })[];
103
+ } | {
104
+ readonly _tag: "ToolMessage";
105
+ readonly parts: readonly {
106
+ readonly _tag: "ToolCallResultPart";
107
+ readonly id: string;
108
+ readonly result: unknown;
109
+ }[];
110
+ }, never>>;
111
+ }>, never, {
112
+ readonly messages: readonly (UserMessage | AssistantMessage | ToolMessage)[];
113
+ }, {}, {}>;
19
114
  /**
115
+ * Represents input to a large language model.
116
+ *
20
117
  * @since 1.0.0
21
- * @category parts
118
+ * @category Models
22
119
  */
23
- export type PartTypeId = typeof PartTypeId;
24
- declare const TextPart_base: Schema_.TaggedClass<TextPart, "Text", {
25
- readonly _tag: Schema_.tag<"Text">;
120
+ export declare class AiInput extends AiInput_base {
121
+ /**
122
+ * @since 1.0.0
123
+ */
124
+ readonly [TypeId]: TypeId;
125
+ }
126
+ /**
127
+ * @since 1.0.0
128
+ * @category Models
129
+ */
130
+ export declare const FromJson: Schema.transform<Schema.SchemaClass<unknown, string, never>, typeof AiInput>;
131
+ /**
132
+ * Represents raw input types that can be converted into an `AiInput`.
133
+ *
134
+ * @since 1.0.0
135
+ * @category Models
136
+ */
137
+ export type Raw = string | Message | Iterable<Message> | AiInput | AiResponse.AiResponse | AiResponse.WithStructuredOutput<any> | AiResponse.WithToolCallResults<any>;
138
+ /**
139
+ * @since 1.0.0
140
+ * @category Type Ids
141
+ */
142
+ export declare const MessageTypeId: unique symbol;
143
+ /**
144
+ * @since 1.0.0
145
+ * @category Type Ids
146
+ */
147
+ export type MessageTypeId = typeof MessageTypeId;
148
+ declare const UserMessage_base: Schema.TaggedClass<UserMessage, "UserMessage", {
149
+ readonly _tag: Schema.tag<"UserMessage">;
26
150
  } & {
27
- content: typeof Schema_.String;
151
+ parts: Schema.Array$<Schema.suspend<TextPart | ImagePart | ImageUrlPart | FilePart | FileUrlPart, {
152
+ readonly _tag: "TextPart";
153
+ readonly text: string;
154
+ } | {
155
+ readonly _tag: "ImagePart";
156
+ readonly data: string;
157
+ readonly mediaType?: string | undefined;
158
+ } | {
159
+ readonly _tag: "ImageUrlPart";
160
+ readonly url: string;
161
+ } | {
162
+ readonly _tag: "FilePart";
163
+ readonly data: string;
164
+ readonly name?: string | undefined;
165
+ readonly mediaType?: string | undefined;
166
+ } | {
167
+ readonly _tag: "FileUrlPart";
168
+ readonly url: string;
169
+ }, never>>;
170
+ userName: Schema.optional<typeof Schema.String>;
28
171
  }>;
29
172
  /**
30
173
  * @since 1.0.0
31
- * @category parts
174
+ * @category Models
32
175
  */
33
- export declare class TextPart extends TextPart_base {
34
- /**
35
- * @since 1.0.0
36
- */
37
- readonly [PartTypeId]: PartTypeId;
176
+ export declare class UserMessage extends UserMessage_base {
38
177
  /**
39
178
  * @since 1.0.0
40
179
  */
41
- static fromContent(content: string): TextPart;
180
+ readonly [MessageTypeId]: MessageTypeId;
42
181
  }
182
+ declare const AssistantMessage_base: Schema.TaggedClass<AssistantMessage, "AssistantMessage", {
183
+ readonly _tag: Schema.tag<"AssistantMessage">;
184
+ } & {
185
+ parts: Schema.Array$<Schema.suspend<TextPart | ReasoningPart | RedactedReasoningPart | ToolCallPart, {
186
+ readonly _tag: "TextPart";
187
+ readonly text: string;
188
+ } | {
189
+ readonly _tag: "ReasoningPart";
190
+ readonly reasoningText: string;
191
+ readonly signature?: string | undefined;
192
+ } | {
193
+ readonly _tag: "RedactedReasoningPart";
194
+ readonly redactedText: string;
195
+ } | {
196
+ readonly _tag: "ToolCallPart";
197
+ readonly name: string;
198
+ readonly id: string;
199
+ readonly params: unknown;
200
+ }, never>>;
201
+ }>;
43
202
  /**
44
203
  * @since 1.0.0
45
- * @category parts
46
- */
47
- export declare const ImageQuality: Schema_.Literal<["low", "high", "auto"]>;
48
- /**
49
- * @since 1.0.0
50
- * @category parts
204
+ * @category Models
51
205
  */
52
- export type ImageQuality = typeof ImageQuality.Type;
53
- declare const ImageUrlPart_base: Schema_.TaggedClass<ImageUrlPart, "ImageUrl", {
54
- readonly _tag: Schema_.tag<"ImageUrl">;
206
+ export declare class AssistantMessage extends AssistantMessage_base {
207
+ /**
208
+ * @since 1.0.0
209
+ */
210
+ readonly [MessageTypeId]: MessageTypeId;
211
+ }
212
+ declare const ToolMessage_base: Schema.TaggedClass<ToolMessage, "ToolMessage", {
213
+ readonly _tag: Schema.tag<"ToolMessage">;
55
214
  } & {
56
- url: typeof Schema_.String;
57
- quality: Schema_.PropertySignature<":", "low" | "high" | "auto", never, ":", "low" | "high" | "auto", true, never>;
215
+ parts: Schema.Array$<Schema.suspend<ToolCallResultPart, {
216
+ readonly _tag: "ToolCallResultPart";
217
+ readonly id: string;
218
+ readonly result: unknown;
219
+ }, never>>;
58
220
  }>;
59
221
  /**
60
222
  * @since 1.0.0
61
- * @category parts
223
+ * @category Models
62
224
  */
63
- export declare class ImageUrlPart extends ImageUrlPart_base {
225
+ export declare class ToolMessage extends ToolMessage_base {
64
226
  /**
65
227
  * @since 1.0.0
66
228
  */
67
- readonly [PartTypeId]: PartTypeId;
229
+ readonly [MessageTypeId]: MessageTypeId;
68
230
  }
69
231
  /**
70
232
  * @since 1.0.0
71
- * @category base64
233
+ * @category Models
72
234
  */
73
- export interface Base64DataUrl extends Schema_.transformOrFail<typeof Schema_.String, Schema_.Struct<{
74
- data: Schema_.Schema<Uint8Array>;
75
- contentType: typeof Schema_.String;
76
- }>> {
77
- }
235
+ export declare const Message: Schema.Union<[
236
+ typeof UserMessage,
237
+ typeof AssistantMessage,
238
+ typeof ToolMessage
239
+ ]>;
240
+ /**
241
+ * @since 1.0.0
242
+ * @category Models
243
+ */
244
+ export type Message = typeof Message.Type;
78
245
  /**
79
246
  * @since 1.0.0
80
- * @category base64
247
+ * @category Type Ids
81
248
  */
82
- export declare const Base64DataUrl: Base64DataUrl;
83
- declare const ImagePart_base: Schema_.TaggedClass<ImagePart, "Image", {
84
- readonly _tag: Schema_.tag<"Image">;
249
+ export declare const PartTypeId: unique symbol;
250
+ /**
251
+ * @since 1.0.0
252
+ * @category Type Ids
253
+ */
254
+ export type PartTypeId = typeof PartTypeId;
255
+ declare const TextPart_base: Schema.TaggedClass<TextPart, "TextPart", {
256
+ readonly _tag: Schema.tag<"TextPart">;
85
257
  } & {
86
- image: Base64DataUrl;
87
- quality: Schema_.PropertySignature<":", "low" | "high" | "auto", never, ":", "low" | "high" | "auto", true, never>;
258
+ /**
259
+ * The text content.
260
+ */
261
+ text: typeof Schema.String;
88
262
  }>;
89
263
  /**
264
+ * Represents a text part of a message.
265
+ *
90
266
  * @since 1.0.0
91
- * @category parts
267
+ * @category Models
92
268
  */
93
- export declare class ImagePart extends ImagePart_base {
269
+ export declare class TextPart extends TextPart_base {
94
270
  /**
95
271
  * @since 1.0.0
96
272
  */
97
273
  readonly [PartTypeId]: PartTypeId;
274
+ }
275
+ declare const ImagePart_base: Schema.TaggedClass<ImagePart, "ImagePart", {
276
+ readonly _tag: Schema.tag<"ImagePart">;
277
+ } & {
98
278
  /**
99
- * @since 1.0.0
279
+ * The binary image data.
100
280
  */
101
- static fromPath(path: string, quality?: ImageQuality): Effect.Effect<ImagePart, PlatformError, FileSystem.FileSystem | Path.Path>;
281
+ data: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
102
282
  /**
103
- * @since 1.0.0
283
+ * The optional MIME type for the image.
104
284
  */
105
- static fromBlob(blob: Blob, quality?: ImageQuality): Effect.Effect<ImagePart>;
106
- get asBase64(): string;
107
- get asDataUri(): string;
108
- }
109
- declare const ToolCallPart_base: Schema_.TaggedClass<ToolCallPart, "ToolCall", {
110
- readonly _tag: Schema_.tag<"ToolCall">;
111
- } & {
112
- id: Schema_.brand<typeof Schema_.String, "ToolCallId">;
113
- name: typeof Schema_.String;
114
- params: typeof Schema_.Unknown;
285
+ mediaType: Schema.optional<typeof Schema.String>;
115
286
  }>;
116
287
  /**
288
+ * Represents an image part of a message with binary image data.
289
+ *
117
290
  * @since 1.0.0
118
- * @category parts
291
+ * @category Models
119
292
  */
120
- export declare class ToolCallPart extends ToolCallPart_base {
293
+ export declare class ImagePart extends ImagePart_base {
121
294
  /**
122
295
  * @since 1.0.0
123
296
  */
124
297
  readonly [PartTypeId]: PartTypeId;
125
298
  }
126
- declare const ToolCallResolvedPart_base: Schema_.TaggedClass<ToolCallResolvedPart, "ToolCallResolved", {
127
- readonly _tag: Schema_.tag<"ToolCallResolved">;
299
+ declare const ImageUrlPart_base: Schema.TaggedClass<ImageUrlPart, "ImageUrlPart", {
300
+ readonly _tag: Schema.tag<"ImageUrlPart">;
128
301
  } & {
129
- toolCallId: Schema_.brand<typeof Schema_.String, "ToolCallId">;
130
- value: typeof Schema_.Unknown;
302
+ /**
303
+ * The URL that points to the image.
304
+ */
305
+ url: typeof Schema.URL;
131
306
  }>;
132
307
  /**
308
+ * Represents an image part of a message with a URL pointing to the image.
309
+ *
133
310
  * @since 1.0.0
134
- * @category parts
311
+ * @category Models
135
312
  */
136
- export declare class ToolCallResolvedPart extends ToolCallResolvedPart_base {
313
+ export declare class ImageUrlPart extends ImageUrlPart_base {
137
314
  /**
138
315
  * @since 1.0.0
139
316
  */
140
317
  readonly [PartTypeId]: PartTypeId;
141
318
  }
319
+ declare const FilePart_base: Schema.TaggedClass<FilePart, "FilePart", {
320
+ readonly _tag: Schema.tag<"FilePart">;
321
+ } & {
322
+ /**
323
+ * The binary file data.
324
+ */
325
+ data: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
326
+ /**
327
+ * The optional name of the file.
328
+ */
329
+ name: Schema.optional<typeof Schema.String>;
330
+ /**
331
+ * The optional MIME type for the image.
332
+ */
333
+ mediaType: Schema.optional<typeof Schema.String>;
334
+ }>;
142
335
  /**
336
+ * Represents a file part of a message with binary file data.
337
+ *
143
338
  * @since 1.0.0
144
- * @category parts
339
+ * @category Models
145
340
  */
146
- export type Part = TextPart | ToolCallPart | ToolCallResolvedPart | ImagePart | ImageUrlPart;
341
+ export declare class FilePart extends FilePart_base {
342
+ /**
343
+ * @since 1.0.0
344
+ */
345
+ readonly [PartTypeId]: PartTypeId;
346
+ }
347
+ declare const FileUrlPart_base: Schema.TaggedClass<FileUrlPart, "FileUrlPart", {
348
+ readonly _tag: Schema.tag<"FileUrlPart">;
349
+ } & {
350
+ /**
351
+ * The URL that points to the file.
352
+ */
353
+ url: typeof Schema.URL;
354
+ }>;
147
355
  /**
356
+ * Represents a file part of a message with a URL pointing to the file.
357
+ *
148
358
  * @since 1.0.0
149
- * @category parts
359
+ * @category Models
150
360
  */
151
- export declare const isPart: (u: unknown) => u is Part;
361
+ export declare class FileUrlPart extends FileUrlPart_base {
362
+ /**
363
+ * @since 1.0.0
364
+ */
365
+ readonly [PartTypeId]: PartTypeId;
366
+ }
367
+ declare const ReasoningPart_base: Schema.TaggedClass<ReasoningPart, "ReasoningPart", {
368
+ readonly _tag: Schema.tag<"ReasoningPart">;
369
+ } & {
370
+ /**
371
+ * The reasoning text that the model used to return the output.
372
+ */
373
+ reasoningText: typeof Schema.String;
374
+ /**
375
+ * An optional signature which verifies that the reasoning text was generated
376
+ * by the model.
377
+ */
378
+ signature: Schema.optional<typeof Schema.String>;
379
+ }>;
152
380
  /**
381
+ * Represents a part of a message containing reasoning that the model used to
382
+ * generate its output.
383
+ *
153
384
  * @since 1.0.0
154
- * @category parts
385
+ * @category Models
155
386
  */
156
- export declare namespace Part {
387
+ export declare class ReasoningPart extends ReasoningPart_base {
157
388
  /**
158
389
  * @since 1.0.0
159
- * @category parts
160
390
  */
161
- type Schema = Schema_.Union<[
162
- typeof TextPart,
163
- typeof ToolCallPart,
164
- typeof ToolCallResolvedPart,
165
- typeof ImagePart,
166
- typeof ImageUrlPart
167
- ]>;
391
+ readonly [PartTypeId]: PartTypeId;
168
392
  }
393
+ declare const RedactedReasoningPart_base: Schema.TaggedClass<RedactedReasoningPart, "RedactedReasoningPart", {
394
+ readonly _tag: Schema.tag<"RedactedReasoningPart">;
395
+ } & {
396
+ /**
397
+ * The content in the reasoning that was encrypted by the model provider for
398
+ * safety reasons.
399
+ */
400
+ redactedText: typeof Schema.String;
401
+ }>;
169
402
  /**
403
+ * Represents a part of a message containing content in the model's reasoning
404
+ * that was encrypted by the model provider for safety reasons.
405
+ *
170
406
  * @since 1.0.0
171
- * @category parts
407
+ * @category Models
172
408
  */
173
- export declare const Part: Part.Schema;
409
+ export declare class RedactedReasoningPart extends RedactedReasoningPart_base {
410
+ /**
411
+ * @since 1.0.0
412
+ */
413
+ readonly [PartTypeId]: PartTypeId;
414
+ }
174
415
  /**
416
+ * Represents the identifier generated by a model when a tool call is requested.
417
+ *
175
418
  * @since 1.0.0
176
- * @category message
419
+ * @category Models
177
420
  */
178
- export declare const MessageTypeId: unique symbol;
421
+ export declare const ToolCallId: Schema.brand<typeof Schema.String, "@effect/ai/ToolCallId">;
179
422
  /**
180
423
  * @since 1.0.0
181
- * @category message
424
+ * @category Models
182
425
  */
183
- export type MessageTypeId = typeof MessageTypeId;
184
- declare const Message_base: Schema_.Class<Message, {
185
- role: Schema_.Union<[typeof AiRole.User, typeof AiRole.UserWithName, typeof AiRole.Model]>;
186
- parts: Schema_.Chunk<Part.Schema>;
187
- }, Schema_.Struct.Encoded<{
188
- role: Schema_.Union<[typeof AiRole.User, typeof AiRole.UserWithName, typeof AiRole.Model]>;
189
- parts: Schema_.Chunk<Part.Schema>;
190
- }>, never, {
191
- readonly role: AiRole.User | AiRole.UserWithName | AiRole.Model;
426
+ export type ToolCallId = typeof ToolCallId.Type;
427
+ declare const ToolCallPart_base: Schema.TaggedClass<ToolCallPart, "ToolCallPart", {
428
+ readonly _tag: Schema.tag<"ToolCallPart">;
192
429
  } & {
193
- readonly parts: Chunk.Chunk<TextPart | ImageUrlPart | ImagePart | ToolCallPart | ToolCallResolvedPart>;
194
- }, {}, {}>;
195
- /**
196
- * @since 1.0.0
197
- * @category message
198
- */
199
- export declare class Message extends Message_base {
200
430
  /**
201
- * @since 1.0.0
431
+ * The identifier generated by a model when requesting a tool call.
202
432
  */
203
- readonly [MessageTypeId]: MessageTypeId;
433
+ id: Schema.brand<typeof Schema.String, "@effect/ai/ToolCallId">;
204
434
  /**
205
- * @since 1.0.0
435
+ * The name of the tool to call.
206
436
  */
207
- static is(u: unknown): u is Message;
437
+ name: typeof Schema.String;
208
438
  /**
209
- * @since 1.0.0
439
+ * The arguments to call the tool with as a JSON-serializable object that
440
+ * matches the tool call input schema.
210
441
  */
211
- static fromInput(input: Message.Input, role?: AiRole.AiRole): Message;
442
+ params: typeof Schema.Unknown;
443
+ }>;
444
+ /**
445
+ * Represents a part of a message containing a tool call that the model has
446
+ * requested invocation of.
447
+ *
448
+ * @since 1.0.0
449
+ * @category Models
450
+ */
451
+ export declare class ToolCallPart extends ToolCallPart_base {
212
452
  /**
213
453
  * @since 1.0.0
214
454
  */
215
- static fromResponse(response: AiResponse): Option.Option<Message>;
455
+ readonly [PartTypeId]: PartTypeId;
456
+ constructor(props: any, options?: Schema.MakeOptions);
457
+ }
458
+ declare const ToolCallResultPart_base: Schema.TaggedClass<ToolCallResultPart, "ToolCallResultPart", {
459
+ readonly _tag: Schema.tag<"ToolCallResultPart">;
460
+ } & {
216
461
  /**
217
- * @since 1.0.0
462
+ * The identifier generated by a model when requesting a tool call.
218
463
  */
219
- static fromWithResolved<A>(response: WithResolved<A>): Message;
220
- }
464
+ id: Schema.brand<typeof Schema.String, "@effect/ai/ToolCallId">;
465
+ /**
466
+ * The result of the tool call as a JSON-serializable object.
467
+ */
468
+ result: typeof Schema.Unknown;
469
+ }>;
221
470
  /**
471
+ * Represents a part of a message containing the results of tool calls that the
472
+ * model requested invocation of.
473
+ *
222
474
  * @since 1.0.0
223
- * @category message
475
+ * @category Models
224
476
  */
225
- export declare namespace Message {
477
+ export declare class ToolCallResultPart extends ToolCallResultPart_base {
226
478
  /**
227
479
  * @since 1.0.0
228
- * @category message
229
480
  */
230
- type Input = string | Part | Iterable<Part>;
481
+ readonly [PartTypeId]: PartTypeId;
231
482
  }
232
483
  /**
484
+ * The valid parts of a user message.
485
+ *
233
486
  * @since 1.0.0
234
- * @category constructors
487
+ * @category Models
235
488
  */
236
- export declare const make: (input: Input, options?: {
237
- readonly role?: AiRole.AiRole;
238
- }) => AiInput;
489
+ export declare const UserMessagePart: Schema.Union<[
490
+ typeof TextPart,
491
+ typeof ImagePart,
492
+ typeof ImageUrlPart,
493
+ typeof FilePart,
494
+ typeof FileUrlPart
495
+ ]>;
239
496
  /**
240
497
  * @since 1.0.0
241
- * @category constructors
498
+ * @category Models
242
499
  */
243
- export declare const empty: AiInput;
500
+ export type UserMessagePart = typeof UserMessagePart.Type;
244
501
  /**
502
+ * The valid parts of an assistant message.
503
+ *
245
504
  * @since 1.0.0
246
- * @category schemas
505
+ * @category Models
247
506
  */
248
- export declare const Schema: Schema_.Chunk<typeof Message>;
507
+ export declare const AssistantMessagePart: Schema.Union<[
508
+ typeof TextPart,
509
+ typeof ReasoningPart,
510
+ typeof RedactedReasoningPart,
511
+ typeof ToolCallPart
512
+ ]>;
249
513
  /**
250
514
  * @since 1.0.0
251
- * @category schemas
515
+ * @category Models
252
516
  */
253
- export declare const SchemaJson: Schema_.Schema<Chunk.Chunk<Message>, string>;
517
+ export type AssistantMessagePart = typeof AssistantMessagePart.Type;
254
518
  /**
519
+ * The valid parts of a tool message.
520
+ *
255
521
  * @since 1.0.0
256
- * @category models
522
+ * @category Models
257
523
  */
258
- export type Input = string | Part | Iterable<Part> | Message | Iterable<Message> | AiResponse | WithResolved<unknown>;
524
+ export declare const ToolMessagePart: typeof ToolCallResultPart;
259
525
  /**
260
526
  * @since 1.0.0
261
- * @category models
527
+ * @category Models
262
528
  */
263
- export type AiInput = Chunk.Chunk<Message>;
264
- declare const SystemInstruction_base: Context.TagClass<SystemInstruction, "@effect/ai/AiInput/SystemInstruction", string>;
529
+ export type ToolMessagePart = typeof ToolMessagePart.Type;
265
530
  /**
266
531
  * @since 1.0.0
267
- * @category system
532
+ * @category Guards
268
533
  */
269
- export declare class SystemInstruction extends SystemInstruction_base {
270
- }
534
+ export declare const is: (u: unknown) => u is AiInput;
535
+ /**
536
+ * @since 1.0.0
537
+ * @category Guards
538
+ */
539
+ export declare const isMessage: (u: unknown) => u is Message;
540
+ /**
541
+ * @since 1.0.0
542
+ * @category Guards
543
+ */
544
+ export declare const isPart: (u: unknown) => u is UserMessagePart | AssistantMessagePart | ToolMessagePart;
545
+ /**
546
+ * @since 1.0.0
547
+ * @category Constructors
548
+ */
549
+ export declare const empty: AiInput;
550
+ /**
551
+ * Constructs a new `AiInput` from raw user input.
552
+ *
553
+ * @since 1.0.0
554
+ * @category Constructors
555
+ */
556
+ export declare const make: (input: Raw) => AiInput;
271
557
  /**
558
+ * Concatenates the messages of one `AiInput` onto the messages of another,
559
+ * creating a new `AiInput` with the messages from both.
560
+ *
272
561
  * @since 1.0.0
273
- * @category system
562
+ * @category Combination
274
563
  */
275
- export declare const provideSystem: {
564
+ export declare const concat: {
276
565
  /**
566
+ * Concatenates the messages of one `AiInput` onto the messages of another,
567
+ * creating a new `AiInput` with the messages from both.
568
+ *
277
569
  * @since 1.0.0
278
- * @category system
570
+ * @category Combination
279
571
  */
280
- (input: string): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, SystemInstruction>>;
572
+ (other: AiInput): (self: AiInput) => AiInput;
281
573
  /**
574
+ * Concatenates the messages of one `AiInput` onto the messages of another,
575
+ * creating a new `AiInput` with the messages from both.
576
+ *
282
577
  * @since 1.0.0
283
- * @category system
578
+ * @category Combination
284
579
  */
285
- <A, E, R>(effect: Effect.Effect<A, E, R>, input: string): Effect.Effect<A, E, Exclude<R, SystemInstruction>>;
580
+ (self: AiInput, other: AiInput): AiInput;
286
581
  };
287
582
  export {};
288
583
  //# sourceMappingURL=AiInput.d.ts.map