@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.
- package/Chat/package.json +6 -0
- package/EmbeddingModel/package.json +6 -0
- package/IdGenerator/package.json +6 -0
- package/LanguageModel/package.json +6 -0
- package/Model/package.json +6 -0
- package/Prompt/package.json +6 -0
- package/Response/package.json +6 -0
- package/Telemetry/package.json +6 -0
- package/Tool/package.json +6 -0
- package/Toolkit/package.json +6 -0
- package/dist/cjs/AiError.js +575 -11
- package/dist/cjs/AiError.js.map +1 -1
- package/dist/cjs/Chat.js +302 -0
- package/dist/cjs/Chat.js.map +1 -0
- package/dist/cjs/EmbeddingModel.js +184 -0
- package/dist/cjs/EmbeddingModel.js.map +1 -0
- package/dist/cjs/IdGenerator.js +255 -0
- package/dist/cjs/IdGenerator.js.map +1 -0
- package/dist/cjs/LanguageModel.js +584 -0
- package/dist/cjs/LanguageModel.js.map +1 -0
- package/dist/cjs/McpServer.js +12 -4
- package/dist/cjs/McpServer.js.map +1 -1
- package/dist/cjs/Model.js +118 -0
- package/dist/cjs/Model.js.map +1 -0
- package/dist/cjs/Prompt.js +649 -0
- package/dist/cjs/Prompt.js.map +1 -0
- package/dist/cjs/Response.js +635 -0
- package/dist/cjs/Response.js.map +1 -0
- package/dist/cjs/Telemetry.js +176 -0
- package/dist/cjs/Telemetry.js.map +1 -0
- package/dist/cjs/Tokenizer.js +87 -8
- package/dist/cjs/Tokenizer.js.map +1 -1
- package/dist/cjs/Tool.js +556 -0
- package/dist/cjs/Tool.js.map +1 -0
- package/dist/cjs/Toolkit.js +279 -0
- package/dist/cjs/Toolkit.js.map +1 -0
- package/dist/cjs/index.js +21 -19
- package/dist/dts/AiError.d.ts +577 -9
- package/dist/dts/AiError.d.ts.map +1 -1
- package/dist/dts/Chat.d.ts +356 -0
- package/dist/dts/Chat.d.ts.map +1 -0
- package/dist/dts/EmbeddingModel.d.ts +153 -0
- package/dist/dts/EmbeddingModel.d.ts.map +1 -0
- package/dist/dts/IdGenerator.d.ts +272 -0
- package/dist/dts/IdGenerator.d.ts.map +1 -0
- package/dist/dts/LanguageModel.d.ts +458 -0
- package/dist/dts/LanguageModel.d.ts.map +1 -0
- package/dist/dts/McpSchema.d.ts +25 -25
- package/dist/dts/McpServer.d.ts +6 -4
- package/dist/dts/McpServer.d.ts.map +1 -1
- package/dist/dts/Model.d.ts +124 -0
- package/dist/dts/Model.d.ts.map +1 -0
- package/dist/dts/Prompt.d.ts +1119 -0
- package/dist/dts/Prompt.d.ts.map +1 -0
- package/dist/dts/Response.d.ts +1519 -0
- package/dist/dts/Response.d.ts.map +1 -0
- package/dist/dts/Telemetry.d.ts +520 -0
- package/dist/dts/Telemetry.d.ts.map +1 -0
- package/dist/dts/Tokenizer.d.ts +131 -13
- package/dist/dts/Tokenizer.d.ts.map +1 -1
- package/dist/dts/Tool.d.ts +876 -0
- package/dist/dts/Tool.d.ts.map +1 -0
- package/dist/dts/Toolkit.d.ts +310 -0
- package/dist/dts/Toolkit.d.ts.map +1 -0
- package/dist/dts/index.d.ts +498 -13
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/esm/AiError.js +570 -10
- package/dist/esm/AiError.js.map +1 -1
- package/dist/esm/Chat.js +291 -0
- package/dist/esm/Chat.js.map +1 -0
- package/dist/esm/EmbeddingModel.js +173 -0
- package/dist/esm/EmbeddingModel.js.map +1 -0
- package/dist/esm/IdGenerator.js +245 -0
- package/dist/esm/IdGenerator.js.map +1 -0
- package/dist/esm/LanguageModel.js +572 -0
- package/dist/esm/LanguageModel.js.map +1 -0
- package/dist/esm/McpServer.js +12 -4
- package/dist/esm/McpServer.js.map +1 -1
- package/dist/esm/Model.js +108 -0
- package/dist/esm/Model.js.map +1 -0
- package/dist/esm/Prompt.js +633 -0
- package/dist/esm/Prompt.js.map +1 -0
- package/dist/esm/Response.js +619 -0
- package/dist/esm/Response.js.map +1 -0
- package/dist/esm/Telemetry.js +166 -0
- package/dist/esm/Telemetry.js.map +1 -0
- package/dist/esm/Tokenizer.js +87 -8
- package/dist/esm/Tokenizer.js.map +1 -1
- package/dist/esm/Tool.js +534 -0
- package/dist/esm/Tool.js.map +1 -0
- package/dist/esm/Toolkit.js +269 -0
- package/dist/esm/Toolkit.js.map +1 -0
- package/dist/esm/index.js +498 -13
- package/dist/esm/index.js.map +1 -1
- package/package.json +76 -68
- package/src/AiError.ts +739 -9
- package/src/Chat.ts +546 -0
- package/src/EmbeddingModel.ts +311 -0
- package/src/IdGenerator.ts +320 -0
- package/src/LanguageModel.ts +1074 -0
- package/src/McpServer.ts +337 -194
- package/src/Model.ts +155 -0
- package/src/Prompt.ts +1616 -0
- package/src/Response.ts +2131 -0
- package/src/Telemetry.ts +655 -0
- package/src/Tokenizer.ts +145 -24
- package/src/Tool.ts +1267 -0
- package/src/Toolkit.ts +516 -0
- package/src/index.ts +499 -13
- package/AiChat/package.json +0 -6
- package/AiEmbeddingModel/package.json +0 -6
- package/AiInput/package.json +0 -6
- package/AiLanguageModel/package.json +0 -6
- package/AiModel/package.json +0 -6
- package/AiResponse/package.json +0 -6
- package/AiTelemetry/package.json +0 -6
- package/AiTool/package.json +0 -6
- package/AiToolkit/package.json +0 -6
- package/dist/cjs/AiChat.js +0 -122
- package/dist/cjs/AiChat.js.map +0 -1
- package/dist/cjs/AiEmbeddingModel.js +0 -109
- package/dist/cjs/AiEmbeddingModel.js.map +0 -1
- package/dist/cjs/AiInput.js +0 -458
- package/dist/cjs/AiInput.js.map +0 -1
- package/dist/cjs/AiLanguageModel.js +0 -351
- package/dist/cjs/AiLanguageModel.js.map +0 -1
- package/dist/cjs/AiModel.js +0 -37
- package/dist/cjs/AiModel.js.map +0 -1
- package/dist/cjs/AiResponse.js +0 -681
- package/dist/cjs/AiResponse.js.map +0 -1
- package/dist/cjs/AiTelemetry.js +0 -58
- package/dist/cjs/AiTelemetry.js.map +0 -1
- package/dist/cjs/AiTool.js +0 -150
- package/dist/cjs/AiTool.js.map +0 -1
- package/dist/cjs/AiToolkit.js +0 -157
- package/dist/cjs/AiToolkit.js.map +0 -1
- package/dist/cjs/internal/common.js +0 -21
- package/dist/cjs/internal/common.js.map +0 -1
- package/dist/dts/AiChat.d.ts +0 -101
- package/dist/dts/AiChat.d.ts.map +0 -1
- package/dist/dts/AiEmbeddingModel.d.ts +0 -65
- package/dist/dts/AiEmbeddingModel.d.ts.map +0 -1
- package/dist/dts/AiInput.d.ts +0 -590
- package/dist/dts/AiInput.d.ts.map +0 -1
- package/dist/dts/AiLanguageModel.d.ts +0 -302
- package/dist/dts/AiLanguageModel.d.ts.map +0 -1
- package/dist/dts/AiModel.d.ts +0 -25
- package/dist/dts/AiModel.d.ts.map +0 -1
- package/dist/dts/AiResponse.d.ts +0 -863
- package/dist/dts/AiResponse.d.ts.map +0 -1
- package/dist/dts/AiTelemetry.d.ts +0 -242
- package/dist/dts/AiTelemetry.d.ts.map +0 -1
- package/dist/dts/AiTool.d.ts +0 -334
- package/dist/dts/AiTool.d.ts.map +0 -1
- package/dist/dts/AiToolkit.d.ts +0 -96
- package/dist/dts/AiToolkit.d.ts.map +0 -1
- package/dist/dts/internal/common.d.ts +0 -2
- package/dist/dts/internal/common.d.ts.map +0 -1
- package/dist/esm/AiChat.js +0 -111
- package/dist/esm/AiChat.js.map +0 -1
- package/dist/esm/AiEmbeddingModel.js +0 -98
- package/dist/esm/AiEmbeddingModel.js.map +0 -1
- package/dist/esm/AiInput.js +0 -433
- package/dist/esm/AiInput.js.map +0 -1
- package/dist/esm/AiLanguageModel.js +0 -340
- package/dist/esm/AiLanguageModel.js.map +0 -1
- package/dist/esm/AiModel.js +0 -29
- package/dist/esm/AiModel.js.map +0 -1
- package/dist/esm/AiResponse.js +0 -657
- package/dist/esm/AiResponse.js.map +0 -1
- package/dist/esm/AiTelemetry.js +0 -48
- package/dist/esm/AiTelemetry.js.map +0 -1
- package/dist/esm/AiTool.js +0 -134
- package/dist/esm/AiTool.js.map +0 -1
- package/dist/esm/AiToolkit.js +0 -147
- package/dist/esm/AiToolkit.js.map +0 -1
- package/dist/esm/internal/common.js +0 -14
- package/dist/esm/internal/common.js.map +0 -1
- package/src/AiChat.ts +0 -251
- package/src/AiEmbeddingModel.ts +0 -169
- package/src/AiInput.ts +0 -602
- package/src/AiLanguageModel.ts +0 -685
- package/src/AiModel.ts +0 -53
- package/src/AiResponse.ts +0 -986
- package/src/AiTelemetry.ts +0 -333
- package/src/AiTool.ts +0 -579
- package/src/AiToolkit.ts +0 -265
- package/src/internal/common.ts +0 -12
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 1.0.0
|
|
3
|
-
*/
|
|
4
|
-
import * as _Context from "effect/Context";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as JsonSchema from "effect/JSONSchema";
|
|
7
|
-
import * as Option from "effect/Option";
|
|
8
|
-
import * as Schema from "effect/Schema";
|
|
9
|
-
import * as Stream from "effect/Stream";
|
|
10
|
-
import type { Span } from "effect/Tracer";
|
|
11
|
-
import type { Concurrency, NoExcessProperties } from "effect/Types";
|
|
12
|
-
import { AiError } from "./AiError.js";
|
|
13
|
-
import * as AiInput from "./AiInput.js";
|
|
14
|
-
import * as AiResponse from "./AiResponse.js";
|
|
15
|
-
import type * as AiTool from "./AiTool.js";
|
|
16
|
-
import type * as AiToolkit from "./AiToolkit.js";
|
|
17
|
-
declare const AiLanguageModel_base: _Context.TagClass<AiLanguageModel, "@effect/ai/AiLanguageModel", AiLanguageModel.Service>;
|
|
18
|
-
/**
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
* @category Context
|
|
21
|
-
*/
|
|
22
|
-
export declare class AiLanguageModel extends AiLanguageModel_base {
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @since 1.0.0
|
|
26
|
-
* @category Models
|
|
27
|
-
*/
|
|
28
|
-
export type StructuredSchema<A, I extends Record<string, unknown>, R> = TaggedSchema<A, I, R> | IdentifiedSchema<A, I, R>;
|
|
29
|
-
/**
|
|
30
|
-
* @since 1.0.0
|
|
31
|
-
* @category Models
|
|
32
|
-
*/
|
|
33
|
-
export interface TaggedSchema<A, I, R> extends Schema.Schema<A, I, R> {
|
|
34
|
-
readonly _tag: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @since 1.0.0
|
|
38
|
-
* @category Models
|
|
39
|
-
*/
|
|
40
|
-
export interface IdentifiedSchema<A, I, R> extends Schema.Schema<A, I, R> {
|
|
41
|
-
readonly identifier: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The tool choice mode for the language model.
|
|
45
|
-
*
|
|
46
|
-
* - `auto` (default): The model can decide whether or not to call tools, as well as which tools to call.
|
|
47
|
-
* - `required`: The model **must** call a tool but can decide which tool will be called.
|
|
48
|
-
* - `none`: The model **must not** call a tool.
|
|
49
|
-
* - `{ tool: <tool_name> }`: The model must call the specified tool.
|
|
50
|
-
*
|
|
51
|
-
* @since 1.0.0
|
|
52
|
-
* @category Models
|
|
53
|
-
*/
|
|
54
|
-
export type ToolChoice<Tool extends AiTool.Any> = "auto" | "none" | "required" | {
|
|
55
|
-
readonly tool: Tool["name"];
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* @since 1.0.0
|
|
59
|
-
* @category Models
|
|
60
|
-
*/
|
|
61
|
-
export interface ToolCallIdGenerator {
|
|
62
|
-
generateId(): Effect.Effect<string>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The default services available for use when constructing an `AiLanguageModel`.
|
|
66
|
-
*
|
|
67
|
-
* @since 1.0.0
|
|
68
|
-
* @category Context
|
|
69
|
-
*/
|
|
70
|
-
export type Context = CurrentToolCallIdGenerator;
|
|
71
|
-
declare const CurrentToolCallIdGenerator_base: _Context.TagClass<CurrentToolCallIdGenerator, "@effect/ai/CurrentToolCallIdGenerator", ToolCallIdGenerator>;
|
|
72
|
-
/**
|
|
73
|
-
* @since 1.0.0
|
|
74
|
-
* @category Context
|
|
75
|
-
*/
|
|
76
|
-
export declare class CurrentToolCallIdGenerator extends CurrentToolCallIdGenerator_base {
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Options for generating text using a large language model.
|
|
80
|
-
*
|
|
81
|
-
* @since 1.0.0
|
|
82
|
-
* @category Models
|
|
83
|
-
*/
|
|
84
|
-
export interface GenerateTextOptions<Tools extends AiTool.Any> {
|
|
85
|
-
/**
|
|
86
|
-
* The prompt input to use to generate text.
|
|
87
|
-
*/
|
|
88
|
-
readonly prompt: AiInput.Raw;
|
|
89
|
-
/**
|
|
90
|
-
* An optional system message that will be part of the prompt.
|
|
91
|
-
*/
|
|
92
|
-
readonly system?: string | undefined;
|
|
93
|
-
/**
|
|
94
|
-
* A toolkit containing both the tools and the tool call handler to use to
|
|
95
|
-
* augment text generation.
|
|
96
|
-
*/
|
|
97
|
-
readonly toolkit?: AiToolkit.ToHandler<Tools> | Effect.Effect<AiToolkit.ToHandler<Tools>, any, any>;
|
|
98
|
-
/**
|
|
99
|
-
* The tool choice mode for the language model.
|
|
100
|
-
*
|
|
101
|
-
* - `auto` (default): The model can decide whether or not to call tools, as well as which tools to call.
|
|
102
|
-
* - `required`: The model **must** call a tool but can decide which tool will be called.
|
|
103
|
-
* - `none`: The model **must not** call a tool.
|
|
104
|
-
* - `{ tool: <tool_name> }`: The model must call the specified tool.
|
|
105
|
-
*/
|
|
106
|
-
readonly toolChoice?: ToolChoice<Tools>;
|
|
107
|
-
/**
|
|
108
|
-
* The concurrency level for resolving tool calls.
|
|
109
|
-
*/
|
|
110
|
-
readonly concurrency?: Concurrency | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* When set to `true`, tool calls requested by the large language model
|
|
113
|
-
* will not be auto-resolved by the framework.
|
|
114
|
-
*
|
|
115
|
-
* This option is useful when:
|
|
116
|
-
* 1. The user wants to include tool call definitions from an `AiToolkit`
|
|
117
|
-
* in requests to the large language model so that the model has the
|
|
118
|
-
* capability to call tools.
|
|
119
|
-
* 2. The user wants to control the execution of tool call resolvers
|
|
120
|
-
* instead of having the framework handle tool call resolution.
|
|
121
|
-
*/
|
|
122
|
-
readonly disableToolCallResolution?: boolean | undefined;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Options for generating a structured object using a large language model.
|
|
126
|
-
*
|
|
127
|
-
* @since 1.0.0
|
|
128
|
-
* @category Models
|
|
129
|
-
*/
|
|
130
|
-
export interface GenerateObjectOptions<A, I extends Record<string, unknown>, R> {
|
|
131
|
-
/**
|
|
132
|
-
* The prompt input to use to generate text.
|
|
133
|
-
*/
|
|
134
|
-
readonly prompt: AiInput.Raw;
|
|
135
|
-
/**
|
|
136
|
-
* An optional system message that will be part of the prompt.
|
|
137
|
-
*/
|
|
138
|
-
readonly system?: string | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* The schema to be used to specify the structure of the object to generate.
|
|
141
|
-
*/
|
|
142
|
-
readonly schema: Schema.Schema<A, I, R>;
|
|
143
|
-
/**
|
|
144
|
-
* The identifier to use to associating the underlying tool call with the
|
|
145
|
-
* generated output.
|
|
146
|
-
*/
|
|
147
|
-
readonly toolCallId?: string | undefined;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* A utility type to extract the success type for the text generation methods
|
|
151
|
-
* of `AiLanguageModel` from the provided options.
|
|
152
|
-
*
|
|
153
|
-
* @since 1.0.0
|
|
154
|
-
* @category Utility Types
|
|
155
|
-
*/
|
|
156
|
-
export type ExtractSuccess<Options> = Options extends {
|
|
157
|
-
disableToolCallResolution: true;
|
|
158
|
-
} ? AiResponse.AiResponse : Options extends {
|
|
159
|
-
toolkit: AiToolkit.ToHandler<infer _Tools>;
|
|
160
|
-
} ? AiResponse.WithToolCallResults<_Tools> : Options extends {
|
|
161
|
-
toolkit: Effect.Effect<AiToolkit.ToHandler<infer _Tools>, infer _E, infer _R>;
|
|
162
|
-
} ? AiResponse.WithToolCallResults<_Tools> : AiResponse.AiResponse;
|
|
163
|
-
/**
|
|
164
|
-
* A utility type to extract the error type for the text generation methods
|
|
165
|
-
* of `AiLanguageModel` from the provided options.
|
|
166
|
-
*
|
|
167
|
-
* @since 1.0.0
|
|
168
|
-
* @category Utility Types
|
|
169
|
-
*/
|
|
170
|
-
export type ExtractError<Options> = Options extends {
|
|
171
|
-
disableToolCallResolution: true;
|
|
172
|
-
} ? AiError : Options extends {
|
|
173
|
-
toolkit: AiToolkit.ToHandler<infer _Tools>;
|
|
174
|
-
} ? AiError | AiTool.Failure<_Tools> : Options extends {
|
|
175
|
-
toolkit: Effect.Effect<AiToolkit.ToHandler<infer _Tools>, infer _E, infer _R>;
|
|
176
|
-
} ? AiError | AiTool.Failure<_Tools> | _E : AiError;
|
|
177
|
-
/**
|
|
178
|
-
* A utility type to extract the context type for the text generation methods
|
|
179
|
-
* of `AiLanguageModel` from the provided options.
|
|
180
|
-
*
|
|
181
|
-
* @since 1.0.0
|
|
182
|
-
* @category Utility Types
|
|
183
|
-
*/
|
|
184
|
-
export type ExtractContext<Options> = Options extends {
|
|
185
|
-
disableToolCallResolution: true;
|
|
186
|
-
} ? never : Options extends {
|
|
187
|
-
toolkit: AiToolkit.ToHandler<infer _Tools>;
|
|
188
|
-
} ? AiTool.Context<_Tools> : Options extends {
|
|
189
|
-
toolkit: Effect.Effect<AiToolkit.ToHandler<infer _Tools>, infer _E, infer _R>;
|
|
190
|
-
} ? AiTool.Context<_Tools> | _R : never;
|
|
191
|
-
/**
|
|
192
|
-
* @since 1.0.0
|
|
193
|
-
* @category Models
|
|
194
|
-
*/
|
|
195
|
-
export declare namespace AiLanguageModel {
|
|
196
|
-
/**
|
|
197
|
-
* @since 1.0.0
|
|
198
|
-
* @category Models
|
|
199
|
-
*/
|
|
200
|
-
interface Service {
|
|
201
|
-
/**
|
|
202
|
-
* Generate text using a large language model for the specified `prompt`.
|
|
203
|
-
*
|
|
204
|
-
* If a `toolkit` is specified, the large language model will additionally
|
|
205
|
-
* be able to perform tool calls to augment its response.
|
|
206
|
-
*/
|
|
207
|
-
readonly generateText: <Tools extends AiTool.Any, Options extends NoExcessProperties<GenerateTextOptions<any>, Options>>(options: Options & GenerateTextOptions<Tools>) => Effect.Effect<ExtractSuccess<Options>, ExtractError<Options>, ExtractContext<Options>>;
|
|
208
|
-
/**
|
|
209
|
-
* Generate text using a large language model for the specified `prompt`,
|
|
210
|
-
* streaming output from the model as soon as it is available.
|
|
211
|
-
*
|
|
212
|
-
* If a `toolkit` is specified, the large language model will additionally
|
|
213
|
-
* be able to perform tool calls to augment its response.
|
|
214
|
-
*/
|
|
215
|
-
readonly streamText: <Tools extends AiTool.Any, Options extends NoExcessProperties<GenerateTextOptions<any>, Options>>(options: Options & GenerateTextOptions<Tools>) => Stream.Stream<ExtractSuccess<Options>, ExtractError<Options>, ExtractContext<Options>>;
|
|
216
|
-
/**
|
|
217
|
-
* Generate a structured object for the specified prompt and schema using a
|
|
218
|
-
* large language model.
|
|
219
|
-
*/
|
|
220
|
-
readonly generateObject: <A, I extends Record<string, unknown>, R>(options: GenerateObjectOptions<A, I, R>) => Effect.Effect<AiResponse.WithStructuredOutput<A>, AiError, R>;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* @since 1.0.0
|
|
225
|
-
* @category Models
|
|
226
|
-
*/
|
|
227
|
-
export interface AiLanguageModelOptions {
|
|
228
|
-
/**
|
|
229
|
-
* The prompt messages to use to generate text.
|
|
230
|
-
*/
|
|
231
|
-
readonly prompt: AiInput.AiInput;
|
|
232
|
-
/**
|
|
233
|
-
* An optional system message that will be part of the prompt.
|
|
234
|
-
*/
|
|
235
|
-
readonly system: Option.Option<string>;
|
|
236
|
-
/**
|
|
237
|
-
* The tools to use to generate text in an encoded format suitable for
|
|
238
|
-
* incorporation into requests to the large language model.
|
|
239
|
-
*/
|
|
240
|
-
readonly tools: Array<{
|
|
241
|
-
readonly name: string;
|
|
242
|
-
readonly description: string;
|
|
243
|
-
readonly parameters: JsonSchema.JsonSchema7;
|
|
244
|
-
readonly structured: boolean;
|
|
245
|
-
}>;
|
|
246
|
-
/**
|
|
247
|
-
* The tool choice mode for the language model.
|
|
248
|
-
*
|
|
249
|
-
* - `auto` (default): The model can decide whether or not to call tools, as well as which tools to call.
|
|
250
|
-
* - `required`: The model **must** call a tool but can decide which tool will be called.
|
|
251
|
-
* - `none`: The model **must not** call a tool.
|
|
252
|
-
* - `{ tool: <tool_name> }`: The model must call the specified tool.
|
|
253
|
-
*/
|
|
254
|
-
readonly toolChoice: ToolChoice<any>;
|
|
255
|
-
/**
|
|
256
|
-
* The span to use to trace interactions with the large language model.
|
|
257
|
-
*/
|
|
258
|
-
readonly span: Span;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* @since 1.0.0
|
|
262
|
-
* @category Constructors
|
|
263
|
-
*/
|
|
264
|
-
export declare const make: (opts: {
|
|
265
|
-
readonly generateText: (options: AiLanguageModelOptions) => Effect.Effect<AiResponse.AiResponse, AiError, Context>;
|
|
266
|
-
readonly streamText: (options: AiLanguageModelOptions) => Stream.Stream<AiResponse.AiResponse, AiError, Context>;
|
|
267
|
-
}) => Effect.Effect<AiLanguageModel.Service>;
|
|
268
|
-
/**
|
|
269
|
-
* Generate text using a large language model for the specified `prompt`.
|
|
270
|
-
*
|
|
271
|
-
* If a `toolkit` is specified, the large language model will additionally
|
|
272
|
-
* be able to perform tool calls to augment its response.
|
|
273
|
-
*
|
|
274
|
-
* @since 1.0.0
|
|
275
|
-
* @category Functions
|
|
276
|
-
*/
|
|
277
|
-
export declare const generateText: <Tools extends AiTool.Any, Options extends NoExcessProperties<GenerateTextOptions<any>, Options>>(options: Options & GenerateTextOptions<Tools>) => Effect.Effect<ExtractSuccess<Options>, ExtractError<Options>, AiLanguageModel | ExtractContext<Options>>;
|
|
278
|
-
/**
|
|
279
|
-
* Generate a structured object for the specified prompt and schema using a
|
|
280
|
-
* large language model.
|
|
281
|
-
*
|
|
282
|
-
* When using a `Schema` that does not have an `identifier` or `_tag`
|
|
283
|
-
* property, you must specify a `toolCallId` to properly associate the
|
|
284
|
-
* output of the model.
|
|
285
|
-
*
|
|
286
|
-
* @since 1.0.0
|
|
287
|
-
* @category Functions
|
|
288
|
-
*/
|
|
289
|
-
export declare const generateObject: <A, I extends Record<string, unknown>, R>(options: GenerateObjectOptions<A, I, R>) => Effect.Effect<AiResponse.WithStructuredOutput<A>, AiError, AiLanguageModel | R>;
|
|
290
|
-
/**
|
|
291
|
-
* Generate text using a large language model for the specified `prompt`,
|
|
292
|
-
* streaming output from the model as soon as it is available.
|
|
293
|
-
*
|
|
294
|
-
* If a `toolkit` is specified, the large language model will additionally
|
|
295
|
-
* be able to perform tool calls to augment its response.
|
|
296
|
-
*
|
|
297
|
-
* @since 1.0.0
|
|
298
|
-
* @category Functions
|
|
299
|
-
*/
|
|
300
|
-
export declare const streamText: <Tools extends AiTool.Any, Options extends NoExcessProperties<GenerateTextOptions<any>, Options>>(options: Options & GenerateTextOptions<Tools>) => Stream.Stream<ExtractSuccess<Options>, ExtractError<Options>, AiLanguageModel | ExtractContext<Options>>;
|
|
301
|
-
export {};
|
|
302
|
-
//# sourceMappingURL=AiLanguageModel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AiLanguageModel.d.ts","sourceRoot":"","sources":["../../src/AiLanguageModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAW,kBAAkB,EAAE,MAAM,cAAc,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S,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAErE,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAC1C,MAAM,CAAC,MAAM,CAChB,cAAc,CAAC,OAAO,CAAC,EACvB,YAAY,CAAC,OAAO,CAAC,EACrB,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,CAC6B,CAAA;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,EACnE,OAAO,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KACpC,MAAM,CAAC,MAAM,CAChB,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAClC,OAAO,EACP,eAAe,GAAG,CAAC,CACqD,CAAA;AAE1E;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GACrB,KAAK,SAAS,MAAM,CAAC,GAAG,EACxB,OAAO,SAAS,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAErE,SAAS,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAC5C,MAAM,CAAC,MAAM,CACd,cAAc,CAAC,OAAO,CAAC,EACvB,YAAY,CAAC,OAAO,CAAC,EACrB,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,CACuC,CAAA"}
|
package/dist/dts/AiModel.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as Layer from "effect/Layer";
|
|
3
|
-
/**
|
|
4
|
-
* @since 1.0.0
|
|
5
|
-
* @category type ids
|
|
6
|
-
*/
|
|
7
|
-
export declare const TypeId: unique symbol;
|
|
8
|
-
/**
|
|
9
|
-
* @since 1.0.0
|
|
10
|
-
* @category type ids
|
|
11
|
-
*/
|
|
12
|
-
export type TypeId = typeof TypeId;
|
|
13
|
-
/**
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
* @category models
|
|
16
|
-
*/
|
|
17
|
-
export interface AiModel<in out Provides, in out Requires> extends Layer.Layer<Provides, never, Requires>, Effect.Effect<Layer.Layer<Provides>, never, Requires> {
|
|
18
|
-
readonly [TypeId]: TypeId;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @since 1.0.0
|
|
22
|
-
* @category constructors
|
|
23
|
-
*/
|
|
24
|
-
export declare const make: <Provides, Requires>(layer: Layer.Layer<Provides, never, Requires>) => AiModel<Provides, Requires>;
|
|
25
|
-
//# sourceMappingURL=AiModel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AiModel.d.ts","sourceRoot":"","sources":["../../src/AiModel.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAyC,CAAA;AAErE;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CACvD,SAAQ,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC;IAErG,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAC1B;AAiBD;;;GAGG;AACH,eAAO,MAAM,IAAI,GAAI,QAAQ,EAAE,QAAQ,EACrC,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,KAC5C,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAsD,CAAA"}
|