@langchain/core 1.1.3 → 1.1.4
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/CHANGELOG.md +8 -0
- package/dist/agents.d.cts +2 -0
- package/dist/agents.d.ts +2 -0
- package/dist/callbacks/base.d.cts +60 -22
- package/dist/callbacks/base.d.ts +60 -22
- package/dist/callbacks/dispatch/index.d.cts +3 -1
- package/dist/callbacks/dispatch/index.d.ts +3 -1
- package/dist/callbacks/dispatch/web.d.cts +3 -1
- package/dist/callbacks/dispatch/web.d.ts +3 -1
- package/dist/callbacks/manager.d.cts +12 -2
- package/dist/callbacks/manager.d.ts +12 -2
- package/dist/chat_history.d.cts +1 -0
- package/dist/chat_history.d.ts +1 -0
- package/dist/document_loaders/langsmith.d.cts +3 -0
- package/dist/document_loaders/langsmith.d.ts +3 -0
- package/dist/documents/document.d.cts +12 -3
- package/dist/documents/document.d.ts +12 -3
- package/dist/example_selectors/length_based.d.cts +1 -1
- package/dist/example_selectors/length_based.d.ts +1 -1
- package/dist/indexing/base.d.cts +1 -0
- package/dist/indexing/base.d.ts +1 -0
- package/dist/indexing/record_manager.d.cts +1 -0
- package/dist/indexing/record_manager.d.ts +1 -0
- package/dist/language_models/base.d.cts +38 -8
- package/dist/language_models/base.d.ts +38 -8
- package/dist/language_models/chat_models.d.cts +33 -6
- package/dist/language_models/chat_models.d.ts +33 -6
- package/dist/language_models/llms.d.cts +6 -0
- package/dist/language_models/llms.d.ts +6 -0
- package/dist/load/import_type.d.cts +1 -0
- package/dist/load/import_type.d.ts +1 -0
- package/dist/load/map_keys.cjs +5 -4
- package/dist/load/map_keys.cjs.map +1 -1
- package/dist/load/map_keys.d.cts +1 -0
- package/dist/load/map_keys.d.ts +1 -0
- package/dist/load/map_keys.js +3 -3
- package/dist/load/map_keys.js.map +1 -1
- package/dist/load/serializable.d.cts +1 -0
- package/dist/load/serializable.d.ts +1 -0
- package/dist/memory.d.cts +3 -0
- package/dist/memory.d.ts +3 -0
- package/dist/messages/base.d.cts +13 -1
- package/dist/messages/base.d.ts +13 -1
- package/dist/messages/content/data.d.cts +7 -2
- package/dist/messages/content/data.d.ts +7 -2
- package/dist/messages/content/index.d.cts +4 -1
- package/dist/messages/content/index.d.ts +4 -1
- package/dist/messages/content/multimodal.d.cts +1 -0
- package/dist/messages/content/multimodal.d.ts +1 -0
- package/dist/messages/content/tools.d.cts +1 -0
- package/dist/messages/content/tools.d.ts +1 -0
- package/dist/messages/tool.d.cts +9 -2
- package/dist/messages/tool.d.ts +9 -2
- package/dist/messages/transformers.d.cts +3 -0
- package/dist/messages/transformers.d.ts +3 -0
- package/dist/messages/utils.d.cts +5 -2
- package/dist/messages/utils.d.ts +5 -2
- package/dist/output_parsers/json.d.cts +5 -1
- package/dist/output_parsers/json.d.ts +5 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +6 -2
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +6 -2
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +34 -10
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +34 -10
- package/dist/output_parsers/transform.d.cts +1 -0
- package/dist/output_parsers/transform.d.ts +1 -0
- package/dist/outputs.d.cts +6 -0
- package/dist/outputs.d.ts +6 -0
- package/dist/prompts/base.d.cts +10 -2
- package/dist/prompts/base.d.ts +10 -2
- package/dist/prompts/chat.d.cts +51 -13
- package/dist/prompts/chat.d.ts +51 -13
- package/dist/prompts/few_shot.d.cts +5 -1
- package/dist/prompts/few_shot.d.ts +5 -1
- package/dist/prompts/image.d.cts +10 -2
- package/dist/prompts/image.d.ts +10 -2
- package/dist/prompts/prompt.d.cts +15 -4
- package/dist/prompts/prompt.d.ts +16 -4
- package/dist/prompts/serde.d.cts +1 -0
- package/dist/prompts/serde.d.ts +1 -0
- package/dist/prompts/string.d.cts +5 -1
- package/dist/prompts/string.d.ts +5 -1
- package/dist/prompts/structured.d.cts +16 -3
- package/dist/prompts/structured.d.ts +16 -3
- package/dist/retrievers/document_compressors/index.d.cts +1 -0
- package/dist/retrievers/document_compressors/index.d.ts +1 -0
- package/dist/retrievers/index.d.cts +6 -2
- package/dist/retrievers/index.d.ts +6 -2
- package/dist/runnables/base.cjs +7 -7
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +64 -12
- package/dist/runnables/base.d.ts +64 -12
- package/dist/runnables/base.js +1 -1
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.d.cts +2 -0
- package/dist/runnables/branch.d.ts +2 -0
- package/dist/runnables/config.d.cts +1 -0
- package/dist/runnables/config.d.ts +1 -0
- package/dist/runnables/graph.d.cts +5 -1
- package/dist/runnables/graph.d.ts +5 -1
- package/dist/runnables/history.d.cts +12 -4
- package/dist/runnables/history.d.ts +12 -4
- package/dist/runnables/passthrough.d.cts +2 -0
- package/dist/runnables/passthrough.d.ts +2 -0
- package/dist/runnables/router.d.cts +1 -0
- package/dist/runnables/router.d.ts +1 -0
- package/dist/runnables/types.d.cts +9 -2
- package/dist/runnables/types.d.ts +9 -2
- package/dist/singletons/async_local_storage/context.d.cts +2 -0
- package/dist/singletons/async_local_storage/context.d.ts +2 -0
- package/dist/singletons/async_local_storage/globals.d.cts +1 -0
- package/dist/singletons/async_local_storage/globals.d.ts +1 -0
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/stores.d.cts +1 -0
- package/dist/stores.d.ts +1 -0
- package/dist/structured_query/utils.d.cts +4 -1
- package/dist/structured_query/utils.d.ts +4 -1
- package/dist/tools/index.d.cts +6 -1
- package/dist/tools/index.d.ts +6 -1
- package/dist/tools/types.d.cts +13 -3
- package/dist/tools/types.d.ts +13 -3
- package/dist/tracers/base.d.cts +20 -1
- package/dist/tracers/base.d.ts +20 -1
- package/dist/tracers/console.cjs +3 -3
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.d.cts +2 -0
- package/dist/tracers/console.d.ts +2 -0
- package/dist/tracers/console.js +3 -3
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.d.cts +4 -0
- package/dist/tracers/event_stream.d.ts +4 -0
- package/dist/tracers/log_stream.d.cts +6 -0
- package/dist/tracers/log_stream.d.ts +6 -0
- package/dist/types/_internal.d.cts +3 -0
- package/dist/types/_internal.d.ts +3 -0
- package/dist/types/type-utils.d.cts +2 -0
- package/dist/types/type-utils.d.ts +2 -0
- package/dist/utils/async_caller.cjs +1 -1
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.d.cts +3 -0
- package/dist/utils/async_caller.d.ts +3 -0
- package/dist/utils/async_caller.js +1 -1
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/env.d.cts +4 -0
- package/dist/utils/env.d.ts +4 -0
- package/dist/utils/event_source_parse.d.cts +4 -1
- package/dist/utils/event_source_parse.d.ts +4 -1
- package/dist/utils/function_calling.d.cts +3 -1
- package/dist/utils/function_calling.d.ts +3 -1
- package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.cjs +1 -1
- package/dist/utils/is-network-error/index.cjs.map +1 -0
- package/dist/{node_modules/.pnpm/is-network-error@1.3.0/node_modules → utils}/is-network-error/index.js +1 -1
- package/dist/utils/is-network-error/index.js.map +1 -0
- package/dist/utils/json.d.cts +1 -0
- package/dist/utils/json.d.ts +1 -0
- package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.cjs +2 -2
- package/dist/utils/p-retry/index.cjs.map +1 -0
- package/dist/{node_modules/.pnpm/p-retry@7.1.0/node_modules → utils}/p-retry/index.js +2 -2
- package/dist/utils/p-retry/index.js.map +1 -0
- package/dist/utils/stream.d.cts +13 -1
- package/dist/utils/stream.d.ts +13 -1
- package/dist/utils/testing/chat_models.d.cts +11 -3
- package/dist/utils/testing/chat_models.d.ts +11 -3
- package/dist/utils/testing/retrievers.d.cts +3 -1
- package/dist/utils/testing/retrievers.d.ts +3 -1
- package/dist/utils/testing/vectorstores.d.cts +1 -0
- package/dist/utils/testing/vectorstores.d.ts +1 -0
- package/dist/utils/types/index.d.cts +2 -0
- package/dist/utils/types/index.d.ts +2 -0
- package/dist/utils/types/zod.d.cts +3 -0
- package/dist/utils/types/zod.d.ts +3 -0
- package/dist/vectorstores.d.cts +17 -5
- package/dist/vectorstores.d.ts +17 -5
- package/package.json +5 -6
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +0 -169
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +0 -168
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +0 -1
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +0 -122
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +0 -121
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +0 -1
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +0 -18
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +0 -17
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +0 -1
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +0 -1
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +0 -1
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js.map +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
//#region src/documents/document.d.ts
|
|
2
|
-
interface DocumentInput<
|
|
2
|
+
interface DocumentInput<
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
Metadata extends Record<string, any> = Record<string, any>> {
|
|
3
5
|
pageContent: string;
|
|
4
6
|
metadata?: Metadata;
|
|
5
7
|
/**
|
|
@@ -10,7 +12,9 @@ interface DocumentInput<Metadata extends Record<string, any> = Record<string, an
|
|
|
10
12
|
*/
|
|
11
13
|
id?: string;
|
|
12
14
|
}
|
|
13
|
-
interface DocumentInterface<
|
|
15
|
+
interface DocumentInterface<
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
Metadata extends Record<string, any> = Record<string, any>> {
|
|
14
18
|
pageContent: string;
|
|
15
19
|
metadata: Metadata;
|
|
16
20
|
/**
|
|
@@ -24,9 +28,14 @@ interface DocumentInterface<Metadata extends Record<string, any> = Record<string
|
|
|
24
28
|
/**
|
|
25
29
|
* Interface for interacting with a document.
|
|
26
30
|
*/
|
|
27
|
-
declare class Document<
|
|
31
|
+
declare class Document<
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
Metadata extends Record<string, any> = Record<string, any>> implements DocumentInput, DocumentInterface {
|
|
28
34
|
pageContent: string;
|
|
29
35
|
metadata: Metadata;
|
|
36
|
+
// The ID field is optional at the moment.
|
|
37
|
+
// It will likely become required in a future major release after
|
|
38
|
+
// it has been adopted by enough vectorstore implementations.
|
|
30
39
|
/**
|
|
31
40
|
* An optional identifier for the document.
|
|
32
41
|
*
|
|
@@ -56,7 +56,7 @@ interface LengthBasedExampleSelectorInput {
|
|
|
56
56
|
*/
|
|
57
57
|
declare class LengthBasedExampleSelector extends BaseExampleSelector {
|
|
58
58
|
protected examples: Example[];
|
|
59
|
-
examplePrompt
|
|
59
|
+
examplePrompt!: PromptTemplate;
|
|
60
60
|
getTextLength: (text: string) => number;
|
|
61
61
|
maxLength: number;
|
|
62
62
|
exampleTextLengths: number[];
|
|
@@ -56,7 +56,7 @@ interface LengthBasedExampleSelectorInput {
|
|
|
56
56
|
*/
|
|
57
57
|
declare class LengthBasedExampleSelector extends BaseExampleSelector {
|
|
58
58
|
protected examples: Example[];
|
|
59
|
-
examplePrompt
|
|
59
|
+
examplePrompt!: PromptTemplate;
|
|
60
60
|
getTextLength: (text: string) => number;
|
|
61
61
|
maxLength: number;
|
|
62
62
|
exampleTextLengths: number[];
|
package/dist/indexing/base.d.cts
CHANGED
|
@@ -89,6 +89,7 @@ type IndexOptions = {
|
|
|
89
89
|
declare function _batch<T>(size: number, iterable: T[]): T[][];
|
|
90
90
|
declare function _deduplicateInOrder(hashedDocuments: HashedDocumentInterface[]): HashedDocumentInterface[];
|
|
91
91
|
declare function _getSourceIdAssigner(sourceIdKey: StringOrDocFunc | null): (doc: DocumentInterface) => string | null;
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
93
|
declare const _isBaseDocumentLoader: (arg: any) => arg is BaseDocumentLoader;
|
|
93
94
|
interface IndexArgs {
|
|
94
95
|
docsSource: BaseDocumentLoader | DocumentInterface[];
|
package/dist/indexing/base.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ type IndexOptions = {
|
|
|
89
89
|
declare function _batch<T>(size: number, iterable: T[]): T[][];
|
|
90
90
|
declare function _deduplicateInOrder(hashedDocuments: HashedDocumentInterface[]): HashedDocumentInterface[];
|
|
91
91
|
declare function _getSourceIdAssigner(sourceIdKey: StringOrDocFunc | null): (doc: DocumentInterface) => string | null;
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
93
|
declare const _isBaseDocumentLoader: (arg: any) => arg is BaseDocumentLoader;
|
|
93
94
|
interface IndexArgs {
|
|
94
95
|
docsSource: BaseDocumentLoader | DocumentInterface[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Serializable } from "../load/serializable.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/indexing/record_manager.d.ts
|
|
4
|
+
// Arbitrary value, used for generating namespaced UUIDs.
|
|
4
5
|
declare const UUIDV5_NAMESPACE = "10f90ea3-90a4-4962-bf75-83a0f3c1c62a";
|
|
5
6
|
type UpdateOptions = {
|
|
6
7
|
groupIds?: (string | null)[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Serializable } from "../load/serializable.js";
|
|
2
2
|
|
|
3
3
|
//#region src/indexing/record_manager.d.ts
|
|
4
|
+
// Arbitrary value, used for generating namespaced UUIDs.
|
|
4
5
|
declare const UUIDV5_NAMESPACE = "10f90ea3-90a4-4962-bf75-83a0f3c1c62a";
|
|
5
6
|
type UpdateOptions = {
|
|
6
7
|
groupIds?: (string | null)[];
|
|
@@ -14,6 +14,7 @@ import { $ZodType } from "zod/v4/core";
|
|
|
14
14
|
import { TiktokenModel } from "js-tiktoken/lite";
|
|
15
15
|
|
|
16
16
|
//#region src/language_models/base.d.ts
|
|
17
|
+
// https://www.npmjs.com/package/js-tiktoken
|
|
17
18
|
declare const getModelNameForTiktoken: (modelName: string) => TiktokenModel;
|
|
18
19
|
declare const getEmbeddingContextSize: (modelName?: string | undefined) => number;
|
|
19
20
|
/**
|
|
@@ -151,12 +152,15 @@ type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> = {
|
|
|
151
152
|
/** @deprecated Use StructuredOutputMethodOptions instead */
|
|
152
153
|
type StructuredOutputMethodParams<RunOutput, IncludeRaw extends boolean = false> = {
|
|
153
154
|
/** @deprecated Pass schema in as the first argument */
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
156
|
schema: InteropZodType<RunOutput> | Record<string, any>;
|
|
155
157
|
name?: string;
|
|
156
158
|
method?: "functionCalling" | "jsonMode";
|
|
157
159
|
includeRaw?: IncludeRaw;
|
|
158
160
|
};
|
|
159
|
-
interface BaseLanguageModelInterface<
|
|
161
|
+
interface BaseLanguageModelInterface<
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
+
RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {
|
|
160
164
|
get callKeys(): string[];
|
|
161
165
|
generatePrompt(promptValues: BasePromptValueInterface[], options?: string[] | CallOptions, callbacks?: Callbacks): Promise<LLMResult>;
|
|
162
166
|
_modelType(): string;
|
|
@@ -165,6 +169,7 @@ interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLa
|
|
|
165
169
|
/**
|
|
166
170
|
* Get the identifying parameters of the LLM.
|
|
167
171
|
*/
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
173
|
_identifyingParams(): Record<string, any>;
|
|
169
174
|
serialize(): SerializedLLM;
|
|
170
175
|
}
|
|
@@ -173,7 +178,9 @@ type LanguageModelLike = Runnable<BaseLanguageModelInput, LanguageModelOutput>;
|
|
|
173
178
|
/**
|
|
174
179
|
* Base class for language models.
|
|
175
180
|
*/
|
|
176
|
-
declare abstract class BaseLanguageModel<
|
|
181
|
+
declare abstract class BaseLanguageModel<
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions> implements BaseLanguageModelParams, BaseLanguageModelInterface<RunOutput, CallOptions> {
|
|
177
184
|
/**
|
|
178
185
|
* Keys that the language model accepts as call options.
|
|
179
186
|
*/
|
|
@@ -203,13 +210,16 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
|
|
|
203
210
|
/**
|
|
204
211
|
* Get the identifying parameters of the LLM.
|
|
205
212
|
*/
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
214
|
_identifyingParams(): Record<string, any>;
|
|
207
215
|
/**
|
|
208
216
|
* Create a unique cache key for a specific call to a specific language model.
|
|
209
217
|
* @param callOptions Call options for the model
|
|
210
218
|
* @returns A unique cache key.
|
|
211
219
|
*/
|
|
212
|
-
_getSerializedCacheKeyParametersForCall(
|
|
220
|
+
_getSerializedCacheKeyParametersForCall(
|
|
221
|
+
// TODO: Fix when we remove the RunnableLambda backwards compatibility shim.
|
|
222
|
+
{
|
|
213
223
|
config,
|
|
214
224
|
...callOptions
|
|
215
225
|
}: CallOptions & {
|
|
@@ -231,13 +241,29 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
|
|
|
231
241
|
* @returns {ModelProfile} An object describing the model's capabilities and constraints
|
|
232
242
|
*/
|
|
233
243
|
get profile(): ModelProfile;
|
|
234
|
-
withStructuredOutput?<
|
|
235
|
-
|
|
244
|
+
withStructuredOutput?<
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
246
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: ZodType<RunOutput>
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
248
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
249
|
+
withStructuredOutput?<
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: ZodType<RunOutput>
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
236
254
|
raw: BaseMessage;
|
|
237
255
|
parsed: RunOutput;
|
|
238
256
|
}>;
|
|
239
|
-
withStructuredOutput?<
|
|
240
|
-
|
|
257
|
+
withStructuredOutput?<
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
259
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: $ZodType<RunOutput>
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
262
|
+
withStructuredOutput?<
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: $ZodType<RunOutput>
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
241
267
|
raw: BaseMessage;
|
|
242
268
|
parsed: RunOutput;
|
|
243
269
|
}>;
|
|
@@ -254,7 +280,11 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
|
|
|
254
280
|
* @param {boolean | undefined} [includeRaw=false] Whether to include the raw output in the result. Defaults to false.
|
|
255
281
|
* @returns {Runnable<RunInput, RunOutput> | Runnable<RunInput, { raw: BaseMessage; parsed: RunOutput }>} A new runnable that calls the LLM with structured output.
|
|
256
282
|
*/
|
|
257
|
-
withStructuredOutput?<
|
|
283
|
+
withStructuredOutput?<
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput>
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
287
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
258
288
|
raw: BaseMessage;
|
|
259
289
|
parsed: RunOutput;
|
|
260
290
|
}>;
|
|
@@ -16,6 +16,7 @@ import { $ZodType } from "zod/v4/core";
|
|
|
16
16
|
import { TiktokenModel } from "js-tiktoken/lite";
|
|
17
17
|
|
|
18
18
|
//#region src/language_models/base.d.ts
|
|
19
|
+
// https://www.npmjs.com/package/js-tiktoken
|
|
19
20
|
declare const getModelNameForTiktoken: (modelName: string) => TiktokenModel;
|
|
20
21
|
declare const getEmbeddingContextSize: (modelName?: string | undefined) => number;
|
|
21
22
|
/**
|
|
@@ -153,12 +154,15 @@ type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> = {
|
|
|
153
154
|
/** @deprecated Use StructuredOutputMethodOptions instead */
|
|
154
155
|
type StructuredOutputMethodParams<RunOutput, IncludeRaw extends boolean = false> = {
|
|
155
156
|
/** @deprecated Pass schema in as the first argument */
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
158
|
schema: InteropZodType<RunOutput> | Record<string, any>;
|
|
157
159
|
name?: string;
|
|
158
160
|
method?: "functionCalling" | "jsonMode";
|
|
159
161
|
includeRaw?: IncludeRaw;
|
|
160
162
|
};
|
|
161
|
-
interface BaseLanguageModelInterface<
|
|
163
|
+
interface BaseLanguageModelInterface<
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
+
RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {
|
|
162
166
|
get callKeys(): string[];
|
|
163
167
|
generatePrompt(promptValues: BasePromptValueInterface[], options?: string[] | CallOptions, callbacks?: Callbacks): Promise<LLMResult>;
|
|
164
168
|
_modelType(): string;
|
|
@@ -167,6 +171,7 @@ interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLa
|
|
|
167
171
|
/**
|
|
168
172
|
* Get the identifying parameters of the LLM.
|
|
169
173
|
*/
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
170
175
|
_identifyingParams(): Record<string, any>;
|
|
171
176
|
serialize(): SerializedLLM;
|
|
172
177
|
}
|
|
@@ -175,7 +180,9 @@ type LanguageModelLike = Runnable<BaseLanguageModelInput, LanguageModelOutput>;
|
|
|
175
180
|
/**
|
|
176
181
|
* Base class for language models.
|
|
177
182
|
*/
|
|
178
|
-
declare abstract class BaseLanguageModel<
|
|
183
|
+
declare abstract class BaseLanguageModel<
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
185
|
+
RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions> implements BaseLanguageModelParams, BaseLanguageModelInterface<RunOutput, CallOptions> {
|
|
179
186
|
/**
|
|
180
187
|
* Keys that the language model accepts as call options.
|
|
181
188
|
*/
|
|
@@ -205,13 +212,16 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
|
|
|
205
212
|
/**
|
|
206
213
|
* Get the identifying parameters of the LLM.
|
|
207
214
|
*/
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
216
|
_identifyingParams(): Record<string, any>;
|
|
209
217
|
/**
|
|
210
218
|
* Create a unique cache key for a specific call to a specific language model.
|
|
211
219
|
* @param callOptions Call options for the model
|
|
212
220
|
* @returns A unique cache key.
|
|
213
221
|
*/
|
|
214
|
-
_getSerializedCacheKeyParametersForCall(
|
|
222
|
+
_getSerializedCacheKeyParametersForCall(
|
|
223
|
+
// TODO: Fix when we remove the RunnableLambda backwards compatibility shim.
|
|
224
|
+
{
|
|
215
225
|
config,
|
|
216
226
|
...callOptions
|
|
217
227
|
}: CallOptions & {
|
|
@@ -233,13 +243,29 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
|
|
|
233
243
|
* @returns {ModelProfile} An object describing the model's capabilities and constraints
|
|
234
244
|
*/
|
|
235
245
|
get profile(): ModelProfile;
|
|
236
|
-
withStructuredOutput?<
|
|
237
|
-
|
|
246
|
+
withStructuredOutput?<
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
248
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: ZodType<RunOutput>
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
251
|
+
withStructuredOutput?<
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: ZodType<RunOutput>
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
238
256
|
raw: BaseMessage;
|
|
239
257
|
parsed: RunOutput;
|
|
240
258
|
}>;
|
|
241
|
-
withStructuredOutput?<
|
|
242
|
-
|
|
259
|
+
withStructuredOutput?<
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: $ZodType<RunOutput>
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
263
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
264
|
+
withStructuredOutput?<
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
266
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: $ZodType<RunOutput>
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
243
269
|
raw: BaseMessage;
|
|
244
270
|
parsed: RunOutput;
|
|
245
271
|
}>;
|
|
@@ -256,7 +282,11 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
|
|
|
256
282
|
* @param {boolean | undefined} [includeRaw=false] Whether to include the raw output in the result. Defaults to false.
|
|
257
283
|
* @returns {Runnable<RunInput, RunOutput> | Runnable<RunInput, { raw: BaseMessage; parsed: RunOutput }>} A new runnable that calls the LLM with structured output.
|
|
258
284
|
*/
|
|
259
|
-
withStructuredOutput?<
|
|
285
|
+
withStructuredOutput?<
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
287
|
+
RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput>
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
260
290
|
raw: BaseMessage;
|
|
261
291
|
parsed: RunOutput;
|
|
262
292
|
}>;
|
|
@@ -13,6 +13,7 @@ import { ZodType } from "zod/v3";
|
|
|
13
13
|
import { $ZodType } from "zod/v4/core";
|
|
14
14
|
|
|
15
15
|
//#region src/language_models/chat_models.d.ts
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
type ToolChoice = string | Record<string, any> | "auto" | "any";
|
|
17
18
|
/**
|
|
18
19
|
* Represents a serialized chat model.
|
|
@@ -21,6 +22,7 @@ type SerializedChatModel = {
|
|
|
21
22
|
_model: string;
|
|
22
23
|
_type: string;
|
|
23
24
|
} & Record<string, any>;
|
|
25
|
+
// todo?
|
|
24
26
|
/**
|
|
25
27
|
* Represents a serialized large language model.
|
|
26
28
|
*/
|
|
@@ -103,13 +105,19 @@ type LangSmithParams = {
|
|
|
103
105
|
ls_max_tokens?: number;
|
|
104
106
|
ls_stop?: Array<string>;
|
|
105
107
|
};
|
|
106
|
-
type BindToolsInput = StructuredToolInterface
|
|
108
|
+
type BindToolsInput = StructuredToolInterface
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
| Record<string, any> | ToolDefinition | RunnableToolLike | StructuredToolParams;
|
|
107
111
|
/**
|
|
108
112
|
* Base class for chat models. It extends the BaseLanguageModel class and
|
|
109
113
|
* provides methods for generating chat based on input messages.
|
|
110
114
|
*/
|
|
111
|
-
declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions,
|
|
115
|
+
declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions,
|
|
116
|
+
// TODO: Fix the parameter order on the next minor version.
|
|
117
|
+
OutputMessageType extends BaseMessageChunk = AIMessageChunk> extends BaseLanguageModel<OutputMessageType, CallOptions> {
|
|
118
|
+
// Backwards compatibility since fields have been moved to RunnableConfig
|
|
112
119
|
ParsedCallOptions: Omit<CallOptions, Exclude<keyof RunnableConfig, "signal" | "timeout" | "maxConcurrency">>;
|
|
120
|
+
// Only ever instantiated in main LangChain
|
|
113
121
|
lc_namespace: string[];
|
|
114
122
|
disableStreaming: boolean;
|
|
115
123
|
outputVersion?: MessageOutputVersion;
|
|
@@ -133,6 +141,7 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
133
141
|
* @returns A Promise that resolves to a BaseMessageChunk.
|
|
134
142
|
*/
|
|
135
143
|
invoke(input: BaseLanguageModelInput, options?: CallOptions): Promise<OutputMessageType>;
|
|
144
|
+
// eslint-disable-next-line require-yield
|
|
136
145
|
_streamResponseChunks(_messages: BaseMessage[], _options: this["ParsedCallOptions"], _runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
137
146
|
_streamIterator(input: BaseLanguageModelInput, options?: CallOptions): AsyncGenerator<OutputMessageType>;
|
|
138
147
|
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
@@ -148,6 +157,7 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
148
157
|
messages: BaseMessageLike[][];
|
|
149
158
|
cache: BaseCache<Generation[]>;
|
|
150
159
|
llmStringKey: string;
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
161
|
parsedOptions: any;
|
|
152
162
|
handledOptions: RunnableConfig;
|
|
153
163
|
}): Promise<LLMResult & {
|
|
@@ -165,6 +175,7 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
165
175
|
/**
|
|
166
176
|
* Get the parameters used to invoke the model
|
|
167
177
|
*/
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
179
|
invocationParams(_options?: this["ParsedCallOptions"]): any;
|
|
169
180
|
_modelType(): string;
|
|
170
181
|
abstract _llmType(): string;
|
|
@@ -177,13 +188,29 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
177
188
|
*/
|
|
178
189
|
generatePrompt(promptValues: BasePromptValueInterface[], options?: string[] | CallOptions, callbacks?: Callbacks): Promise<LLMResult>;
|
|
179
190
|
abstract _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
180
|
-
withStructuredOutput<
|
|
181
|
-
|
|
191
|
+
withStructuredOutput<
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
193
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: $ZodType<RunOutput>
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
195
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
196
|
+
withStructuredOutput<
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: $ZodType<RunOutput>
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
182
201
|
raw: BaseMessage;
|
|
183
202
|
parsed: RunOutput;
|
|
184
203
|
}>;
|
|
185
|
-
withStructuredOutput<
|
|
186
|
-
|
|
204
|
+
withStructuredOutput<
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: ZodType<RunOutput>
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
209
|
+
withStructuredOutput<
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: ZodType<RunOutput>
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
213
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
187
214
|
raw: BaseMessage;
|
|
188
215
|
parsed: RunOutput;
|
|
189
216
|
}>;
|
|
@@ -16,6 +16,7 @@ import { ZodType } from "zod/v3";
|
|
|
16
16
|
import { $ZodType } from "zod/v4/core";
|
|
17
17
|
|
|
18
18
|
//#region src/language_models/chat_models.d.ts
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
20
|
type ToolChoice = string | Record<string, any> | "auto" | "any";
|
|
20
21
|
/**
|
|
21
22
|
* Represents a serialized chat model.
|
|
@@ -24,6 +25,7 @@ type SerializedChatModel = {
|
|
|
24
25
|
_model: string;
|
|
25
26
|
_type: string;
|
|
26
27
|
} & Record<string, any>;
|
|
28
|
+
// todo?
|
|
27
29
|
/**
|
|
28
30
|
* Represents a serialized large language model.
|
|
29
31
|
*/
|
|
@@ -106,13 +108,19 @@ type LangSmithParams = {
|
|
|
106
108
|
ls_max_tokens?: number;
|
|
107
109
|
ls_stop?: Array<string>;
|
|
108
110
|
};
|
|
109
|
-
type BindToolsInput = StructuredToolInterface
|
|
111
|
+
type BindToolsInput = StructuredToolInterface
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
| Record<string, any> | ToolDefinition | RunnableToolLike | StructuredToolParams;
|
|
110
114
|
/**
|
|
111
115
|
* Base class for chat models. It extends the BaseLanguageModel class and
|
|
112
116
|
* provides methods for generating chat based on input messages.
|
|
113
117
|
*/
|
|
114
|
-
declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions,
|
|
118
|
+
declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions,
|
|
119
|
+
// TODO: Fix the parameter order on the next minor version.
|
|
120
|
+
OutputMessageType extends BaseMessageChunk = AIMessageChunk> extends BaseLanguageModel<OutputMessageType, CallOptions> {
|
|
121
|
+
// Backwards compatibility since fields have been moved to RunnableConfig
|
|
115
122
|
ParsedCallOptions: Omit<CallOptions, Exclude<keyof RunnableConfig, "signal" | "timeout" | "maxConcurrency">>;
|
|
123
|
+
// Only ever instantiated in main LangChain
|
|
116
124
|
lc_namespace: string[];
|
|
117
125
|
disableStreaming: boolean;
|
|
118
126
|
outputVersion?: MessageOutputVersion;
|
|
@@ -136,6 +144,7 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
136
144
|
* @returns A Promise that resolves to a BaseMessageChunk.
|
|
137
145
|
*/
|
|
138
146
|
invoke(input: BaseLanguageModelInput, options?: CallOptions): Promise<OutputMessageType>;
|
|
147
|
+
// eslint-disable-next-line require-yield
|
|
139
148
|
_streamResponseChunks(_messages: BaseMessage[], _options: this["ParsedCallOptions"], _runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
140
149
|
_streamIterator(input: BaseLanguageModelInput, options?: CallOptions): AsyncGenerator<OutputMessageType>;
|
|
141
150
|
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
@@ -151,6 +160,7 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
151
160
|
messages: BaseMessageLike[][];
|
|
152
161
|
cache: BaseCache<Generation[]>;
|
|
153
162
|
llmStringKey: string;
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
164
|
parsedOptions: any;
|
|
155
165
|
handledOptions: RunnableConfig;
|
|
156
166
|
}): Promise<LLMResult & {
|
|
@@ -168,6 +178,7 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
168
178
|
/**
|
|
169
179
|
* Get the parameters used to invoke the model
|
|
170
180
|
*/
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
182
|
invocationParams(_options?: this["ParsedCallOptions"]): any;
|
|
172
183
|
_modelType(): string;
|
|
173
184
|
abstract _llmType(): string;
|
|
@@ -180,13 +191,29 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
|
|
|
180
191
|
*/
|
|
181
192
|
generatePrompt(promptValues: BasePromptValueInterface[], options?: string[] | CallOptions, callbacks?: Callbacks): Promise<LLMResult>;
|
|
182
193
|
abstract _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
183
|
-
withStructuredOutput<
|
|
184
|
-
|
|
194
|
+
withStructuredOutput<
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: $ZodType<RunOutput>
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
199
|
+
withStructuredOutput<
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: $ZodType<RunOutput>
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
185
204
|
raw: BaseMessage;
|
|
186
205
|
parsed: RunOutput;
|
|
187
206
|
}>;
|
|
188
|
-
withStructuredOutput<
|
|
189
|
-
|
|
207
|
+
withStructuredOutput<
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
209
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: ZodType<RunOutput>
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
212
|
+
withStructuredOutput<
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: ZodType<RunOutput>
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
190
217
|
raw: BaseMessage;
|
|
191
218
|
parsed: RunOutput;
|
|
192
219
|
}>;
|
|
@@ -16,7 +16,9 @@ interface BaseLLMCallOptions extends BaseLanguageModelCallOptions {}
|
|
|
16
16
|
* LLM Wrapper. Takes in a prompt (or prompts) and returns a string.
|
|
17
17
|
*/
|
|
18
18
|
declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMCallOptions> extends BaseLanguageModel<string, CallOptions> {
|
|
19
|
+
// Backwards compatibility since fields have been moved to RunnableConfig
|
|
19
20
|
ParsedCallOptions: Omit<CallOptions, Exclude<keyof RunnableConfig, "signal" | "timeout" | "maxConcurrency">>;
|
|
21
|
+
// Only ever instantiated in main LangChain
|
|
20
22
|
lc_namespace: string[];
|
|
21
23
|
/**
|
|
22
24
|
* This method takes an input and options, and returns a string. It
|
|
@@ -27,6 +29,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
27
29
|
* @returns A string result based on the prompt.
|
|
28
30
|
*/
|
|
29
31
|
invoke(input: BaseLanguageModelInput, options?: CallOptions): Promise<string>;
|
|
32
|
+
// eslint-disable-next-line require-yield
|
|
30
33
|
_streamResponseChunks(_input: string, _options: this["ParsedCallOptions"], _runManager?: CallbackManagerForLLMRun): AsyncGenerator<GenerationChunk>;
|
|
31
34
|
protected _separateRunnableConfigFromCallOptionsCompat(options?: Partial<CallOptions>): [RunnableConfig, this["ParsedCallOptions"]];
|
|
32
35
|
_streamIterator(input: BaseLanguageModelInput, options?: CallOptions): AsyncGenerator<string>;
|
|
@@ -46,6 +49,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
46
49
|
/**
|
|
47
50
|
* Get the parameters used to invoke the model
|
|
48
51
|
*/
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
53
|
invocationParams(_options?: this["ParsedCallOptions"]): any;
|
|
50
54
|
_flattenLLMResult(llmResult: LLMResult): LLMResult[];
|
|
51
55
|
/** @ignore */
|
|
@@ -61,6 +65,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
61
65
|
prompts: string[];
|
|
62
66
|
cache: BaseCache<Generation[]>;
|
|
63
67
|
llmStringKey: string;
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
69
|
parsedOptions: any;
|
|
65
70
|
handledOptions: RunnableConfig;
|
|
66
71
|
runId?: string;
|
|
@@ -75,6 +80,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
75
80
|
/**
|
|
76
81
|
* Get the identifying parameters of the LLM.
|
|
77
82
|
*/
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
84
|
_identifyingParams(): Record<string, any>;
|
|
79
85
|
/**
|
|
80
86
|
* Return the string type key uniquely identifying this class of LLM.
|
|
@@ -17,7 +17,9 @@ interface BaseLLMCallOptions extends BaseLanguageModelCallOptions {}
|
|
|
17
17
|
* LLM Wrapper. Takes in a prompt (or prompts) and returns a string.
|
|
18
18
|
*/
|
|
19
19
|
declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMCallOptions> extends BaseLanguageModel<string, CallOptions> {
|
|
20
|
+
// Backwards compatibility since fields have been moved to RunnableConfig
|
|
20
21
|
ParsedCallOptions: Omit<CallOptions, Exclude<keyof RunnableConfig, "signal" | "timeout" | "maxConcurrency">>;
|
|
22
|
+
// Only ever instantiated in main LangChain
|
|
21
23
|
lc_namespace: string[];
|
|
22
24
|
/**
|
|
23
25
|
* This method takes an input and options, and returns a string. It
|
|
@@ -28,6 +30,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
28
30
|
* @returns A string result based on the prompt.
|
|
29
31
|
*/
|
|
30
32
|
invoke(input: BaseLanguageModelInput, options?: CallOptions): Promise<string>;
|
|
33
|
+
// eslint-disable-next-line require-yield
|
|
31
34
|
_streamResponseChunks(_input: string, _options: this["ParsedCallOptions"], _runManager?: CallbackManagerForLLMRun): AsyncGenerator<GenerationChunk>;
|
|
32
35
|
protected _separateRunnableConfigFromCallOptionsCompat(options?: Partial<CallOptions>): [RunnableConfig, this["ParsedCallOptions"]];
|
|
33
36
|
_streamIterator(input: BaseLanguageModelInput, options?: CallOptions): AsyncGenerator<string>;
|
|
@@ -47,6 +50,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
47
50
|
/**
|
|
48
51
|
* Get the parameters used to invoke the model
|
|
49
52
|
*/
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
54
|
invocationParams(_options?: this["ParsedCallOptions"]): any;
|
|
51
55
|
_flattenLLMResult(llmResult: LLMResult): LLMResult[];
|
|
52
56
|
/** @ignore */
|
|
@@ -62,6 +66,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
62
66
|
prompts: string[];
|
|
63
67
|
cache: BaseCache<Generation[]>;
|
|
64
68
|
llmStringKey: string;
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
70
|
parsedOptions: any;
|
|
66
71
|
handledOptions: RunnableConfig;
|
|
67
72
|
runId?: string;
|
|
@@ -76,6 +81,7 @@ declare abstract class BaseLLM<CallOptions extends BaseLLMCallOptions = BaseLLMC
|
|
|
76
81
|
/**
|
|
77
82
|
* Get the identifying parameters of the LLM.
|
|
78
83
|
*/
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
85
|
_identifyingParams(): Record<string, any>;
|
|
80
86
|
/**
|
|
81
87
|
* Return the string type key uniquely identifying this class of LLM.
|
package/dist/load/map_keys.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const decamelize = require_rolldown_runtime.__toESM(require("decamelize"));
|
|
3
|
+
const camelcase = require_rolldown_runtime.__toESM(require("camelcase"));
|
|
3
4
|
|
|
4
5
|
//#region src/load/map_keys.ts
|
|
5
6
|
function keyToJson(key, map) {
|
|
6
|
-
return map?.[key] ||
|
|
7
|
+
return map?.[key] || (0, decamelize.default)(key);
|
|
7
8
|
}
|
|
8
9
|
function keyFromJson(key, map) {
|
|
9
|
-
return map?.[key] ||
|
|
10
|
+
return map?.[key] || (0, camelcase.default)(key);
|
|
10
11
|
}
|
|
11
12
|
function mapKeys(fields, mapper, map) {
|
|
12
13
|
const mapped = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map_keys.cjs","names":["key: string","map?: SerializedKeyAlias","
|
|
1
|
+
{"version":3,"file":"map_keys.cjs","names":["key: string","map?: SerializedKeyAlias","fields: SerializedFields","mapper: typeof keyToJson","mapped: SerializedFields"],"sources":["../../src/load/map_keys.ts"],"sourcesContent":["import snakeCase from \"decamelize\";\nimport camelCase from \"camelcase\";\n\nexport interface SerializedFields {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n}\n\nexport interface SerializedKeyAlias {\n [key: string]: string;\n}\n\nexport function keyToJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || snakeCase(key);\n}\n\nexport function keyFromJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || camelCase(key);\n}\n\nexport function mapKeys(\n fields: SerializedFields,\n mapper: typeof keyToJson,\n map?: SerializedKeyAlias\n): SerializedFields {\n const mapped: SerializedFields = {};\n\n for (const key in fields) {\n if (Object.hasOwn(fields, key)) {\n mapped[mapper(key, map)] = fields[key];\n }\n }\n\n return mapped;\n}\n"],"mappings":";;;;;AAYA,SAAgB,UAAUA,KAAaC,KAAkC;AACvE,QAAO,MAAM,gCAAkB,IAAI;AACpC;AAED,SAAgB,YAAYD,KAAaC,KAAkC;AACzE,QAAO,MAAM,+BAAkB,IAAI;AACpC;AAED,SAAgB,QACdC,QACAC,QACAF,KACkB;CAClB,MAAMG,SAA2B,CAAE;AAEnC,MAAK,MAAM,OAAO,OAChB,KAAI,OAAO,OAAO,QAAQ,IAAI,EAC5B,OAAO,OAAO,KAAK,IAAI,IAAI,OAAO;AAItC,QAAO;AACR"}
|