@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
@@ -1,657 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import { dual } from "effect/Function";
3
- import * as Option from "effect/Option";
4
- import * as Predicate from "effect/Predicate";
5
- import * as Schema from "effect/Schema";
6
- import { AiError } from "./AiError.js";
7
- import * as InternalCommon from "./internal/common.js";
8
- const constDisableValidation = {
9
- disableValidation: true
10
- };
11
- /**
12
- * @since 1.0.0
13
- * @category Type Ids
14
- */
15
- export const TypeId = /*#__PURE__*/Symbol.for("@effect/ai/AiResponse");
16
- /**
17
- * Represents a response received from a large language model.
18
- *
19
- * @since 1.0.0
20
- * @category Models
21
- */
22
- export class AiResponse extends /*#__PURE__*/Schema.Class("@effect/ai/AiResponse")({
23
- /**
24
- * The parts of the response.
25
- */
26
- parts: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.suspend(() => Part))
27
- }) {
28
- /**
29
- * @since 1.0.0
30
- */
31
- [TypeId] = TypeId;
32
- /**
33
- * Returns the generated text content of the response.
34
- */
35
- get text() {
36
- let text = "";
37
- let found = false;
38
- for (const part of this.parts) {
39
- if (part._tag === "TextPart") {
40
- text += found ? "\n\n" + part.text : part.text;
41
- found = true;
42
- }
43
- }
44
- return text;
45
- }
46
- /**
47
- * Returns the finish reason for the response, or `"unknown"` if the finish
48
- * reason is not known.
49
- */
50
- get finishReason() {
51
- const finishPart = this.parts.find(part => part._tag === "FinishPart");
52
- return finishPart?.reason ?? "unknown";
53
- }
54
- /**
55
- * Returns all tool calls contained within the response.
56
- */
57
- get toolCalls() {
58
- return this.parts.filter(part => part._tag === "ToolCallPart");
59
- }
60
- /**
61
- * Attempts to retrieve provider-specific response metadata.
62
- */
63
- getProviderMetadata(tag) {
64
- const finishPart = this.parts.find(part => part._tag === "FinishPart");
65
- return Option.fromNullable(finishPart?.providerMetadata[tag.key]);
66
- }
67
- }
68
- /**
69
- * @since 1.0.0
70
- * @category Models
71
- */
72
- export const FromJson = /*#__PURE__*/Schema.parseJson(AiResponse);
73
- /**
74
- * @since 1.0.0
75
- * @category Type Ids
76
- */
77
- export const StructuredResponseTypeId = /*#__PURE__*/Symbol.for("@effect/ai/AiResponse/StructuredResponse");
78
- /**
79
- * Represents a response generated by a large language model that includes
80
- * structured output.
81
- *
82
- * @since 1.0.0
83
- * @category Models
84
- */
85
- export class WithStructuredOutput extends AiResponse {
86
- /**
87
- * @since 1.0.0
88
- */
89
- [StructuredResponseTypeId] = StructuredResponseTypeId;
90
- /**
91
- * The identifier of the tool which generated the structured output.
92
- */
93
- id;
94
- /**
95
- * The name of the tool which generated the structured output.
96
- */
97
- name;
98
- /**
99
- * The structured output generated by the model.
100
- */
101
- value;
102
- constructor(props, options) {
103
- super({
104
- parts: props.parts
105
- }, options);
106
- this.id = props.id;
107
- this.name = props.name;
108
- this.value = props.value;
109
- }
110
- }
111
- /**
112
- * @since 1.0.0
113
- * @category Type Ids
114
- */
115
- export const WithToolCallResultsTypeId = /*#__PURE__*/Symbol.for("@effect/ai/AiResponse/WithToolCallResults");
116
- /**
117
- * Represents a response generated by a large language model that includes
118
- * tool call results.
119
- *
120
- * @since 1.0.0
121
- * @category Models
122
- */
123
- export class WithToolCallResults extends AiResponse {
124
- /**
125
- * @since 1.0.0
126
- */
127
- [WithToolCallResultsTypeId] = WithToolCallResultsTypeId;
128
- /**
129
- * The tool call results, represented as a mapping between the tool call
130
- * identifier and the result of the tool call handler.
131
- */
132
- results;
133
- /**
134
- * The encoded tool call results, suitable for incorporation into subsequent
135
- * requests to the large language model.
136
- */
137
- encodedResults;
138
- constructor(props, options) {
139
- super({
140
- parts: props.parts
141
- }, options);
142
- this.results = props.results;
143
- this.encodedResults = props.encodedResults;
144
- }
145
- getToolCallResult(toolName) {
146
- for (const {
147
- name,
148
- result
149
- } of this.results.values()) {
150
- if (name === toolName) {
151
- return Option.some(result);
152
- }
153
- }
154
- return Option.none();
155
- }
156
- }
157
- // =============================================================================
158
- // Part
159
- // =============================================================================
160
- /**
161
- * @since 1.0.0
162
- * @category Type Ids
163
- */
164
- export const PartTypeId = /*#__PURE__*/Symbol.for("@effect/ai/AiResponse/Part");
165
- /**
166
- * Represents a content source that was used to generate a model response.
167
- *
168
- * @since 1.0.0
169
- * @category Models
170
- */
171
- export class ContentSourceAnnotation extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/Annotation/ContentSourceAnnotation")("ContentSourceAnnotation", {
172
- /**
173
- * The identifier for the content source.
174
- */
175
- id: Schema.String,
176
- /**
177
- * The index of the content source in the list of sources provided in the
178
- * model request parameters.
179
- */
180
- index: Schema.Int,
181
- /**
182
- * The provider-specific type of the file annotation.
183
- *
184
- * For example, when using Anthropic the type may be `char_location`,
185
- * `page_location`, or `content_block_location`.
186
- */
187
- type: Schema.String,
188
- /**
189
- * The content used from the content source in the message generated by the
190
- * model.
191
- */
192
- referencedContent: Schema.String,
193
- /**
194
- * The index of the first character of the content referenced by the content
195
- * source in the message generated by the model.
196
- */
197
- startIndex: Schema.Int,
198
- /**
199
- * The index of the last character of the content referenced by the content
200
- * source in the message generated by the model.
201
- */
202
- endIndex: Schema.Int
203
- }) {}
204
- /**
205
- * Represents a file that was used to generate a model response.
206
- *
207
- * @since 1.0.0
208
- * @category Models
209
- */
210
- export class FileAnnotation extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/Annotation/FileAnnotation")("FileAnnotation", {
211
- /**
212
- * The identifier for the file.
213
- */
214
- id: Schema.String,
215
- /**
216
- * The provider-specific type of the file annotation.
217
- *
218
- * For example, when using OpenAi the type may be `file_citation` or
219
- * `file_path`.
220
- */
221
- type: Schema.String,
222
- /**
223
- * The index of the file in the list of files provided in the model request
224
- * parameters.
225
- */
226
- index: Schema.Int
227
- }) {}
228
- /**
229
- * Represents a web resource that was used to generate a model response.
230
- *
231
- * @since 1.0.0
232
- * @category Models
233
- */
234
- export class UrlAnnotation extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/Annotation/UrlAnnotation")("UrlAnnotation", {
235
- /**
236
- * The URL of the web resource.
237
- */
238
- url: Schema.String,
239
- /**
240
- * The title of the web resource.
241
- */
242
- title: Schema.String,
243
- /**
244
- * The index of the first character of the content referenced by the web
245
- * resource in the message generated by the model.
246
- */
247
- startIndex: Schema.Int,
248
- /**
249
- * The index of the last character of the content referenced by the web
250
- * resource in the message generated by the model.
251
- */
252
- endIndex: Schema.Int
253
- }) {}
254
- /**
255
- * Represents annotations that were used to support the message generated by
256
- * a model.
257
- *
258
- * @since 1.0.0
259
- * @category Models
260
- */
261
- export const Annotation = /*#__PURE__*/Schema.Union(ContentSourceAnnotation, FileAnnotation, UrlAnnotation);
262
- /**
263
- * Represents part of the text generated by the model.
264
- *
265
- * @since 1.0.0
266
- * @category Models
267
- */
268
- export class TextPart extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/TextPart")("TextPart", {
269
- /**
270
- * The text content generated by the model.
271
- */
272
- text: Schema.String,
273
- /**
274
- * The annotations used to support the text generated by the model.
275
- */
276
- annotations: /*#__PURE__*/Schema.optionalWith(/*#__PURE__*/Schema.Array(Annotation), {
277
- default: () => []
278
- })
279
- }) {
280
- /**
281
- * @since 1.0.0
282
- */
283
- [PartTypeId] = PartTypeId;
284
- }
285
- /**
286
- * Represents part of the reasoning carried out by the model to generate a
287
- * response.
288
- *
289
- * @since 1.0.0
290
- * @category Models
291
- */
292
- export class ReasoningPart extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/ReasoningPart")("ReasoningPart", {
293
- /**
294
- * The reasoning content that the model used to return the output.
295
- */
296
- reasoningText: Schema.String,
297
- /**
298
- * An optional signature which verifies that the reasoning text was generated
299
- * by the model.
300
- */
301
- signature: /*#__PURE__*/Schema.optional(Schema.String)
302
- }) {
303
- /**
304
- * @since 1.0.0
305
- */
306
- [PartTypeId] = PartTypeId;
307
- }
308
- /**
309
- * Represents part of the reasoning carried out by the model to generate a
310
- * response which needed to be encrypted by the model provider for safety
311
- * reasons.
312
- *
313
- * @since 1.0.0
314
- * @category Models
315
- */
316
- export class RedactedReasoningPart extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/RedactedReasoningPart")("RedactedReasoningPart", {
317
- /**
318
- * The content in the reasoning that was encrypted by the model provider for
319
- * safety reasons.
320
- */
321
- redactedText: Schema.String
322
- }) {
323
- /**
324
- * @since 1.0.0
325
- */
326
- [PartTypeId] = PartTypeId;
327
- }
328
- /**
329
- * Represents the identifier generated by a model when a tool call is requested.
330
- *
331
- * @since 1.0.0
332
- * @category Models
333
- */
334
- export const ToolCallId = InternalCommon.ToolCallId;
335
- /**
336
- * Represents a request by a model to call a specific tool that it has been
337
- * provided with.
338
- *
339
- * @since 1.0.0
340
- * @category Models
341
- */
342
- export class ToolCallPart extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/ToolCallPart")("ToolCallPart", {
343
- /**
344
- * The identifier generated by a model when requesting a tool call.
345
- */
346
- id: ToolCallId,
347
- /**
348
- * The name of the tool to call.
349
- */
350
- name: Schema.String,
351
- /**
352
- * The arguments to call the tool with as a JSON-serializable object that
353
- * matches the tool call input schema.
354
- */
355
- params: Schema.Unknown
356
- }) {
357
- /**
358
- * @since 1.0.0
359
- */
360
- [PartTypeId] = PartTypeId;
361
- /**
362
- * Converts a raw tool call into a `ToolCallPart` by parsing tool call
363
- * parameters as a JSON string. If your tool call parameters are already
364
- * parsed, use `ToolCallPart.fromUnknown`.
365
- *
366
- * @since 1.0.0
367
- */
368
- static fromJson({
369
- id,
370
- name,
371
- params
372
- }) {
373
- return Effect.try({
374
- try() {
375
- return new ToolCallPart({
376
- id: ToolCallId.make(id, constDisableValidation),
377
- name,
378
- params: JSON.parse(params)
379
- }, constDisableValidation);
380
- },
381
- catch: cause => new AiError({
382
- module: "AiResponse",
383
- method: "ToolCall.fromJson",
384
- description: `Failed to parse parameters from JSON:\n${params}`,
385
- cause
386
- })
387
- });
388
- }
389
- /**
390
- * Converts a raw tool call into a `ToolCallPart` assuming that the tool call
391
- * parameters have already been parsed. If your tool call parameters have not
392
- * already been parsed, use `ToolCallPart.fromJson`.
393
- *
394
- * @since 1.0.0
395
- */
396
- static fromUnknown({
397
- id,
398
- name,
399
- params
400
- }) {
401
- return new ToolCallPart({
402
- id: ToolCallId.make(id, constDisableValidation),
403
- name,
404
- params
405
- }, constDisableValidation);
406
- }
407
- }
408
- /**
409
- * Represents the initial response metadata generated by a model when responding
410
- * to a request.
411
- *
412
- * @since 1.0.0
413
- * @categor Models
414
- */
415
- export class MetadataPart extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/MetadataPart")("MetadataPart", {
416
- /**
417
- * The unique identifier for the response. Each chunk of the response should
418
- * have the same identifier.
419
- */
420
- id: /*#__PURE__*/Schema.optional(Schema.String),
421
- /**
422
- * The model that was used to generate the response.
423
- */
424
- model: Schema.String,
425
- /**
426
- * The Unix timestamp of when the model began generated the response.
427
- */
428
- timestamp: /*#__PURE__*/Schema.optional(Schema.DateFromNumber)
429
- }) {
430
- /**
431
- * @since 1.0.0
432
- */
433
- [PartTypeId] = PartTypeId;
434
- }
435
- /**
436
- * Represents the reason why a model finished generation of a response.
437
- *
438
- * Possible finish reasons:
439
- * - `"stop"`: The model generated a stop sequence.
440
- * - `"length"`: The model exceeded its token budget.
441
- * - `"content-filter"`: The model generated content which violated a content filter.
442
- * - `"tool-calls"`: The model triggered a tool call.
443
- * - `"error"`: The model encountered an error.
444
- * - `"other"`: The model stopped for a reason not supported by this protocol.
445
- * - `"unknown"`: The model did not specify a finish reason.
446
- *
447
- * @since 1.0.0
448
- * @category Models
449
- */
450
- export const FinishReason = /*#__PURE__*/Schema.Literal("stop", "length", "content-filter", "tool-calls", "error", "other", "unknown");
451
- /**
452
- * Represents information about the number of tokens used by the model to
453
- * generate a response.
454
- *
455
- * @since 1.0.0
456
- * @category Models
457
- */
458
- export class Usage extends /*#__PURE__*/Schema.Class("@effect/ai/AiResponse/Usage")({
459
- /**
460
- * The number of tokens sent in the request to the model.
461
- */
462
- inputTokens: Schema.Number,
463
- /**
464
- * The number of tokens that the model generated for the request.
465
- */
466
- outputTokens: Schema.Number,
467
- /**
468
- * The total of number of input tokens and output tokens generated by the
469
- * model.
470
- */
471
- totalTokens: Schema.Number,
472
- /**
473
- * The number of reasoning tokens that the model used to generate the output
474
- * for the request.
475
- */
476
- reasoningTokens: Schema.Number,
477
- /**
478
- * The number of input tokens read from the prompt cache for the request.
479
- */
480
- cacheReadInputTokens: Schema.Number,
481
- /**
482
- * The number of input tokens written to the prompt cache for the request.
483
- */
484
- cacheWriteInputTokens: Schema.Number
485
- }) {}
486
- /**
487
- * Represents the final part of a response generated by a large language model.
488
- *
489
- * Contains useful information such as tokens used as part of the interaction
490
- * with the model.
491
- *
492
- * @since 1.0.0
493
- * @category Models
494
- */
495
- export class FinishPart extends /*#__PURE__*/Schema.TaggedClass("@effect/ai/AiResponse/FinishPart")("FinishPart", {
496
- /**
497
- * The usage information for the response.
498
- */
499
- usage: Usage,
500
- /**
501
- * The reason the model finished generating a response.
502
- */
503
- reason: FinishReason,
504
- /**
505
- * Provider-specific metadata associated with the response.
506
- */
507
- providerMetadata: /*#__PURE__*/Schema.optionalWith(/*#__PURE__*/Schema.Record({
508
- key: Schema.String,
509
- value: /*#__PURE__*/Schema.Record({
510
- key: Schema.String,
511
- value: Schema.Unknown
512
- })
513
- }), {
514
- default: () => ({})
515
- })
516
- }) {
517
- /**
518
- * @since 1.0.0
519
- */
520
- [PartTypeId] = PartTypeId;
521
- }
522
- /**
523
- * Represents an single part of a response received from a large language model.
524
- *
525
- * @since 1.0.0
526
- * @category Models
527
- */
528
- export const Part = /*#__PURE__*/Schema.Union(TextPart, ReasoningPart, RedactedReasoningPart, ToolCallPart, MetadataPart, FinishPart);
529
- /**
530
- * @since 1.0.0
531
- * @category Guards
532
- */
533
- export const is = u => Predicate.hasProperty(u, TypeId);
534
- /**
535
- * @since 1.0.0
536
- * @category Guards
537
- */
538
- export const isPart = u => Predicate.hasProperty(u, PartTypeId);
539
- /**
540
- * @since 1.0.0
541
- * @category Guards
542
- */
543
- export const isStructured = u => Predicate.hasProperty(u, StructuredResponseTypeId);
544
- /**
545
- * @since 1.0.0
546
- * @category Guards
547
- */
548
- export const hasToolCallResults = u => Predicate.hasProperty(u, WithToolCallResultsTypeId);
549
- /**
550
- * @since 1.0.0
551
- * @category Constructors
552
- */
553
- export const empty = /*#__PURE__*/new AiResponse({
554
- parts: []
555
- }, constDisableValidation);
556
- /**
557
- * Combines two responses into a single response.
558
- *
559
- * @since 1.0.0
560
- * @category Combination
561
- */
562
- export const merge = /*#__PURE__*/dual(2, (self, other) => {
563
- const newParts = mergeParts(self, other);
564
- if (hasToolCallResults(self) && hasToolCallResults(other)) {
565
- return new WithToolCallResults({
566
- results: new Map([...self.results, ...other.results]),
567
- encodedResults: new Map([...self.encodedResults, ...other.encodedResults]),
568
- parts: newParts
569
- }, constDisableValidation);
570
- } else if (hasToolCallResults(self)) {
571
- return new WithToolCallResults({
572
- results: self.results,
573
- encodedResults: self.encodedResults,
574
- parts: newParts
575
- }, constDisableValidation);
576
- } else if (hasToolCallResults(other)) {
577
- return new WithToolCallResults({
578
- results: other.results,
579
- encodedResults: other.encodedResults,
580
- parts: newParts
581
- }, constDisableValidation);
582
- } else if (isStructured(self) && isStructured(other)) {
583
- return new WithStructuredOutput({
584
- id: self.id,
585
- name: self.name,
586
- value: other.value,
587
- parts: newParts
588
- }, constDisableValidation);
589
- } else if (isStructured(self)) {
590
- return new WithStructuredOutput({
591
- id: self.id,
592
- name: self.name,
593
- value: self.value,
594
- parts: newParts
595
- }, constDisableValidation);
596
- } else if (isStructured(other)) {
597
- return new WithStructuredOutput({
598
- id: other.id,
599
- name: other.name,
600
- value: other.value,
601
- parts: newParts
602
- }, constDisableValidation);
603
- }
604
- return new AiResponse({
605
- parts: newParts
606
- }, constDisableValidation);
607
- });
608
- const mergeParts = (self, other) => {
609
- if (other.parts.length === 0) {
610
- return self.parts;
611
- }
612
- if (self.parts.length === 0) {
613
- return other.parts;
614
- }
615
- const result = [];
616
- let accumulatedText = "";
617
- const flushText = () => {
618
- if (accumulatedText.length > 0) {
619
- result.push(new TextPart({
620
- text: accumulatedText
621
- }, constDisableValidation));
622
- accumulatedText = "";
623
- }
624
- };
625
- for (const part of self.parts) {
626
- if (part._tag === "TextPart") {
627
- accumulatedText += part.text;
628
- } else {
629
- flushText();
630
- result.push(part);
631
- }
632
- }
633
- for (const part of other.parts) {
634
- if (part._tag === "TextPart") {
635
- accumulatedText += part.text;
636
- } else {
637
- flushText();
638
- result.push(part);
639
- }
640
- }
641
- flushText();
642
- return result;
643
- };
644
- /**
645
- * Adds the specified tool calls to the provided `AiResponse`.
646
- *
647
- * **NOTE**: With this method, the tool call parameters will be parsed as a
648
- * JSON string. If your tool call parameters are already parsed, use
649
- * `AiResponse.withToolCallsUnknown`.
650
- *
651
- * @since 1.0.0
652
- * @category Combination
653
- */
654
- export const withToolCallsJson = /*#__PURE__*/dual(2, (self, toolCalls) => Effect.forEach(toolCalls, toolCall => ToolCallPart.fromJson(toolCall)).pipe(Effect.map(parts => new AiResponse({
655
- parts: [...self.parts, ...parts]
656
- }, constDisableValidation))));
657
- //# sourceMappingURL=AiResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AiResponse.js","names":["Effect","dual","Option","Predicate","Schema","AiError","InternalCommon","constDisableValidation","disableValidation","TypeId","Symbol","for","AiResponse","Class","parts","Array","suspend","Part","text","found","part","_tag","finishReason","finishPart","find","reason","toolCalls","filter","getProviderMetadata","tag","fromNullable","providerMetadata","key","FromJson","parseJson","StructuredResponseTypeId","WithStructuredOutput","id","name","value","constructor","props","options","WithToolCallResultsTypeId","WithToolCallResults","results","encodedResults","getToolCallResult","toolName","result","values","some","none","PartTypeId","ContentSourceAnnotation","TaggedClass","String","index","Int","type","referencedContent","startIndex","endIndex","FileAnnotation","UrlAnnotation","url","title","Annotation","Union","TextPart","annotations","optionalWith","default","ReasoningPart","reasoningText","signature","optional","RedactedReasoningPart","redactedText","ToolCallId","ToolCallPart","params","Unknown","fromJson","try","make","JSON","parse","catch","cause","module","method","description","fromUnknown","MetadataPart","model","timestamp","DateFromNumber","FinishReason","Literal","Usage","inputTokens","Number","outputTokens","totalTokens","reasoningTokens","cacheReadInputTokens","cacheWriteInputTokens","FinishPart","usage","Record","is","u","hasProperty","isPart","isStructured","hasToolCallResults","empty","merge","self","other","newParts","mergeParts","Map","length","accumulatedText","flushText","push","withToolCallsJson","forEach","toolCall","pipe","map"],"sources":["../../src/AiResponse.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAA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