@langchain/core 1.1.1 → 1.1.3
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 +16 -0
- package/dist/agents.d.cts +0 -2
- package/dist/agents.d.ts +0 -2
- package/dist/callbacks/base.d.cts +22 -60
- package/dist/callbacks/base.d.ts +22 -60
- package/dist/callbacks/dispatch/index.d.cts +1 -3
- package/dist/callbacks/dispatch/index.d.ts +1 -3
- package/dist/callbacks/dispatch/web.d.cts +1 -3
- package/dist/callbacks/dispatch/web.d.ts +1 -3
- package/dist/callbacks/manager.d.cts +2 -12
- package/dist/callbacks/manager.d.ts +2 -12
- package/dist/chat_history.cjs +1 -1
- package/dist/chat_history.d.cts +0 -1
- package/dist/chat_history.d.ts +0 -1
- package/dist/chat_history.js +1 -1
- package/dist/document_loaders/langsmith.d.cts +0 -3
- package/dist/document_loaders/langsmith.d.ts +0 -3
- package/dist/documents/document.d.cts +3 -12
- package/dist/documents/document.d.ts +3 -12
- 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 +0 -1
- package/dist/indexing/base.d.ts +0 -1
- package/dist/indexing/record_manager.d.cts +0 -1
- package/dist/indexing/record_manager.d.ts +0 -1
- package/dist/language_models/base.d.cts +8 -38
- package/dist/language_models/base.d.ts +8 -38
- package/dist/language_models/chat_models.cjs +1 -1
- package/dist/language_models/chat_models.d.cts +6 -33
- package/dist/language_models/chat_models.d.ts +6 -33
- package/dist/language_models/chat_models.js +1 -1
- package/dist/language_models/llms.d.cts +0 -6
- package/dist/language_models/llms.d.ts +0 -6
- package/dist/load/import_type.d.cts +0 -1
- package/dist/load/import_type.d.ts +0 -1
- package/dist/load/map_keys.cjs +4 -5
- package/dist/load/map_keys.cjs.map +1 -1
- package/dist/load/map_keys.d.cts +0 -1
- package/dist/load/map_keys.d.ts +0 -1
- package/dist/load/map_keys.js +3 -3
- package/dist/load/map_keys.js.map +1 -1
- package/dist/load/serializable.d.cts +0 -1
- package/dist/load/serializable.d.ts +0 -1
- package/dist/memory.d.cts +0 -3
- package/dist/memory.d.ts +0 -3
- package/dist/messages/ai.cjs +6 -48
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.js +6 -48
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +3 -2
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +1 -13
- package/dist/messages/base.d.ts +1 -13
- package/dist/messages/base.js +3 -2
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/content/data.d.cts +2 -7
- package/dist/messages/content/data.d.ts +2 -7
- package/dist/messages/content/index.d.cts +1 -4
- package/dist/messages/content/index.d.ts +1 -4
- package/dist/messages/content/multimodal.d.cts +0 -1
- package/dist/messages/content/multimodal.d.ts +0 -1
- package/dist/messages/content/tools.d.cts +0 -1
- package/dist/messages/content/tools.d.ts +0 -1
- package/dist/messages/index.cjs +4 -2
- package/dist/messages/index.d.cts +2 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.js +5 -4
- package/dist/messages/tool.d.cts +2 -9
- package/dist/messages/tool.d.ts +2 -9
- package/dist/messages/transformers.cjs +2 -2
- package/dist/messages/transformers.d.cts +0 -3
- package/dist/messages/transformers.d.ts +0 -3
- package/dist/messages/transformers.js +2 -2
- package/dist/messages/utils.cjs +77 -4
- package/dist/messages/utils.cjs.map +1 -1
- package/dist/messages/utils.d.cts +35 -7
- package/dist/messages/utils.d.ts +35 -7
- package/dist/messages/utils.js +77 -5
- package/dist/messages/utils.js.map +1 -1
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +169 -0
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +168 -0
- package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +1 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +122 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +121 -0
- package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +1 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +18 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +17 -0
- package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +1 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs +27 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js +26 -0
- package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +1 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs +141 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js +141 -0
- package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js.map +1 -0
- package/dist/output_parsers/json.cjs.map +1 -1
- package/dist/output_parsers/json.d.cts +1 -5
- package/dist/output_parsers/json.d.ts +1 -5
- package/dist/output_parsers/json.js.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +2 -6
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +2 -6
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +10 -34
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +10 -34
- package/dist/output_parsers/transform.d.cts +0 -1
- package/dist/output_parsers/transform.d.ts +0 -1
- package/dist/outputs.d.cts +0 -6
- package/dist/outputs.d.ts +0 -6
- package/dist/prompts/base.d.cts +2 -10
- package/dist/prompts/base.d.ts +2 -10
- package/dist/prompts/chat.cjs +2 -2
- package/dist/prompts/chat.d.cts +13 -51
- package/dist/prompts/chat.d.ts +13 -51
- package/dist/prompts/chat.js +2 -2
- package/dist/prompts/few_shot.d.cts +1 -5
- package/dist/prompts/few_shot.d.ts +1 -5
- package/dist/prompts/image.d.cts +2 -10
- package/dist/prompts/image.d.ts +2 -10
- package/dist/prompts/prompt.d.cts +4 -15
- package/dist/prompts/prompt.d.ts +4 -16
- package/dist/prompts/serde.d.cts +0 -1
- package/dist/prompts/serde.d.ts +0 -1
- package/dist/prompts/string.d.cts +1 -5
- package/dist/prompts/string.d.ts +1 -5
- package/dist/prompts/structured.d.cts +3 -16
- package/dist/prompts/structured.d.ts +3 -16
- package/dist/retrievers/document_compressors/index.d.cts +0 -1
- package/dist/retrievers/document_compressors/index.d.ts +0 -1
- package/dist/retrievers/index.d.cts +2 -6
- package/dist/retrievers/index.d.ts +2 -6
- package/dist/runnables/base.cjs +7 -7
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +12 -64
- package/dist/runnables/base.d.ts +12 -64
- package/dist/runnables/base.js +1 -1
- package/dist/runnables/branch.d.cts +0 -2
- package/dist/runnables/branch.d.ts +0 -2
- package/dist/runnables/config.d.cts +0 -1
- package/dist/runnables/config.d.ts +0 -1
- package/dist/runnables/graph.d.cts +1 -5
- package/dist/runnables/graph.d.ts +1 -5
- package/dist/runnables/graph_mermaid.cjs +2 -1
- package/dist/runnables/graph_mermaid.cjs.map +1 -1
- package/dist/runnables/graph_mermaid.js +3 -1
- package/dist/runnables/graph_mermaid.js.map +1 -1
- package/dist/runnables/history.cjs +1 -1
- package/dist/runnables/history.d.cts +4 -12
- package/dist/runnables/history.d.ts +4 -12
- package/dist/runnables/history.js +1 -1
- package/dist/runnables/passthrough.d.cts +0 -2
- package/dist/runnables/passthrough.d.ts +0 -2
- package/dist/runnables/router.d.cts +0 -1
- package/dist/runnables/router.d.ts +0 -1
- package/dist/runnables/types.d.cts +2 -9
- package/dist/runnables/types.d.ts +2 -9
- package/dist/runnables/utils.cjs +5 -0
- package/dist/runnables/utils.cjs.map +1 -1
- package/dist/runnables/utils.js +5 -1
- package/dist/runnables/utils.js.map +1 -1
- package/dist/singletons/async_local_storage/context.d.cts +0 -2
- package/dist/singletons/async_local_storage/context.d.ts +0 -2
- package/dist/singletons/async_local_storage/globals.d.cts +0 -1
- package/dist/singletons/async_local_storage/globals.d.ts +0 -1
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/stores.d.cts +0 -1
- package/dist/stores.d.ts +0 -1
- package/dist/structured_query/utils.d.cts +1 -4
- package/dist/structured_query/utils.d.ts +1 -4
- package/dist/tools/index.d.cts +1 -6
- package/dist/tools/index.d.ts +1 -6
- package/dist/tools/types.d.cts +3 -13
- package/dist/tools/types.d.ts +3 -13
- package/dist/tracers/base.d.cts +1 -20
- package/dist/tracers/base.d.ts +1 -20
- package/dist/tracers/console.cjs +3 -3
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.d.cts +0 -2
- package/dist/tracers/console.d.ts +0 -2
- package/dist/tracers/console.js +3 -3
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.d.cts +0 -4
- package/dist/tracers/event_stream.d.ts +0 -4
- package/dist/tracers/log_stream.d.cts +0 -6
- package/dist/tracers/log_stream.d.ts +0 -6
- package/dist/types/_internal.d.cts +0 -3
- package/dist/types/_internal.d.ts +0 -3
- package/dist/types/type-utils.d.cts +0 -2
- package/dist/types/type-utils.d.ts +0 -2
- package/dist/utils/async_caller.cjs +2 -7
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.d.cts +0 -3
- package/dist/utils/async_caller.d.ts +0 -3
- package/dist/utils/async_caller.js +1 -6
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/env.d.cts +0 -4
- package/dist/utils/env.d.ts +0 -4
- package/dist/utils/event_source_parse.d.cts +1 -4
- package/dist/utils/event_source_parse.d.ts +1 -4
- package/dist/utils/function_calling.d.cts +1 -3
- package/dist/utils/function_calling.d.ts +1 -3
- package/dist/utils/json.cjs +182 -22
- package/dist/utils/json.cjs.map +1 -1
- package/dist/utils/json.d.cts +1 -3
- package/dist/utils/json.d.ts +1 -3
- package/dist/utils/json.js +182 -22
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/stream.d.cts +1 -13
- package/dist/utils/stream.d.ts +1 -13
- package/dist/utils/testing/chat_models.d.cts +3 -11
- package/dist/utils/testing/chat_models.d.ts +3 -11
- package/dist/utils/testing/message_history.cjs +1 -1
- package/dist/utils/testing/message_history.js +1 -1
- package/dist/utils/testing/retrievers.d.cts +1 -3
- package/dist/utils/testing/retrievers.d.ts +1 -3
- package/dist/utils/testing/vectorstores.d.cts +0 -1
- package/dist/utils/testing/vectorstores.d.ts +0 -1
- package/dist/utils/types/index.cjs +4 -0
- package/dist/utils/types/index.d.cts +2 -4
- package/dist/utils/types/index.d.ts +2 -4
- package/dist/utils/types/index.js +4 -2
- package/dist/utils/types/zod.cjs +24 -0
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.d.cts +4 -4
- package/dist/utils/types/zod.d.ts +4 -4
- package/dist/utils/types/zod.js +23 -1
- package/dist/utils/types/zod.js.map +1 -1
- package/dist/vectorstores.d.cts +5 -17
- package/dist/vectorstores.d.ts +5 -17
- package/package.json +6 -6
|
@@ -8,17 +8,13 @@ import { parseJsonMarkdown, parsePartialJson } from "../utils/json.cjs";
|
|
|
8
8
|
/**
|
|
9
9
|
* Class for parsing the output of an LLM into a JSON object.
|
|
10
10
|
*/
|
|
11
|
-
declare class JsonOutputParser<
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {
|
|
11
|
+
declare class JsonOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {
|
|
14
12
|
static lc_name(): string;
|
|
15
13
|
lc_namespace: string[];
|
|
16
14
|
lc_serializable: boolean;
|
|
17
15
|
/** @internal */
|
|
18
16
|
_concatOutputChunks<T>(first: T, second: T): T;
|
|
19
17
|
protected _diff(prev: unknown | undefined, next: unknown): Operation[] | undefined;
|
|
20
|
-
// This should actually return Partial<T>, but there's no way
|
|
21
|
-
// to specify emitted chunks as instances separate from the main output type.
|
|
22
18
|
parsePartialResult(generations: ChatGeneration[] | Generation[]): Promise<T | undefined>;
|
|
23
19
|
parse(text: string): Promise<T>;
|
|
24
20
|
getFormatInstructions(): string;
|
|
@@ -8,17 +8,13 @@ import { parseJsonMarkdown, parsePartialJson } from "../utils/json.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Class for parsing the output of an LLM into a JSON object.
|
|
10
10
|
*/
|
|
11
|
-
declare class JsonOutputParser<
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {
|
|
11
|
+
declare class JsonOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {
|
|
14
12
|
static lc_name(): string;
|
|
15
13
|
lc_namespace: string[];
|
|
16
14
|
lc_serializable: boolean;
|
|
17
15
|
/** @internal */
|
|
18
16
|
_concatOutputChunks<T>(first: T, second: T): T;
|
|
19
17
|
protected _diff(prev: unknown | undefined, next: unknown): Operation[] | undefined;
|
|
20
|
-
// This should actually return Partial<T>, but there's no way
|
|
21
|
-
// to specify emitted chunks as instances separate from the main output type.
|
|
22
18
|
parsePartialResult(generations: ChatGeneration[] | Generation[]): Promise<T | undefined>;
|
|
23
19
|
parse(text: string): Promise<T>;
|
|
24
20
|
getFormatInstructions(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","names":["first: T","second: T","prev: unknown | undefined","next: unknown","generations: ChatGeneration[] | Generation[]","text: string"],"sources":["../../src/output_parsers/json.ts"],"sourcesContent":["import { BaseCumulativeTransformOutputParser } from \"./transform.js\";\nimport { Operation, compare } from \"../utils/json_patch.js\";\nimport { ChatGeneration, Generation } from \"../outputs.js\";\nimport { parseJsonMarkdown, parsePartialJson } from \"../utils/json.js\";\n\n/**\n * Class for parsing the output of an LLM into a JSON object.\n */\nexport class JsonOutputParser<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n> extends BaseCumulativeTransformOutputParser<T> {\n static lc_name() {\n return \"JsonOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\"];\n\n lc_serializable = true;\n\n /** @internal */\n override _concatOutputChunks<T>(first: T, second: T): T {\n if (this.diff) {\n return super._concatOutputChunks(first, second);\n }\n return second;\n }\n\n protected _diff(\n prev: unknown | undefined,\n next: unknown\n ): Operation[] | undefined {\n if (!next) {\n return undefined;\n }\n if (!prev) {\n return [{ op: \"replace\", path: \"\", value: next }];\n }\n return compare(prev, next);\n }\n\n // This should actually return Partial<T>, but there's no way\n // to specify emitted chunks as instances separate from the main output type.\n async parsePartialResult(\n generations: ChatGeneration[] | Generation[]\n ): Promise<T | undefined> {\n return parseJsonMarkdown(generations[0].text);\n }\n\n async parse(text: string): Promise<T> {\n return parseJsonMarkdown(text, JSON.parse);\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n}\n\nexport { parsePartialJson, parseJsonMarkdown };\n"],"mappings":";;;;;;;;;AAQA,IAAa,mBAAb,cAGU,oCAAuC;CAC/C,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe,CAAC,kBAAkB,gBAAiB;CAEnD,kBAAkB;;CAGlB,AAAS,oBAAuBA,OAAUC,QAAc;AACtD,MAAI,KAAK,KACP,QAAO,MAAM,oBAAoB,OAAO,OAAO;AAEjD,SAAO;CACR;CAED,AAAU,MACRC,MACAC,MACyB;AACzB,MAAI,CAAC,KACH,QAAO;AAET,MAAI,CAAC,KACH,QAAO,CAAC;GAAE,IAAI;GAAW,MAAM;GAAI,OAAO;EAAM,CAAC;AAEnD,SAAO,QAAQ,MAAM,KAAK;CAC3B;CAID,MAAM,mBACJC,aACwB;AACxB,SAAO,kBAAkB,YAAY,GAAG,KAAK;CAC9C;CAED,MAAM,MAAMC,MAA0B;AACpC,SAAO,kBAAkB,MAAM,KAAK,MAAM;CAC3C;CAED,wBAAgC;AAC9B,SAAO;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"json.js","names":["first: T","second: T","prev: unknown | undefined","next: unknown","generations: ChatGeneration[] | Generation[]","text: string"],"sources":["../../src/output_parsers/json.ts"],"sourcesContent":["import { BaseCumulativeTransformOutputParser } from \"./transform.js\";\nimport { Operation, compare } from \"../utils/json_patch.js\";\nimport { ChatGeneration, Generation } from \"../outputs.js\";\nimport { parseJsonMarkdown, parsePartialJson } from \"../utils/json.js\";\n\n/**\n * Class for parsing the output of an LLM into a JSON object.\n */\nexport class JsonOutputParser<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n> extends BaseCumulativeTransformOutputParser<T> {\n static lc_name() {\n return \"JsonOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\"];\n\n lc_serializable = true;\n\n /** @internal */\n override _concatOutputChunks<T>(first: T, second: T): T {\n if (this.diff) {\n return super._concatOutputChunks(first, second);\n }\n return second;\n }\n\n protected _diff(\n prev: unknown | undefined,\n next: unknown\n ): Operation[] | undefined {\n if (!next) {\n return undefined;\n }\n if (!prev) {\n return [{ op: \"replace\", path: \"\", value: next }];\n }\n return compare(prev, next);\n }\n\n // This should actually return Partial<T>, but there's no way\n // to specify emitted chunks as instances separate from the main output type.\n async parsePartialResult(\n generations: ChatGeneration[] | Generation[]\n ): Promise<T | undefined> {\n return parseJsonMarkdown(generations[0].text) as T | undefined;\n }\n\n async parse(text: string): Promise<T> {\n return parseJsonMarkdown(text, JSON.parse) as T;\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n}\n\nexport { parsePartialJson, parseJsonMarkdown };\n"],"mappings":";;;;;;;;;AAQA,IAAa,mBAAb,cAGU,oCAAuC;CAC/C,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe,CAAC,kBAAkB,gBAAiB;CAEnD,kBAAkB;;CAGlB,AAAS,oBAAuBA,OAAUC,QAAc;AACtD,MAAI,KAAK,KACP,QAAO,MAAM,oBAAoB,OAAO,OAAO;AAEjD,SAAO;CACR;CAED,AAAU,MACRC,MACAC,MACyB;AACzB,MAAI,CAAC,KACH,QAAO;AAET,MAAI,CAAC,KACH,QAAO,CAAC;GAAE,IAAI;GAAW,MAAM;GAAI,OAAO;EAAM,CAAC;AAEnD,SAAO,QAAQ,MAAM,KAAK;CAC3B;CAID,MAAM,mBACJC,aACwB;AACxB,SAAO,kBAAkB,YAAY,GAAG,KAAK;CAC9C;CAED,MAAM,MAAMC,MAA0B;AACpC,SAAO,kBAAkB,MAAM,KAAK,MAAM;CAC3C;CAED,wBAAgC;AAC9B,SAAO;CACR;AACF"}
|
|
@@ -35,9 +35,7 @@ declare class OutputFunctionsParser extends BaseLLMOutputParser<string> {
|
|
|
35
35
|
* Class for parsing the output of an LLM into a JSON object. Uses an
|
|
36
36
|
* instance of `OutputFunctionsParser` to parse the output.
|
|
37
37
|
*/
|
|
38
|
-
declare class JsonOutputFunctionsParser<
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
Output extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<Output> {
|
|
38
|
+
declare class JsonOutputFunctionsParser<Output extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<Output> {
|
|
41
39
|
static lc_name(): string;
|
|
42
40
|
lc_namespace: string[];
|
|
43
41
|
lc_serializable: boolean;
|
|
@@ -63,9 +61,7 @@ Output extends Record<string, any> = Record<string, any>> extends BaseCumulative
|
|
|
63
61
|
* a specific attribute. Uses an instance of `JsonOutputFunctionsParser`
|
|
64
62
|
* to parse the output.
|
|
65
63
|
*/
|
|
66
|
-
declare class JsonKeyOutputFunctionsParser<
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
T extends Record<string, any> = Record<string, any>> extends BaseLLMOutputParser<T> {
|
|
64
|
+
declare class JsonKeyOutputFunctionsParser<T extends Record<string, any> = Record<string, any>> extends BaseLLMOutputParser<T> {
|
|
69
65
|
static lc_name(): string;
|
|
70
66
|
lc_namespace: string[];
|
|
71
67
|
lc_serializable: boolean;
|
|
@@ -35,9 +35,7 @@ declare class OutputFunctionsParser extends BaseLLMOutputParser<string> {
|
|
|
35
35
|
* Class for parsing the output of an LLM into a JSON object. Uses an
|
|
36
36
|
* instance of `OutputFunctionsParser` to parse the output.
|
|
37
37
|
*/
|
|
38
|
-
declare class JsonOutputFunctionsParser<
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
Output extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<Output> {
|
|
38
|
+
declare class JsonOutputFunctionsParser<Output extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<Output> {
|
|
41
39
|
static lc_name(): string;
|
|
42
40
|
lc_namespace: string[];
|
|
43
41
|
lc_serializable: boolean;
|
|
@@ -63,9 +61,7 @@ Output extends Record<string, any> = Record<string, any>> extends BaseCumulative
|
|
|
63
61
|
* a specific attribute. Uses an instance of `JsonOutputFunctionsParser`
|
|
64
62
|
* to parse the output.
|
|
65
63
|
*/
|
|
66
|
-
declare class JsonKeyOutputFunctionsParser<
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
T extends Record<string, any> = Record<string, any>> extends BaseLLMOutputParser<T> {
|
|
64
|
+
declare class JsonKeyOutputFunctionsParser<T extends Record<string, any> = Record<string, any>> extends BaseLLMOutputParser<T> {
|
|
69
65
|
static lc_name(): string;
|
|
70
66
|
lc_namespace: string[];
|
|
71
67
|
lc_serializable: boolean;
|
|
@@ -9,28 +9,21 @@ import * as z4 from "zod/v4/core";
|
|
|
9
9
|
type ParsedToolCall = {
|
|
10
10
|
id?: string;
|
|
11
11
|
type: string;
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
12
|
args: Record<string, any>;
|
|
14
13
|
};
|
|
15
14
|
type JsonOutputToolsParserParams = {
|
|
16
15
|
/** Whether to return the tool call id. */
|
|
17
16
|
returnId?: boolean;
|
|
18
17
|
} & BaseCumulativeTransformOutputParserInput;
|
|
19
|
-
declare function parseToolCall(
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
rawToolCall: Record<string, any>, options: {
|
|
18
|
+
declare function parseToolCall(rawToolCall: Record<string, any>, options: {
|
|
22
19
|
returnId?: boolean;
|
|
23
20
|
partial: true;
|
|
24
21
|
}): ToolCall | undefined;
|
|
25
|
-
declare function parseToolCall(
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
rawToolCall: Record<string, any>, options?: {
|
|
22
|
+
declare function parseToolCall(rawToolCall: Record<string, any>, options?: {
|
|
28
23
|
returnId?: boolean;
|
|
29
24
|
partial?: false;
|
|
30
25
|
}): ToolCall;
|
|
31
|
-
declare function parseToolCall(
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
rawToolCall: Record<string, any>, options?: {
|
|
26
|
+
declare function parseToolCall(rawToolCall: Record<string, any>, options?: {
|
|
34
27
|
returnId?: boolean;
|
|
35
28
|
partial?: boolean;
|
|
36
29
|
}): ToolCall | undefined;
|
|
@@ -42,9 +35,7 @@ declare function convertLangChainToolCallToOpenAI(toolCall: ToolCall): {
|
|
|
42
35
|
arguments: string;
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
|
-
declare function makeInvalidToolCall(
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
rawToolCall: Record<string, any>, errorMsg?: string): InvalidToolCall;
|
|
38
|
+
declare function makeInvalidToolCall(rawToolCall: Record<string, any>, errorMsg?: string): InvalidToolCall;
|
|
48
39
|
/**
|
|
49
40
|
* Class for parsing the output of a tool-calling LLM into a JSON object.
|
|
50
41
|
*/
|
|
@@ -63,40 +54,27 @@ declare class JsonOutputToolsParser<T> extends BaseCumulativeTransformOutputPars
|
|
|
63
54
|
* @param generations The output of the LLM to parse.
|
|
64
55
|
* @returns A JSON object representation of the function call or its arguments.
|
|
65
56
|
*/
|
|
66
|
-
parsePartialResult(generations: ChatGenerationChunk[] | ChatGeneration[], partial?: boolean
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
): Promise<any>;
|
|
57
|
+
parsePartialResult(generations: ChatGenerationChunk[] | ChatGeneration[], partial?: boolean): Promise<any>;
|
|
69
58
|
}
|
|
70
59
|
type JsonOutputKeyToolsParserParamsBase = {
|
|
71
60
|
keyName: string;
|
|
72
61
|
returnSingle?: boolean;
|
|
73
62
|
} & JsonOutputToolsParserParams;
|
|
74
|
-
type JsonOutputKeyToolsParserParamsV3<
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
-
T extends Record<string, any> = Record<string, any>> = {
|
|
63
|
+
type JsonOutputKeyToolsParserParamsV3<T extends Record<string, any> = Record<string, any>> = {
|
|
77
64
|
zodSchema?: z3.ZodType<T>;
|
|
78
65
|
} & JsonOutputKeyToolsParserParamsBase;
|
|
79
|
-
type JsonOutputKeyToolsParserParamsV4<
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
T extends Record<string, any> = Record<string, any>> = {
|
|
66
|
+
type JsonOutputKeyToolsParserParamsV4<T extends Record<string, any> = Record<string, any>> = {
|
|
82
67
|
zodSchema?: z4.$ZodType<T, T>;
|
|
83
68
|
} & JsonOutputKeyToolsParserParamsBase;
|
|
84
|
-
type JsonOutputKeyToolsParserParamsInterop<
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
T extends Record<string, any> = Record<string, any>> = {
|
|
69
|
+
type JsonOutputKeyToolsParserParamsInterop<T extends Record<string, any> = Record<string, any>> = {
|
|
87
70
|
zodSchema?: InteropZodType<T>;
|
|
88
71
|
} & JsonOutputKeyToolsParserParamsBase;
|
|
89
|
-
|
|
90
|
-
type JsonOutputKeyToolsParserParams<
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
T extends Record<string, any> = Record<string, any>> = JsonOutputKeyToolsParserParamsV3<T>;
|
|
72
|
+
type JsonOutputKeyToolsParserParams<T extends Record<string, any> = Record<string, any>> = JsonOutputKeyToolsParserParamsV3<T>;
|
|
93
73
|
/**
|
|
94
74
|
* Class for parsing the output of a tool-calling LLM into a JSON object if you are
|
|
95
75
|
* expecting only a single tool to be called.
|
|
96
76
|
*/
|
|
97
|
-
declare class JsonOutputKeyToolsParser<
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
T extends Record<string, any> = Record<string, any>> extends JsonOutputToolsParser<T> {
|
|
77
|
+
declare class JsonOutputKeyToolsParser<T extends Record<string, any> = Record<string, any>> extends JsonOutputToolsParser<T> {
|
|
100
78
|
static lc_name(): string;
|
|
101
79
|
lc_namespace: string[];
|
|
102
80
|
lc_serializable: boolean;
|
|
@@ -110,9 +88,7 @@ T extends Record<string, any> = Record<string, any>> extends JsonOutputToolsPars
|
|
|
110
88
|
constructor(params: JsonOutputKeyToolsParserParamsV4<T>);
|
|
111
89
|
constructor(params: JsonOutputKeyToolsParserParamsInterop<T>);
|
|
112
90
|
protected _validateResult(result: unknown): Promise<T>;
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
91
|
parsePartialResult(generations: ChatGeneration[]): Promise<any>;
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
92
|
parseResult(generations: ChatGeneration[]): Promise<any>;
|
|
117
93
|
}
|
|
118
94
|
//#endregion
|
|
@@ -9,28 +9,21 @@ import * as z4 from "zod/v4/core";
|
|
|
9
9
|
type ParsedToolCall = {
|
|
10
10
|
id?: string;
|
|
11
11
|
type: string;
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
12
|
args: Record<string, any>;
|
|
14
13
|
};
|
|
15
14
|
type JsonOutputToolsParserParams = {
|
|
16
15
|
/** Whether to return the tool call id. */
|
|
17
16
|
returnId?: boolean;
|
|
18
17
|
} & BaseCumulativeTransformOutputParserInput;
|
|
19
|
-
declare function parseToolCall(
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
rawToolCall: Record<string, any>, options: {
|
|
18
|
+
declare function parseToolCall(rawToolCall: Record<string, any>, options: {
|
|
22
19
|
returnId?: boolean;
|
|
23
20
|
partial: true;
|
|
24
21
|
}): ToolCall | undefined;
|
|
25
|
-
declare function parseToolCall(
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
rawToolCall: Record<string, any>, options?: {
|
|
22
|
+
declare function parseToolCall(rawToolCall: Record<string, any>, options?: {
|
|
28
23
|
returnId?: boolean;
|
|
29
24
|
partial?: false;
|
|
30
25
|
}): ToolCall;
|
|
31
|
-
declare function parseToolCall(
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
rawToolCall: Record<string, any>, options?: {
|
|
26
|
+
declare function parseToolCall(rawToolCall: Record<string, any>, options?: {
|
|
34
27
|
returnId?: boolean;
|
|
35
28
|
partial?: boolean;
|
|
36
29
|
}): ToolCall | undefined;
|
|
@@ -42,9 +35,7 @@ declare function convertLangChainToolCallToOpenAI(toolCall: ToolCall): {
|
|
|
42
35
|
arguments: string;
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
|
-
declare function makeInvalidToolCall(
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
rawToolCall: Record<string, any>, errorMsg?: string): InvalidToolCall;
|
|
38
|
+
declare function makeInvalidToolCall(rawToolCall: Record<string, any>, errorMsg?: string): InvalidToolCall;
|
|
48
39
|
/**
|
|
49
40
|
* Class for parsing the output of a tool-calling LLM into a JSON object.
|
|
50
41
|
*/
|
|
@@ -63,40 +54,27 @@ declare class JsonOutputToolsParser<T> extends BaseCumulativeTransformOutputPars
|
|
|
63
54
|
* @param generations The output of the LLM to parse.
|
|
64
55
|
* @returns A JSON object representation of the function call or its arguments.
|
|
65
56
|
*/
|
|
66
|
-
parsePartialResult(generations: ChatGenerationChunk[] | ChatGeneration[], partial?: boolean
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
): Promise<any>;
|
|
57
|
+
parsePartialResult(generations: ChatGenerationChunk[] | ChatGeneration[], partial?: boolean): Promise<any>;
|
|
69
58
|
}
|
|
70
59
|
type JsonOutputKeyToolsParserParamsBase = {
|
|
71
60
|
keyName: string;
|
|
72
61
|
returnSingle?: boolean;
|
|
73
62
|
} & JsonOutputToolsParserParams;
|
|
74
|
-
type JsonOutputKeyToolsParserParamsV3<
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
-
T extends Record<string, any> = Record<string, any>> = {
|
|
63
|
+
type JsonOutputKeyToolsParserParamsV3<T extends Record<string, any> = Record<string, any>> = {
|
|
77
64
|
zodSchema?: z3.ZodType<T>;
|
|
78
65
|
} & JsonOutputKeyToolsParserParamsBase;
|
|
79
|
-
type JsonOutputKeyToolsParserParamsV4<
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
T extends Record<string, any> = Record<string, any>> = {
|
|
66
|
+
type JsonOutputKeyToolsParserParamsV4<T extends Record<string, any> = Record<string, any>> = {
|
|
82
67
|
zodSchema?: z4.$ZodType<T, T>;
|
|
83
68
|
} & JsonOutputKeyToolsParserParamsBase;
|
|
84
|
-
type JsonOutputKeyToolsParserParamsInterop<
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
T extends Record<string, any> = Record<string, any>> = {
|
|
69
|
+
type JsonOutputKeyToolsParserParamsInterop<T extends Record<string, any> = Record<string, any>> = {
|
|
87
70
|
zodSchema?: InteropZodType<T>;
|
|
88
71
|
} & JsonOutputKeyToolsParserParamsBase;
|
|
89
|
-
|
|
90
|
-
type JsonOutputKeyToolsParserParams<
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
T extends Record<string, any> = Record<string, any>> = JsonOutputKeyToolsParserParamsV3<T>;
|
|
72
|
+
type JsonOutputKeyToolsParserParams<T extends Record<string, any> = Record<string, any>> = JsonOutputKeyToolsParserParamsV3<T>;
|
|
93
73
|
/**
|
|
94
74
|
* Class for parsing the output of a tool-calling LLM into a JSON object if you are
|
|
95
75
|
* expecting only a single tool to be called.
|
|
96
76
|
*/
|
|
97
|
-
declare class JsonOutputKeyToolsParser<
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
T extends Record<string, any> = Record<string, any>> extends JsonOutputToolsParser<T> {
|
|
77
|
+
declare class JsonOutputKeyToolsParser<T extends Record<string, any> = Record<string, any>> extends JsonOutputToolsParser<T> {
|
|
100
78
|
static lc_name(): string;
|
|
101
79
|
lc_namespace: string[];
|
|
102
80
|
lc_serializable: boolean;
|
|
@@ -110,9 +88,7 @@ T extends Record<string, any> = Record<string, any>> extends JsonOutputToolsPars
|
|
|
110
88
|
constructor(params: JsonOutputKeyToolsParserParamsV4<T>);
|
|
111
89
|
constructor(params: JsonOutputKeyToolsParserParamsInterop<T>);
|
|
112
90
|
protected _validateResult(result: unknown): Promise<T>;
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
91
|
parsePartialResult(generations: ChatGeneration[]): Promise<any>;
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
92
|
parseResult(generations: ChatGeneration[]): Promise<any>;
|
|
117
93
|
}
|
|
118
94
|
//#endregion
|
|
@@ -30,7 +30,6 @@ type BaseCumulativeTransformOutputParserInput = {
|
|
|
30
30
|
declare abstract class BaseCumulativeTransformOutputParser<T = unknown> extends BaseTransformOutputParser<T> {
|
|
31
31
|
protected diff: boolean;
|
|
32
32
|
constructor(fields?: BaseCumulativeTransformOutputParserInput);
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
33
|
protected abstract _diff(prev: any | undefined, next: any): any;
|
|
35
34
|
abstract parsePartialResult(generations: Generation[] | ChatGeneration[]): Promise<T | undefined>;
|
|
36
35
|
_transform(inputGenerator: AsyncGenerator<string | BaseMessage>): AsyncGenerator<T>;
|
|
@@ -30,7 +30,6 @@ type BaseCumulativeTransformOutputParserInput = {
|
|
|
30
30
|
declare abstract class BaseCumulativeTransformOutputParser<T = unknown> extends BaseTransformOutputParser<T> {
|
|
31
31
|
protected diff: boolean;
|
|
32
32
|
constructor(fields?: BaseCumulativeTransformOutputParserInput);
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
33
|
protected abstract _diff(prev: any | undefined, next: any): any;
|
|
35
34
|
abstract parsePartialResult(generations: Generation[] | ChatGeneration[]): Promise<T | undefined>;
|
|
36
35
|
_transform(inputGenerator: AsyncGenerator<string | BaseMessage>): AsyncGenerator<T>;
|
package/dist/outputs.d.cts
CHANGED
|
@@ -14,12 +14,10 @@ interface Generation {
|
|
|
14
14
|
* Raw generation info response from the provider.
|
|
15
15
|
* May include things like reason for finishing (e.g. in {@link OpenAI})
|
|
16
16
|
*/
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
17
|
generationInfo?: Record<string, any>;
|
|
19
18
|
}
|
|
20
19
|
type GenerationChunkFields = {
|
|
21
20
|
text: string;
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
21
|
generationInfo?: Record<string, any>;
|
|
24
22
|
};
|
|
25
23
|
/**
|
|
@@ -27,7 +25,6 @@ type GenerationChunkFields = {
|
|
|
27
25
|
*/
|
|
28
26
|
declare class GenerationChunk implements Generation {
|
|
29
27
|
text: string;
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
28
|
generationInfo?: Record<string, any>;
|
|
32
29
|
constructor(fields: GenerationChunkFields);
|
|
33
30
|
concat(chunk: GenerationChunk): GenerationChunk;
|
|
@@ -43,12 +40,10 @@ type LLMResult = {
|
|
|
43
40
|
/**
|
|
44
41
|
* Dictionary of arbitrary LLM-provider specific output.
|
|
45
42
|
*/
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
43
|
llmOutput?: Record<string, any>;
|
|
48
44
|
/**
|
|
49
45
|
* Dictionary of run metadata
|
|
50
46
|
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
47
|
[RUN_KEY]?: Record<string, any>;
|
|
53
48
|
};
|
|
54
49
|
interface ChatGeneration extends Generation {
|
|
@@ -64,7 +59,6 @@ declare class ChatGenerationChunk extends GenerationChunk implements ChatGenerat
|
|
|
64
59
|
}
|
|
65
60
|
interface ChatResult {
|
|
66
61
|
generations: ChatGeneration[];
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
62
|
llmOutput?: Record<string, any>;
|
|
69
63
|
}
|
|
70
64
|
//#endregion
|
package/dist/outputs.d.ts
CHANGED
|
@@ -14,12 +14,10 @@ interface Generation {
|
|
|
14
14
|
* Raw generation info response from the provider.
|
|
15
15
|
* May include things like reason for finishing (e.g. in {@link OpenAI})
|
|
16
16
|
*/
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
17
|
generationInfo?: Record<string, any>;
|
|
19
18
|
}
|
|
20
19
|
type GenerationChunkFields = {
|
|
21
20
|
text: string;
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
21
|
generationInfo?: Record<string, any>;
|
|
24
22
|
};
|
|
25
23
|
/**
|
|
@@ -27,7 +25,6 @@ type GenerationChunkFields = {
|
|
|
27
25
|
*/
|
|
28
26
|
declare class GenerationChunk implements Generation {
|
|
29
27
|
text: string;
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
28
|
generationInfo?: Record<string, any>;
|
|
32
29
|
constructor(fields: GenerationChunkFields);
|
|
33
30
|
concat(chunk: GenerationChunk): GenerationChunk;
|
|
@@ -43,12 +40,10 @@ type LLMResult = {
|
|
|
43
40
|
/**
|
|
44
41
|
* Dictionary of arbitrary LLM-provider specific output.
|
|
45
42
|
*/
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
43
|
llmOutput?: Record<string, any>;
|
|
48
44
|
/**
|
|
49
45
|
* Dictionary of run metadata
|
|
50
46
|
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
47
|
[RUN_KEY]?: Record<string, any>;
|
|
53
48
|
};
|
|
54
49
|
interface ChatGeneration extends Generation {
|
|
@@ -64,7 +59,6 @@ declare class ChatGenerationChunk extends GenerationChunk implements ChatGenerat
|
|
|
64
59
|
}
|
|
65
60
|
interface ChatResult {
|
|
66
61
|
generations: ChatGeneration[];
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
62
|
llmOutput?: Record<string, any>;
|
|
69
63
|
}
|
|
70
64
|
//#endregion
|
package/dist/prompts/base.d.cts
CHANGED
|
@@ -11,11 +11,7 @@ type Example = Record<string, string>;
|
|
|
11
11
|
/**
|
|
12
12
|
* Input common to all prompt templates.
|
|
13
13
|
*/
|
|
14
|
-
interface BasePromptTemplateInput<
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
InputVariables extends InputValues = any,
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
PartialVariableName extends string = any> {
|
|
14
|
+
interface BasePromptTemplateInput<InputVariables extends InputValues = any, PartialVariableName extends string = any> {
|
|
19
15
|
/**
|
|
20
16
|
* A list of variable names the prompt template expects
|
|
21
17
|
*/
|
|
@@ -31,11 +27,7 @@ PartialVariableName extends string = any> {
|
|
|
31
27
|
* Base class for prompt templates. Exposes a format method that returns a
|
|
32
28
|
* string prompt given a set of input values.
|
|
33
29
|
*/
|
|
34
|
-
declare abstract class BasePromptTemplate<
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
RunInput extends InputValues = any, RunOutput extends BasePromptValueInterface = BasePromptValueInterface,
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
PartialVariableName extends string = any> extends Runnable<RunInput, RunOutput> implements BasePromptTemplateInput {
|
|
30
|
+
declare abstract class BasePromptTemplate<RunInput extends InputValues = any, RunOutput extends BasePromptValueInterface = BasePromptValueInterface, PartialVariableName extends string = any> extends Runnable<RunInput, RunOutput> implements BasePromptTemplateInput {
|
|
39
31
|
PromptValueReturnType: RunOutput;
|
|
40
32
|
lc_serializable: boolean;
|
|
41
33
|
lc_namespace: string[];
|
package/dist/prompts/base.d.ts
CHANGED
|
@@ -12,11 +12,7 @@ type Example = Record<string, string>;
|
|
|
12
12
|
/**
|
|
13
13
|
* Input common to all prompt templates.
|
|
14
14
|
*/
|
|
15
|
-
interface BasePromptTemplateInput<
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
InputVariables extends InputValues = any,
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
PartialVariableName extends string = any> {
|
|
15
|
+
interface BasePromptTemplateInput<InputVariables extends InputValues = any, PartialVariableName extends string = any> {
|
|
20
16
|
/**
|
|
21
17
|
* A list of variable names the prompt template expects
|
|
22
18
|
*/
|
|
@@ -32,11 +28,7 @@ PartialVariableName extends string = any> {
|
|
|
32
28
|
* Base class for prompt templates. Exposes a format method that returns a
|
|
33
29
|
* string prompt given a set of input values.
|
|
34
30
|
*/
|
|
35
|
-
declare abstract class BasePromptTemplate<
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
RunInput extends InputValues = any, RunOutput extends BasePromptValueInterface = BasePromptValueInterface,
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
PartialVariableName extends string = any> extends Runnable<RunInput, RunOutput> implements BasePromptTemplateInput {
|
|
31
|
+
declare abstract class BasePromptTemplate<RunInput extends InputValues = any, RunOutput extends BasePromptValueInterface = BasePromptValueInterface, PartialVariableName extends string = any> extends Runnable<RunInput, RunOutput> implements BasePromptTemplateInput {
|
|
40
32
|
PromptValueReturnType: RunOutput;
|
|
41
33
|
lc_serializable: boolean;
|
|
42
34
|
lc_namespace: string[];
|
package/dist/prompts/chat.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_base = require('../messages/base.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_index = require('../errors/index.cjs');
|
|
3
3
|
const require_chat = require('../messages/chat.cjs');
|
|
4
4
|
const require_human = require('../messages/human.cjs');
|
|
5
5
|
const require_system = require('../messages/system.cjs');
|
|
6
|
-
const require_index = require('../errors/index.cjs');
|
|
7
6
|
const require_utils = require('../messages/utils.cjs');
|
|
7
|
+
const require_ai = require('../messages/ai.cjs');
|
|
8
8
|
const require_base$1 = require('../runnables/base.cjs');
|
|
9
9
|
require('../messages/index.cjs');
|
|
10
10
|
const require_prompt_values = require('../prompt_values.cjs');
|
package/dist/prompts/chat.d.cts
CHANGED
|
@@ -21,9 +21,7 @@ import { DictPromptTemplate } from "./dict.cjs";
|
|
|
21
21
|
* templates. It defines how to format messages for different roles in a
|
|
22
22
|
* conversation.
|
|
23
23
|
*/
|
|
24
|
-
declare abstract class BaseMessagePromptTemplate<
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
RunInput extends InputValues = any, RunOutput extends BaseMessage[] = BaseMessage[]> extends Runnable<RunInput, RunOutput> {
|
|
24
|
+
declare abstract class BaseMessagePromptTemplate<RunInput extends InputValues = any, RunOutput extends BaseMessage[] = BaseMessage[]> extends Runnable<RunInput, RunOutput> {
|
|
27
25
|
lc_namespace: string[];
|
|
28
26
|
lc_serializable: boolean;
|
|
29
27
|
abstract inputVariables: Array<Extract<keyof RunInput, string>>;
|
|
@@ -53,9 +51,7 @@ interface MessagesPlaceholderFields<T extends string> {
|
|
|
53
51
|
* Class that represents a placeholder for messages in a chat prompt. It
|
|
54
52
|
* extends the BaseMessagePromptTemplate.
|
|
55
53
|
*/
|
|
56
|
-
declare class MessagesPlaceholder<
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput> implements MessagesPlaceholderFields<Extract<keyof RunInput, string>> {
|
|
54
|
+
declare class MessagesPlaceholder<RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput> implements MessagesPlaceholderFields<Extract<keyof RunInput, string>> {
|
|
59
55
|
static lc_name(): string;
|
|
60
56
|
variableName: Extract<keyof RunInput, string>;
|
|
61
57
|
optional: boolean;
|
|
@@ -67,18 +63,14 @@ RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput>
|
|
|
67
63
|
/**
|
|
68
64
|
* Interface for the fields of a MessageStringPromptTemplate.
|
|
69
65
|
*/
|
|
70
|
-
interface MessageStringPromptTemplateFields<
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
-
T extends InputValues = any> {
|
|
66
|
+
interface MessageStringPromptTemplateFields<T extends InputValues = any> {
|
|
73
67
|
prompt: BaseStringPromptTemplate<T, string>;
|
|
74
68
|
}
|
|
75
69
|
/**
|
|
76
70
|
* Abstract class that serves as a base for creating message string prompt
|
|
77
71
|
* templates. It extends the BaseMessagePromptTemplate.
|
|
78
72
|
*/
|
|
79
|
-
declare abstract class BaseMessageStringPromptTemplate<
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput> {
|
|
73
|
+
declare abstract class BaseMessageStringPromptTemplate<RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput> {
|
|
82
74
|
prompt: BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>, string>;
|
|
83
75
|
constructor(prompt: BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>>);
|
|
84
76
|
constructor(fields: MessageStringPromptTemplateFields<InputValues<Extract<keyof RunInput, string>>>);
|
|
@@ -90,11 +82,7 @@ RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput>
|
|
|
90
82
|
* Abstract class that serves as a base for creating chat prompt
|
|
91
83
|
* templates. It extends the BasePromptTemplate.
|
|
92
84
|
*/
|
|
93
|
-
declare abstract class BaseChatPromptTemplate<
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
-
RunInput extends InputValues = any,
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
-
PartialVariableName extends string = any> extends BasePromptTemplate<RunInput, ChatPromptValueInterface, PartialVariableName> {
|
|
85
|
+
declare abstract class BaseChatPromptTemplate<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BasePromptTemplate<RunInput, ChatPromptValueInterface, PartialVariableName> {
|
|
98
86
|
constructor(input: BasePromptTemplateInput<RunInput, PartialVariableName>);
|
|
99
87
|
abstract formatMessages(values: TypedPromptInputValues<RunInput>): Promise<BaseMessage[]>;
|
|
100
88
|
format(values: TypedPromptInputValues<RunInput>): Promise<string>;
|
|
@@ -103,7 +91,6 @@ PartialVariableName extends string = any> extends BasePromptTemplate<RunInput, C
|
|
|
103
91
|
/**
|
|
104
92
|
* Interface for the fields of a ChatMessagePromptTemplate.
|
|
105
93
|
*/
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
94
|
interface ChatMessagePromptTemplateFields<T extends InputValues = any> extends MessageStringPromptTemplateFields<T> {
|
|
108
95
|
role: string;
|
|
109
96
|
}
|
|
@@ -111,9 +98,7 @@ interface ChatMessagePromptTemplateFields<T extends InputValues = any> extends M
|
|
|
111
98
|
* Class that represents a chat message prompt template. It extends the
|
|
112
99
|
* BaseMessageStringPromptTemplate.
|
|
113
100
|
*/
|
|
114
|
-
declare class ChatMessagePromptTemplate<
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
-
RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunInput> {
|
|
101
|
+
declare class ChatMessagePromptTemplate<RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunInput> {
|
|
117
102
|
static lc_name(): string;
|
|
118
103
|
role: string;
|
|
119
104
|
constructor(prompt: BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>>, role: string);
|
|
@@ -124,11 +109,9 @@ RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunI
|
|
|
124
109
|
}): ChatMessagePromptTemplate<ExtractedFStringParams<T, RunInput>>;
|
|
125
110
|
}
|
|
126
111
|
interface _TextTemplateParam {
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
112
|
text?: string | Record<string, any>;
|
|
129
113
|
}
|
|
130
114
|
interface _ImageTemplateParam {
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
132
115
|
image_url?: string | Record<string, any>;
|
|
133
116
|
}
|
|
134
117
|
type MessageClass = typeof HumanMessage | typeof AIMessage | typeof SystemMessage;
|
|
@@ -136,9 +119,7 @@ type ChatMessageClass = typeof ChatMessage;
|
|
|
136
119
|
interface _StringImageMessagePromptTemplateOptions<Format extends TemplateFormat = TemplateFormat> extends Record<string, unknown> {
|
|
137
120
|
templateFormat?: Format;
|
|
138
121
|
}
|
|
139
|
-
declare class _StringImageMessagePromptTemplate<
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
|
-
RunInput extends InputValues = any, RunOutput extends BaseMessage[] = BaseMessage[]> extends BaseMessagePromptTemplate<RunInput, RunOutput> {
|
|
122
|
+
declare class _StringImageMessagePromptTemplate<RunInput extends InputValues = any, RunOutput extends BaseMessage[] = BaseMessage[]> extends BaseMessagePromptTemplate<RunInput, RunOutput> {
|
|
142
123
|
lc_namespace: string[];
|
|
143
124
|
lc_serializable: boolean;
|
|
144
125
|
inputVariables: Array<Extract<keyof RunInput, string>>;
|
|
@@ -146,11 +127,8 @@ RunInput extends InputValues = any, RunOutput extends BaseMessage[] = BaseMessag
|
|
|
146
127
|
prompt: BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>, string> | Array<BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>, string> | ImagePromptTemplate<InputValues<Extract<keyof RunInput, string>>, string> | MessageStringPromptTemplateFields<InputValues<Extract<keyof RunInput, string>>> | DictPromptTemplate<InputValues<Extract<keyof RunInput, string>>>>;
|
|
147
128
|
protected messageClass?: MessageClass;
|
|
148
129
|
static _messageClass(): MessageClass;
|
|
149
|
-
// ChatMessage contains role field, others don't.
|
|
150
|
-
// Because of this, we have a separate class property for ChatMessage.
|
|
151
130
|
protected chatMessageClass?: ChatMessageClass;
|
|
152
131
|
constructor(/** @TODO When we come up with a better way to type prompt templates, fix this */
|
|
153
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
132
|
fields: any, additionalOptions?: _StringImageMessagePromptTemplateOptions);
|
|
155
133
|
createMessage(content: MessageContent): any;
|
|
156
134
|
getRoleFromMessageClass(name: string): "ai" | "chat" | "human" | "system";
|
|
@@ -172,9 +150,7 @@ RunInput extends InputValues = any, RunOutput extends BaseMessage[] = BaseMessag
|
|
|
172
150
|
* });
|
|
173
151
|
* ```
|
|
174
152
|
*/
|
|
175
|
-
declare class HumanMessagePromptTemplate<
|
|
176
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
-
RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<RunInput> {
|
|
153
|
+
declare class HumanMessagePromptTemplate<RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<RunInput> {
|
|
178
154
|
static _messageClass(): typeof HumanMessage;
|
|
179
155
|
static lc_name(): string;
|
|
180
156
|
}
|
|
@@ -182,9 +158,7 @@ RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<Ru
|
|
|
182
158
|
* Class that represents an AI message prompt template. It extends the
|
|
183
159
|
* BaseMessageStringPromptTemplate.
|
|
184
160
|
*/
|
|
185
|
-
declare class AIMessagePromptTemplate<
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
187
|
-
RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<RunInput> {
|
|
161
|
+
declare class AIMessagePromptTemplate<RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<RunInput> {
|
|
188
162
|
static _messageClass(): typeof AIMessage;
|
|
189
163
|
static lc_name(): string;
|
|
190
164
|
}
|
|
@@ -202,20 +176,14 @@ RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<Ru
|
|
|
202
176
|
* });
|
|
203
177
|
* ```
|
|
204
178
|
*/
|
|
205
|
-
declare class SystemMessagePromptTemplate<
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
|
-
RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<RunInput> {
|
|
179
|
+
declare class SystemMessagePromptTemplate<RunInput extends InputValues = any> extends _StringImageMessagePromptTemplate<RunInput> {
|
|
208
180
|
static _messageClass(): typeof SystemMessage;
|
|
209
181
|
static lc_name(): string;
|
|
210
182
|
}
|
|
211
183
|
/**
|
|
212
184
|
* Interface for the input of a ChatPromptTemplate.
|
|
213
185
|
*/
|
|
214
|
-
interface ChatPromptTemplateInput<
|
|
215
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
-
RunInput extends InputValues = any,
|
|
217
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
|
-
PartialVariableName extends string = any> extends BasePromptTemplateInput<RunInput, PartialVariableName> {
|
|
186
|
+
interface ChatPromptTemplateInput<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BasePromptTemplateInput<RunInput, PartialVariableName> {
|
|
219
187
|
/**
|
|
220
188
|
* The prompt messages
|
|
221
189
|
*/
|
|
@@ -249,11 +217,7 @@ type BaseMessagePromptTemplateLike = BaseMessagePromptTemplate | BaseMessageLike
|
|
|
249
217
|
* });
|
|
250
218
|
* ```
|
|
251
219
|
*/
|
|
252
|
-
declare class ChatPromptTemplate<
|
|
253
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
|
-
RunInput extends InputValues = any,
|
|
255
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
256
|
-
PartialVariableName extends string = any> extends BaseChatPromptTemplate<RunInput, PartialVariableName> implements ChatPromptTemplateInput<RunInput, PartialVariableName> {
|
|
220
|
+
declare class ChatPromptTemplate<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BaseChatPromptTemplate<RunInput, PartialVariableName> implements ChatPromptTemplateInput<RunInput, PartialVariableName> {
|
|
257
221
|
static lc_name(): string;
|
|
258
222
|
get lc_aliases(): Record<string, string>;
|
|
259
223
|
promptMessages: Array<BaseMessagePromptTemplate | BaseMessage>;
|
|
@@ -276,9 +240,7 @@ PartialVariableName extends string = any> extends BaseChatPromptTemplate<RunInpu
|
|
|
276
240
|
* @param promptMessages Messages to be passed to the chat model
|
|
277
241
|
* @returns A new ChatPromptTemplate
|
|
278
242
|
*/
|
|
279
|
-
static fromMessages<
|
|
280
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
-
RunInput extends InputValues = any, Extra extends ChatPromptTemplateInput<RunInput> = ChatPromptTemplateInput<RunInput>>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], extra?: Omit<Extra, "inputVariables" | "promptMessages" | "partialVariables">): ChatPromptTemplate<RunInput>;
|
|
243
|
+
static fromMessages<RunInput extends InputValues = any, Extra extends ChatPromptTemplateInput<RunInput> = ChatPromptTemplateInput<RunInput>>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], extra?: Omit<Extra, "inputVariables" | "promptMessages" | "partialVariables">): ChatPromptTemplate<RunInput>;
|
|
282
244
|
}
|
|
283
245
|
//#endregion
|
|
284
246
|
export { AIMessagePromptTemplate, BaseChatPromptTemplate, BaseMessagePromptTemplate, BaseMessagePromptTemplateLike, BaseMessageStringPromptTemplate, ChatMessagePromptTemplate, ChatMessagePromptTemplateFields, ChatPromptTemplate, ChatPromptTemplateInput, HumanMessagePromptTemplate, MessageStringPromptTemplateFields, MessagesPlaceholder, MessagesPlaceholderFields, SystemMessagePromptTemplate };
|