@langchain/core 1.0.0-alpha.2 → 1.0.0-alpha.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/README.md +3 -19
- package/dist/agents.d.ts.map +1 -1
- package/dist/caches/base.cjs +5 -18
- package/dist/caches/base.cjs.map +1 -1
- package/dist/caches/base.d.cts +4 -20
- package/dist/caches/base.d.cts.map +1 -1
- package/dist/caches/base.d.ts +4 -20
- package/dist/caches/base.d.ts.map +1 -1
- package/dist/caches/base.js +5 -18
- package/dist/caches/base.js.map +1 -1
- package/dist/callbacks/base.d.cts +3 -2
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/callbacks/base.d.ts +3 -2
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/callbacks/manager.d.cts +1 -1
- package/dist/callbacks/manager.d.ts +1 -1
- package/dist/document_loaders/langsmith.cjs +1 -1
- package/dist/document_loaders/langsmith.cjs.map +1 -1
- package/dist/document_loaders/langsmith.js +1 -1
- package/dist/document_loaders/langsmith.js.map +1 -1
- package/dist/embeddings.cjs.map +1 -1
- package/dist/embeddings.d.cts +6 -6
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts +6 -6
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/embeddings.js.map +1 -1
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/indexing/base.cjs +2 -2
- package/dist/indexing/base.cjs.map +1 -1
- package/dist/indexing/base.d.cts +0 -3
- package/dist/indexing/base.d.cts.map +1 -1
- package/dist/indexing/base.d.ts +0 -3
- package/dist/indexing/base.d.ts.map +1 -1
- package/dist/indexing/base.js +2 -2
- package/dist/indexing/base.js.map +1 -1
- package/dist/language_models/base.cjs +1 -1
- package/dist/language_models/base.cjs.map +1 -1
- package/dist/language_models/base.d.cts +4 -4
- package/dist/language_models/base.d.cts.map +1 -1
- package/dist/language_models/base.d.ts +4 -4
- package/dist/language_models/base.d.ts.map +1 -1
- package/dist/language_models/base.js +1 -1
- package/dist/language_models/base.js.map +1 -1
- package/dist/language_models/chat_models.cjs +1 -0
- package/dist/language_models/chat_models.cjs.map +1 -1
- package/dist/language_models/chat_models.d.cts +2 -1
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts +2 -1
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/language_models/chat_models.js +2 -1
- package/dist/language_models/chat_models.js.map +1 -1
- package/dist/language_models/llms.cjs.map +1 -1
- package/dist/language_models/llms.js.map +1 -1
- package/dist/load/import_map.cjs +1 -5
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +3 -7
- package/dist/load/import_map.js.map +1 -1
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.js.map +1 -1
- package/dist/load/serializable.cjs.map +1 -1
- package/dist/load/serializable.d.cts +1 -3
- package/dist/load/serializable.d.cts.map +1 -1
- package/dist/load/serializable.d.ts +1 -3
- package/dist/load/serializable.d.ts.map +1 -1
- package/dist/load/serializable.js.map +1 -1
- package/dist/messages/ai.cjs +34 -62
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.d.cts +26 -119
- package/dist/messages/ai.d.cts.map +1 -1
- package/dist/messages/ai.d.ts +26 -119
- package/dist/messages/ai.d.ts.map +1 -1
- package/dist/messages/ai.js +34 -62
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +53 -33
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +38 -41
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +38 -41
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +53 -33
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/utils.cjs +1 -1
- package/dist/messages/block_translators/utils.cjs.map +1 -1
- package/dist/messages/block_translators/utils.js +1 -1
- package/dist/messages/block_translators/utils.js.map +1 -1
- package/dist/messages/chat.cjs +18 -12
- package/dist/messages/chat.cjs.map +1 -1
- package/dist/messages/chat.d.cts +21 -13
- package/dist/messages/chat.d.cts.map +1 -1
- package/dist/messages/chat.d.ts +21 -13
- package/dist/messages/chat.d.ts.map +1 -1
- package/dist/messages/chat.js +18 -12
- package/dist/messages/chat.js.map +1 -1
- package/dist/messages/content/index.cjs.map +1 -1
- package/dist/messages/content/index.d.cts +1 -1
- package/dist/messages/content/index.d.cts.map +1 -1
- package/dist/messages/content/index.d.ts +1 -1
- package/dist/messages/content/index.d.ts.map +1 -1
- package/dist/messages/content/index.js.map +1 -1
- package/dist/messages/function.cjs +8 -13
- package/dist/messages/function.cjs.map +1 -1
- package/dist/messages/function.d.cts +11 -11
- package/dist/messages/function.d.cts.map +1 -1
- package/dist/messages/function.d.ts +11 -11
- package/dist/messages/function.d.ts.map +1 -1
- package/dist/messages/function.js +8 -13
- package/dist/messages/function.js.map +1 -1
- package/dist/messages/human.cjs +20 -11
- package/dist/messages/human.cjs.map +1 -1
- package/dist/messages/human.d.cts +20 -15
- package/dist/messages/human.d.cts.map +1 -1
- package/dist/messages/human.d.ts +20 -15
- package/dist/messages/human.d.ts.map +1 -1
- package/dist/messages/human.js +20 -11
- package/dist/messages/human.js.map +1 -1
- package/dist/messages/index.cjs +11 -1
- package/dist/messages/index.cjs.map +1 -1
- package/dist/messages/index.d.cts +9 -7
- package/dist/messages/index.d.ts +9 -7
- package/dist/messages/index.js +8 -2
- package/dist/messages/index.js.map +1 -1
- package/dist/messages/message.cjs +15 -0
- package/dist/messages/message.cjs.map +1 -0
- package/dist/messages/message.d.cts +598 -0
- package/dist/messages/message.d.cts.map +1 -0
- package/dist/messages/message.d.ts +598 -0
- package/dist/messages/message.d.ts.map +1 -0
- package/dist/messages/message.js +14 -0
- package/dist/messages/message.js.map +1 -0
- package/dist/messages/metadata.cjs +41 -0
- package/dist/messages/metadata.cjs.map +1 -0
- package/dist/messages/metadata.d.cts +98 -0
- package/dist/messages/metadata.d.cts.map +1 -0
- package/dist/messages/metadata.d.ts +98 -0
- package/dist/messages/metadata.d.ts.map +1 -0
- package/dist/messages/metadata.js +40 -0
- package/dist/messages/metadata.js.map +1 -0
- package/dist/messages/modifier.cjs +5 -4
- package/dist/messages/modifier.cjs.map +1 -1
- package/dist/messages/modifier.d.cts +7 -5
- package/dist/messages/modifier.d.cts.map +1 -1
- package/dist/messages/modifier.d.ts +7 -5
- package/dist/messages/modifier.d.ts.map +1 -1
- package/dist/messages/modifier.js +5 -4
- package/dist/messages/modifier.js.map +1 -1
- package/dist/messages/system.cjs +20 -11
- package/dist/messages/system.cjs.map +1 -1
- package/dist/messages/system.d.cts +20 -15
- package/dist/messages/system.d.cts.map +1 -1
- package/dist/messages/system.d.ts +20 -15
- package/dist/messages/system.d.ts.map +1 -1
- package/dist/messages/system.js +20 -11
- package/dist/messages/system.js.map +1 -1
- package/dist/messages/tool.cjs +21 -19
- package/dist/messages/tool.cjs.map +1 -1
- package/dist/messages/tool.d.cts +72 -46
- package/dist/messages/tool.d.cts.map +1 -1
- package/dist/messages/tool.d.ts +72 -46
- package/dist/messages/tool.d.ts.map +1 -1
- package/dist/messages/tool.js +21 -19
- package/dist/messages/tool.js.map +1 -1
- package/dist/messages/transformers.cjs +2 -2
- package/dist/messages/transformers.cjs.map +1 -1
- package/dist/messages/transformers.d.cts +2 -1
- package/dist/messages/transformers.d.cts.map +1 -1
- package/dist/messages/transformers.d.ts +2 -1
- package/dist/messages/transformers.d.ts.map +1 -1
- package/dist/messages/transformers.js +2 -2
- package/dist/messages/transformers.js.map +1 -1
- package/dist/messages/utils.cjs +13 -1
- package/dist/messages/utils.cjs.map +1 -1
- package/dist/messages/utils.d.cts +83 -3
- package/dist/messages/utils.d.cts.map +1 -1
- package/dist/messages/utils.d.ts +83 -3
- package/dist/messages/utils.d.ts.map +1 -1
- package/dist/messages/utils.js +13 -2
- package/dist/messages/utils.js.map +1 -1
- package/dist/output_parsers/list.cjs +1 -1
- package/dist/output_parsers/list.cjs.map +1 -1
- package/dist/output_parsers/list.js +1 -1
- package/dist/output_parsers/list.js.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
- package/dist/output_parsers/structured.cjs +2 -1
- package/dist/output_parsers/structured.cjs.map +1 -1
- package/dist/output_parsers/structured.js +2 -1
- package/dist/output_parsers/structured.js.map +1 -1
- package/dist/prompt_values.d.cts +4 -3
- package/dist/prompt_values.d.cts.map +1 -1
- package/dist/prompt_values.d.ts +4 -3
- package/dist/prompt_values.d.ts.map +1 -1
- package/dist/prompts/chat.cjs +3 -1
- package/dist/prompts/chat.cjs.map +1 -1
- package/dist/prompts/chat.d.cts +7 -15
- package/dist/prompts/chat.d.cts.map +1 -1
- package/dist/prompts/chat.d.ts +7 -15
- package/dist/prompts/chat.d.ts.map +1 -1
- package/dist/prompts/chat.js +3 -1
- package/dist/prompts/chat.js.map +1 -1
- package/dist/prompts/few_shot.d.cts +1 -1
- package/dist/prompts/few_shot.d.ts +1 -1
- package/dist/prompts/image.cjs.map +1 -1
- package/dist/prompts/image.d.cts +1 -3
- package/dist/prompts/image.d.cts.map +1 -1
- package/dist/prompts/image.d.ts +1 -3
- package/dist/prompts/image.d.ts.map +1 -1
- package/dist/prompts/image.js.map +1 -1
- package/dist/prompts/pipeline.cjs.map +1 -1
- package/dist/prompts/pipeline.js.map +1 -1
- package/dist/prompts/prompt.cjs.map +1 -1
- package/dist/prompts/prompt.d.cts +5 -17
- package/dist/prompts/prompt.d.cts.map +1 -1
- package/dist/prompts/prompt.d.ts +5 -17
- package/dist/prompts/prompt.d.ts.map +1 -1
- package/dist/prompts/prompt.js.map +1 -1
- package/dist/prompts/structured.cjs.map +1 -1
- package/dist/prompts/structured.js.map +1 -1
- package/dist/prompts/template.cjs +4 -2
- package/dist/prompts/template.cjs.map +1 -1
- package/dist/prompts/template.d.cts +1 -1
- package/dist/prompts/template.d.ts +1 -1
- package/dist/prompts/template.js +4 -2
- package/dist/prompts/template.js.map +1 -1
- package/dist/runnables/base.cjs +6 -6
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +1 -4
- package/dist/runnables/base.d.cts.map +1 -1
- package/dist/runnables/base.d.ts +1 -4
- package/dist/runnables/base.d.ts.map +1 -1
- package/dist/runnables/base.js +6 -6
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.cjs +2 -2
- package/dist/runnables/branch.cjs.map +1 -1
- package/dist/runnables/branch.js +2 -2
- package/dist/runnables/branch.js.map +1 -1
- package/dist/runnables/config.cjs.map +1 -1
- package/dist/runnables/config.js.map +1 -1
- package/dist/runnables/graph.cjs +1 -1
- package/dist/runnables/graph.cjs.map +1 -1
- package/dist/runnables/graph.js +1 -1
- package/dist/runnables/graph.js.map +1 -1
- package/dist/runnables/graph_mermaid.cjs +26 -3
- package/dist/runnables/graph_mermaid.cjs.map +1 -1
- package/dist/runnables/graph_mermaid.js +26 -3
- package/dist/runnables/graph_mermaid.js.map +1 -1
- package/dist/runnables/remote.cjs.map +1 -1
- package/dist/runnables/remote.js.map +1 -1
- package/dist/runnables/types.d.cts +0 -1
- package/dist/runnables/types.d.cts.map +1 -1
- package/dist/runnables/types.d.ts +0 -1
- package/dist/runnables/types.d.ts.map +1 -1
- package/dist/singletons/async_local_storage/context.cjs.map +1 -1
- package/dist/singletons/async_local_storage/context.d.cts +0 -1
- package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
- package/dist/singletons/async_local_storage/context.d.ts +0 -1
- package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
- package/dist/singletons/async_local_storage/context.js.map +1 -1
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +3 -3
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.d.cts +6 -6
- package/dist/tools/types.d.cts.map +1 -1
- package/dist/tools/types.d.ts +6 -6
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tracers/base.cjs.map +1 -1
- package/dist/tracers/base.d.cts +1 -1
- package/dist/tracers/base.d.ts +1 -1
- package/dist/tracers/base.js.map +1 -1
- package/dist/tracers/console.cjs +1 -1
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.js +1 -1
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.cjs +1 -1
- package/dist/tracers/event_stream.cjs.map +1 -1
- package/dist/tracers/event_stream.d.cts +0 -1
- package/dist/tracers/event_stream.d.cts.map +1 -1
- package/dist/tracers/event_stream.d.ts +0 -1
- package/dist/tracers/event_stream.d.ts.map +1 -1
- package/dist/tracers/event_stream.js +1 -1
- package/dist/tracers/event_stream.js.map +1 -1
- package/dist/tracers/log_stream.cjs.map +1 -1
- package/dist/tracers/log_stream.js.map +1 -1
- package/dist/tracers/tracer_langchain.cjs.map +1 -1
- package/dist/tracers/tracer_langchain.js.map +1 -1
- package/dist/tracers/tracer_langchain_v1.d.cts +1 -1
- package/dist/tracers/tracer_langchain_v1.d.ts +1 -1
- package/dist/utils/chunk_array.cjs.map +1 -1
- package/dist/utils/chunk_array.js.map +1 -1
- package/dist/utils/env.cjs +1 -1
- package/dist/utils/env.cjs.map +1 -1
- package/dist/utils/env.js +1 -1
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/event_source_parse.cjs.map +1 -1
- package/dist/utils/event_source_parse.d.cts.map +1 -1
- package/dist/utils/event_source_parse.d.ts.map +1 -1
- package/dist/utils/event_source_parse.js.map +1 -1
- package/dist/utils/hash.cjs +3 -8
- package/dist/utils/hash.cjs.map +1 -1
- package/dist/utils/hash.d.cts +1 -2
- package/dist/utils/hash.d.cts.map +1 -1
- package/dist/utils/hash.d.ts +1 -2
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +2 -6
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/js-sha256/hash.cjs +0 -9
- package/dist/utils/js-sha256/hash.cjs.map +1 -1
- package/dist/utils/js-sha256/hash.js +1 -5
- package/dist/utils/js-sha256/hash.js.map +1 -1
- package/dist/utils/json.cjs +2 -2
- package/dist/utils/json.cjs.map +1 -1
- package/dist/utils/json.js +2 -2
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/json_schema.cjs +3 -2
- package/dist/utils/json_schema.cjs.map +1 -1
- package/dist/utils/json_schema.d.cts +8 -4
- package/dist/utils/json_schema.d.cts.map +1 -1
- package/dist/utils/json_schema.d.ts +8 -4
- package/dist/utils/json_schema.d.ts.map +1 -1
- package/dist/utils/json_schema.js +2 -1
- package/dist/utils/json_schema.js.map +1 -1
- package/dist/utils/stream.cjs.map +1 -1
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/testing/index.cjs.map +1 -1
- package/dist/utils/testing/index.d.cts +8 -12
- package/dist/utils/testing/index.d.cts.map +1 -1
- package/dist/utils/testing/index.d.ts +8 -12
- package/dist/utils/testing/index.d.ts.map +1 -1
- package/dist/utils/testing/index.js.map +1 -1
- package/dist/utils/zod-to-json-schema/Options.cjs +40 -0
- package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/Options.js +37 -0
- package/dist/utils/zod-to-json-schema/Options.js.map +1 -0
- package/dist/utils/zod-to-json-schema/Refs.cjs +30 -0
- package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/Refs.js +30 -0
- package/dist/utils/zod-to-json-schema/Refs.js.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.cjs +18 -0
- package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.cts +11 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.ts +11 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.js +16 -0
- package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.cjs +11 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.js +10 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -0
- package/dist/utils/zod-to-json-schema/index.cjs +37 -0
- package/dist/utils/zod-to-json-schema/index.js +37 -0
- package/dist/utils/zod-to-json-schema/parseDef.cjs +57 -0
- package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parseDef.js +57 -0
- package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.cts +38 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.ts +38 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.cjs +17 -0
- package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.js +17 -0
- package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.cjs +24 -0
- package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.cts +14 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.ts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.js +23 -0
- package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +36 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.js +36 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +9 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.js +8 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.cjs +39 -0
- package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.cts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.ts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.js +39 -0
- package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/default.cjs +13 -0
- package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/default.js +13 -0
- package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.cjs +11 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.js +11 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.cjs +12 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.cts +8 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +10 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.js +11 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +47 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +10 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +11 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.js +47 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.cjs +18 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +11 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +12 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.js +17 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.cjs +40 -0
- package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.cts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.ts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.js +40 -0
- package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +18 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts +8 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +10 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +17 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.cjs +13 -0
- package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.cts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.ts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.js +13 -0
- package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.cjs +12 -0
- package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.js +11 -0
- package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +46 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +12 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +13 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.js +46 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.cjs +37 -0
- package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.cts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.ts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.js +37 -0
- package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.cjs +64 -0
- package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.cts +12 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.ts +13 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.js +64 -0
- package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.cjs +20 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.js +20 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +28 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.js +28 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.cjs +57 -0
- package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.cts +14 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.ts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.js +56 -0
- package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.cjs +22 -0
- package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.cts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.ts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.js +22 -0
- package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.cjs +255 -0
- package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.cts +28 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.ts +29 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.js +254 -0
- package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +38 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.js +38 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.cjs +67 -0
- package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.cts +24 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.ts +25 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.js +66 -0
- package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -0
- package/dist/utils/zod-to-json-schema/selectParser.cjs +81 -0
- package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/selectParser.js +80 -0
- package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +70 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +70 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -0
- package/package.json +7 -36
- package/dist/utils/js-sha1/hash.cjs +0 -291
- package/dist/utils/js-sha1/hash.cjs.map +0 -1
- package/dist/utils/js-sha1/hash.d.cts +0 -9
- package/dist/utils/js-sha1/hash.d.cts.map +0 -1
- package/dist/utils/js-sha1/hash.d.ts +0 -9
- package/dist/utils/js-sha1/hash.d.ts.map +0 -1
- package/dist/utils/js-sha1/hash.js +0 -284
- package/dist/utils/js-sha1/hash.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🦜🍎️ @langchain/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
 [](https://opensource.org/licenses/MIT) [](https://twitter.com/langchainai)
|
|
4
4
|
|
|
5
5
|
`@langchain/core` contains the core abstractions and schemas of LangChain.js, including base classes for language models,
|
|
6
6
|
chat models, vectorstores, retrievers, and runnables.
|
|
@@ -8,7 +8,7 @@ chat models, vectorstores, retrievers, and runnables.
|
|
|
8
8
|
## 💾 Quick Install
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
|
|
11
|
+
pnpm install @langchain/core
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## 🤔 What is this?
|
|
@@ -21,7 +21,7 @@ The benefit of having these abstractions is that any provider can implement the
|
|
|
21
21
|
For example, you can install other provider-specific packages like this:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
pnpm install @langchain/openai
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And use them as follows:
|
|
@@ -72,22 +72,6 @@ leigh
|
|
|
72
72
|
Note that for compatibility, all used LangChain packages (including the base LangChain package, which itself depends on core!) must share the same version of `@langchain/core`.
|
|
73
73
|
This means that you may need to install/resolve a specific version of `@langchain/core` that matches the dependencies of your used packages.
|
|
74
74
|
|
|
75
|
-
## 🔗 What is LangChain Expression Language?
|
|
76
|
-
|
|
77
|
-
LangChain Core also contains LangChain Expression Language, or LCEL, a runtime that allows users to compose arbitrary sequences together and get several benefits that are important when building LLM applications.
|
|
78
|
-
We call these sequences “runnables”.
|
|
79
|
-
|
|
80
|
-
All runnables expose the same interface with single-invocation, batch, streaming and async methods.
|
|
81
|
-
This design is useful because it is not enough to have a single sync interface when building an LLM application.
|
|
82
|
-
Batch is needed for efficient processing of many inputs.
|
|
83
|
-
Streaming (and streaming of intermediate steps) is needed to show the user that progress is being made.
|
|
84
|
-
Async interfaces are nice when moving into production.
|
|
85
|
-
Rather than having to write multiple implementations for all of those, LCEL allows you to write a runnable once and invoke it in many different ways.
|
|
86
|
-
|
|
87
|
-
For more check out the [LCEL docs](https://js.langchain.com/docs/concepts/lcel).
|
|
88
|
-
|
|
89
|
-

|
|
90
|
-
|
|
91
75
|
## 📕 Releases & Versioning
|
|
92
76
|
|
|
93
77
|
`@langchain/core` is currently on version `0.3.x`.
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","names":["AgentAction","Record","AgentFinish","AgentStep"],"sources":["../src/agents.d.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toolInput: string | Record<string, any>;\n log: string;\n};\nexport type AgentFinish = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n returnValues: Record<string, any>;\n log: string;\n};\nexport type AgentStep = {\n action: AgentAction;\n observation: string;\n};\n"],"mappings":";KAAYA,WAAAA;EAAAA,IAAAA,EAAAA,MAAAA;EAMAE;EAKAC,SAAAA,EAAAA,MAAS,GARGF,MASZD,CAAAA,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","names":["AgentAction","Record","AgentFinish","AgentStep"],"sources":["../src/agents.d.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toolInput: string | Record<string, any>;\n log: string;\n};\nexport type AgentFinish = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n returnValues: Record<string, any>;\n log: string;\n};\nexport type AgentStep = {\n action: AgentAction;\n observation: string;\n};\n"],"mappings":";KAAYA,WAAAA;EAAAA,IAAAA,EAAAA,MAAAA;EAMAE;EAKAC,SAAAA,EAAAA,MAAS,GARGF,MASZD,CAAAA,MAAW,EAAA,GAAA,CAAA;;;KANXE,WAAAA;;gBAEMD;;;KAGNE,SAAAA;UACAH"}
|
package/dist/caches/base.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_utils = require('../messages/utils.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_hash = require('../utils/js-sha256/hash.cjs');
|
|
4
4
|
require('../utils/hash.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/caches/base.ts
|
|
@@ -8,24 +8,11 @@ var base_exports = {};
|
|
|
8
8
|
require_rolldown_runtime.__export(base_exports, {
|
|
9
9
|
BaseCache: () => BaseCache,
|
|
10
10
|
InMemoryCache: () => InMemoryCache,
|
|
11
|
+
defaultHashKeyEncoder: () => defaultHashKeyEncoder,
|
|
11
12
|
deserializeStoredGeneration: () => deserializeStoredGeneration,
|
|
12
|
-
getCacheKey: () => getCacheKey,
|
|
13
13
|
serializeGeneration: () => serializeGeneration
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
* This cache key should be consistent across all versions of LangChain.
|
|
17
|
-
* It is currently NOT consistent across versions of LangChain.
|
|
18
|
-
*
|
|
19
|
-
* A huge benefit of having a remote cache (like redis) is that you can
|
|
20
|
-
* access the cache from different processes/machines. The allows you to
|
|
21
|
-
* separate concerns and scale horizontally.
|
|
22
|
-
*
|
|
23
|
-
* TODO: Make cache key consistent across versions of LangChain.
|
|
24
|
-
*
|
|
25
|
-
* @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
|
|
26
|
-
* This function will be removed in a future version.
|
|
27
|
-
*/
|
|
28
|
-
const getCacheKey = (...strings) => require_utils_js_sha1_hash.insecureHash(strings.join("_"));
|
|
15
|
+
const defaultHashKeyEncoder = (...strings) => require_hash.sha256(strings.join("_"));
|
|
29
16
|
function deserializeStoredGeneration(storedGeneration) {
|
|
30
17
|
if (storedGeneration.message !== void 0) return {
|
|
31
18
|
text: storedGeneration.text,
|
|
@@ -42,7 +29,7 @@ function serializeGeneration(generation) {
|
|
|
42
29
|
* Base class for all caches. All caches should extend this class.
|
|
43
30
|
*/
|
|
44
31
|
var BaseCache = class {
|
|
45
|
-
keyEncoder =
|
|
32
|
+
keyEncoder = defaultHashKeyEncoder;
|
|
46
33
|
/**
|
|
47
34
|
* Sets a custom key encoder function for the cache.
|
|
48
35
|
* This function should take a prompt and an LLM key and return a string
|
|
@@ -101,7 +88,7 @@ Object.defineProperty(exports, 'base_exports', {
|
|
|
101
88
|
return base_exports;
|
|
102
89
|
}
|
|
103
90
|
});
|
|
91
|
+
exports.defaultHashKeyEncoder = defaultHashKeyEncoder;
|
|
104
92
|
exports.deserializeStoredGeneration = deserializeStoredGeneration;
|
|
105
|
-
exports.getCacheKey = getCacheKey;
|
|
106
93
|
exports.serializeGeneration = serializeGeneration;
|
|
107
94
|
//# sourceMappingURL=base.cjs.map
|
package/dist/caches/base.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","names":["
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["defaultHashKeyEncoder: HashKeyEncoder","sha256","storedGeneration: StoredGeneration","mapStoredMessageToChatMessage","generation: Generation","serializedValue: StoredGeneration","keyEncoderFn: HashKeyEncoder","map?: Map<string, T>","prompt: string","llmKey: string","value: T"],"sources":["../../src/caches/base.ts"],"sourcesContent":["import { sha256, type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { mapStoredMessageToChatMessage } from \"../messages/utils.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n\nexport const defaultHashKeyEncoder: HashKeyEncoder = (...strings) =>\n sha256(strings.join(\"_\"));\n\nexport function deserializeStoredGeneration(\n storedGeneration: StoredGeneration\n) {\n if (storedGeneration.message !== undefined) {\n return {\n text: storedGeneration.text,\n message: mapStoredMessageToChatMessage(storedGeneration.message),\n };\n } else {\n return { text: storedGeneration.text };\n }\n}\n\nexport function serializeGeneration(generation: Generation) {\n const serializedValue: StoredGeneration = {\n text: generation.text,\n };\n if ((generation as ChatGeneration).message !== undefined) {\n serializedValue.message = (generation as ChatGeneration).message.toDict();\n }\n return serializedValue;\n}\n\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder = defaultHashKeyEncoder;\n\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void {\n this.keyEncoder = keyEncoderFn;\n }\n\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n\nconst GLOBAL_MAP = new Map();\n\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache: Map<string, T>;\n\n constructor(map?: Map<string, T>) {\n super();\n this.cache = map ?? new Map();\n }\n\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null> {\n return Promise.resolve(\n this.cache.get(this.keyEncoder(prompt, llmKey)) ?? null\n );\n }\n\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n async update(prompt: string, llmKey: string, value: T): Promise<void> {\n this.cache.set(this.keyEncoder(prompt, llmKey), value);\n }\n\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache {\n return new InMemoryCache(GLOBAL_MAP);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAaA,wBAAwC,CAAC,GAAG,YACvDC,oBAAO,QAAQ,KAAK,IAAI,CAAC;AAE3B,SAAgB,4BACdC,kBACA;AACA,KAAI,iBAAiB,YAAY,OAC/B,QAAO;EACL,MAAM,iBAAiB;EACvB,SAASC,4CAA8B,iBAAiB,QAAQ;CACjE;KAED,QAAO,EAAE,MAAM,iBAAiB,KAAM;AAEzC;AAED,SAAgB,oBAAoBC,YAAwB;CAC1D,MAAMC,kBAAoC,EACxC,MAAM,WAAW,KAClB;AACD,KAAK,WAA8B,YAAY,QAC7C,gBAAgB,UAAW,WAA8B,QAAQ,QAAQ;AAE3E,QAAO;AACR;;;;AAKD,IAAsB,YAAtB,MAAkD;CAChD,AAAU,aAA6B;;;;;;;CAQvC,sBAAsBC,cAAoC;EACxD,KAAK,aAAa;CACnB;AAKF;AAED,MAAM,6BAAa,IAAI;;;;AAKvB,IAAa,gBAAb,MAAa,sBAAwC,UAAa;CAChE,AAAQ;CAER,YAAYC,KAAsB;EAChC,OAAO;EACP,KAAK,QAAQ,uBAAO,IAAI;CACzB;;;;;;;;CASD,OAAOC,QAAgBC,QAAmC;AACxD,SAAO,QAAQ,QACb,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC,IAAI,KACpD;CACF;;;;;;;CAQD,MAAM,OAAOD,QAAgBC,QAAgBC,OAAyB;EACpE,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,EAAE,MAAM;CACvD;;;;;;CAOD,OAAO,SAAwB;AAC7B,SAAO,IAAI,cAAc;CAC1B;AACF"}
|
package/dist/caches/base.d.cts
CHANGED
|
@@ -5,28 +5,15 @@ import { ChatMessage } from "../messages/chat.cjs";
|
|
|
5
5
|
import { FunctionMessage } from "../messages/function.cjs";
|
|
6
6
|
import { HumanMessage } from "../messages/human.cjs";
|
|
7
7
|
import { SystemMessage } from "../messages/system.cjs";
|
|
8
|
+
import { MessageStructure } from "../messages/message.cjs";
|
|
8
9
|
import { HashKeyEncoder } from "../utils/hash.cjs";
|
|
9
10
|
import { Generation } from "../outputs.cjs";
|
|
10
11
|
|
|
11
12
|
//#region src/caches/base.d.ts
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This cache key should be consistent across all versions of LangChain.
|
|
15
|
-
* It is currently NOT consistent across versions of LangChain.
|
|
16
|
-
*
|
|
17
|
-
* A huge benefit of having a remote cache (like redis) is that you can
|
|
18
|
-
* access the cache from different processes/machines. The allows you to
|
|
19
|
-
* separate concerns and scale horizontally.
|
|
20
|
-
*
|
|
21
|
-
* TODO: Make cache key consistent across versions of LangChain.
|
|
22
|
-
*
|
|
23
|
-
* @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
|
|
24
|
-
* This function will be removed in a future version.
|
|
25
|
-
*/
|
|
26
|
-
declare const getCacheKey: HashKeyEncoder;
|
|
13
|
+
declare const defaultHashKeyEncoder: HashKeyEncoder;
|
|
27
14
|
declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {
|
|
28
15
|
text: string;
|
|
29
|
-
message: AIMessage | ChatMessage | FunctionMessage | HumanMessage | SystemMessage | ToolMessage
|
|
16
|
+
message: AIMessage<MessageStructure> | ChatMessage<MessageStructure> | FunctionMessage<MessageStructure> | HumanMessage<MessageStructure> | SystemMessage<MessageStructure> | ToolMessage<MessageStructure>;
|
|
30
17
|
} | {
|
|
31
18
|
message?: undefined;
|
|
32
19
|
text: string;
|
|
@@ -36,9 +23,6 @@ declare function serializeGeneration(generation: Generation): StoredGeneration;
|
|
|
36
23
|
* Base class for all caches. All caches should extend this class.
|
|
37
24
|
*/
|
|
38
25
|
declare abstract class BaseCache<T = Generation[]> {
|
|
39
|
-
// For backwards compatibility, we use a default key encoder
|
|
40
|
-
// that uses SHA-1 to hash the prompt and LLM key. This will also print a warning
|
|
41
|
-
// about the security implications of using SHA-1 as a cache key.
|
|
42
26
|
protected keyEncoder: HashKeyEncoder;
|
|
43
27
|
/**
|
|
44
28
|
* Sets a custom key encoder function for the cache.
|
|
@@ -79,5 +63,5 @@ declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {
|
|
|
79
63
|
static global(): InMemoryCache;
|
|
80
64
|
}
|
|
81
65
|
//#endregion
|
|
82
|
-
export { BaseCache, InMemoryCache,
|
|
66
|
+
export { BaseCache, InMemoryCache, defaultHashKeyEncoder, deserializeStoredGeneration, serializeGeneration };
|
|
83
67
|
//# sourceMappingURL=base.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":["___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":["___messages_ai_js0","___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","defaultHashKeyEncoder","deserializeStoredGeneration","___messages_message_js0","MessageStructure","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\nexport declare const defaultHashKeyEncoder: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/chat.js\").ChatMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/function.js\").FunctionMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/human.js\").HumanMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/system.js\").SystemMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/tool.js\").ToolMessage<import(\"../messages/message.js\").MessageStructure>;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n"],"mappings":";;;;;;;;;;;;cAGqBS,uBAAuBH;iBACpBI,2BAAAA,mBAA8CF;;WAE8B,UAFd,gBAAA,IAE6G,YAAjJ,gBAAA,IAAwP,gBAAzJ,gBAAA,IAA0P,aAAnJ,gBAAA,IAAsP,cAArJ,gBAAA,IAAoP,YAAjJ,gBAAA;;;;;iBAKpaW,mBAAAA,aAAgCZ,aAAaC;AARrE;AACA;;AAAsEA,uBAWxCY,SAXwCZ,CAAAA,IAW1BD,UAX0BC,EAAAA,CAAAA,CAAAA;EAAgB,UAAA,UAAA,EAY5DF,cAZ4D;EAEc;;;;;;EAAuS,qBAAA,CAAA,YAAA,EAiBnWA,cAjBmW,CAAA,EAAA,IAAA;EAAlD,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAkBpSgB,OAlBoS,CAkB5RD,CAlB4R,GAAA,IAAA,CAAA;EAAqJ,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAmBnbA,CAnBmb,CAAA,EAmB/aC,OAnB+a,CAAA,IAAA,CAAA;;;AAA6C;AAK3hB;AAA2C,cAmBtBC,aAnBsB,CAAA,IAmBJhB,UAnBI,EAAA,CAAA,SAmBkBa,SAnBlB,CAmB4BC,CAnB5B,CAAA,CAAA;EAAA,QAAad,KAAAA;EAAU,WAAGC,CAAAA,GAAAA,CAAAA,EAqB/CgB,GArB+ChB,CAAAA,MAAAA,EAqBnCa,CArBmCb,CAAAA;EAAgB;AAIrF;;;;;;EAS8D,MAATc,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAgBTA,OAhBSA,CAgBDD,CAhBCC,GAAAA,IAAAA,CAAAA;EAAO;;AACU;AAKtE;;;EAAiD,MAAsBD,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAiBrBA,CAjBqBA,CAAAA,EAiBjBC,OAjBiBD,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAiBrB,OAAGC,MAAAA,CAAAA,CAAAA,EAMjCC,aANiCD"}
|
package/dist/caches/base.d.ts
CHANGED
|
@@ -5,28 +5,15 @@ import { ChatMessage } from "../messages/chat.js";
|
|
|
5
5
|
import { FunctionMessage } from "../messages/function.js";
|
|
6
6
|
import { HumanMessage } from "../messages/human.js";
|
|
7
7
|
import { SystemMessage } from "../messages/system.js";
|
|
8
|
+
import { MessageStructure } from "../messages/message.js";
|
|
8
9
|
import { HashKeyEncoder } from "../utils/hash.js";
|
|
9
10
|
import { Generation } from "../outputs.js";
|
|
10
11
|
|
|
11
12
|
//#region src/caches/base.d.ts
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This cache key should be consistent across all versions of LangChain.
|
|
15
|
-
* It is currently NOT consistent across versions of LangChain.
|
|
16
|
-
*
|
|
17
|
-
* A huge benefit of having a remote cache (like redis) is that you can
|
|
18
|
-
* access the cache from different processes/machines. The allows you to
|
|
19
|
-
* separate concerns and scale horizontally.
|
|
20
|
-
*
|
|
21
|
-
* TODO: Make cache key consistent across versions of LangChain.
|
|
22
|
-
*
|
|
23
|
-
* @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
|
|
24
|
-
* This function will be removed in a future version.
|
|
25
|
-
*/
|
|
26
|
-
declare const getCacheKey: HashKeyEncoder;
|
|
13
|
+
declare const defaultHashKeyEncoder: HashKeyEncoder;
|
|
27
14
|
declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {
|
|
28
15
|
text: string;
|
|
29
|
-
message: AIMessage | ChatMessage | FunctionMessage | HumanMessage | SystemMessage | ToolMessage
|
|
16
|
+
message: AIMessage<MessageStructure> | ChatMessage<MessageStructure> | FunctionMessage<MessageStructure> | HumanMessage<MessageStructure> | SystemMessage<MessageStructure> | ToolMessage<MessageStructure>;
|
|
30
17
|
} | {
|
|
31
18
|
message?: undefined;
|
|
32
19
|
text: string;
|
|
@@ -36,9 +23,6 @@ declare function serializeGeneration(generation: Generation): StoredGeneration;
|
|
|
36
23
|
* Base class for all caches. All caches should extend this class.
|
|
37
24
|
*/
|
|
38
25
|
declare abstract class BaseCache<T = Generation[]> {
|
|
39
|
-
// For backwards compatibility, we use a default key encoder
|
|
40
|
-
// that uses SHA-1 to hash the prompt and LLM key. This will also print a warning
|
|
41
|
-
// about the security implications of using SHA-1 as a cache key.
|
|
42
26
|
protected keyEncoder: HashKeyEncoder;
|
|
43
27
|
/**
|
|
44
28
|
* Sets a custom key encoder function for the cache.
|
|
@@ -79,5 +63,5 @@ declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {
|
|
|
79
63
|
static global(): InMemoryCache;
|
|
80
64
|
}
|
|
81
65
|
//#endregion
|
|
82
|
-
export { BaseCache, InMemoryCache,
|
|
66
|
+
export { BaseCache, InMemoryCache, defaultHashKeyEncoder, deserializeStoredGeneration, serializeGeneration };
|
|
83
67
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":["___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":["___messages_ai_js0","___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","defaultHashKeyEncoder","deserializeStoredGeneration","___messages_message_js0","MessageStructure","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\nexport declare const defaultHashKeyEncoder: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/chat.js\").ChatMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/function.js\").FunctionMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/human.js\").HumanMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/system.js\").SystemMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/tool.js\").ToolMessage<import(\"../messages/message.js\").MessageStructure>;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n"],"mappings":";;;;;;;;;;;;cAGqBS,uBAAuBH;iBACpBI,2BAAAA,mBAA8CF;;WAE8B,UAFd,gBAAA,IAE6G,YAAjJ,gBAAA,IAAwP,gBAAzJ,gBAAA,IAA0P,aAAnJ,gBAAA,IAAsP,cAArJ,gBAAA,IAAoP,YAAjJ,gBAAA;;;;;iBAKpaW,mBAAAA,aAAgCZ,aAAaC;AARrE;AACA;;AAAsEA,uBAWxCY,SAXwCZ,CAAAA,IAW1BD,UAX0BC,EAAAA,CAAAA,CAAAA;EAAgB,UAAA,UAAA,EAY5DF,cAZ4D;EAEc;;;;;;EAAuS,qBAAA,CAAA,YAAA,EAiBnWA,cAjBmW,CAAA,EAAA,IAAA;EAAlD,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAkBpSgB,OAlBoS,CAkB5RD,CAlB4R,GAAA,IAAA,CAAA;EAAqJ,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAmBnbA,CAnBmb,CAAA,EAmB/aC,OAnB+a,CAAA,IAAA,CAAA;;;AAA6C;AAK3hB;AAA2C,cAmBtBC,aAnBsB,CAAA,IAmBJhB,UAnBI,EAAA,CAAA,SAmBkBa,SAnBlB,CAmB4BC,CAnB5B,CAAA,CAAA;EAAA,QAAad,KAAAA;EAAU,WAAGC,CAAAA,GAAAA,CAAAA,EAqB/CgB,GArB+ChB,CAAAA,MAAAA,EAqBnCa,CArBmCb,CAAAA;EAAgB;AAIrF;;;;;;EAS8D,MAATc,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAgBTA,OAhBSA,CAgBDD,CAhBCC,GAAAA,IAAAA,CAAAA;EAAO;;AACU;AAKtE;;;EAAiD,MAAsBD,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAiBrBA,CAjBqBA,CAAAA,EAiBjBC,OAjBiBD,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAiBrB,OAAGC,MAAAA,CAAAA,CAAAA,EAMjCC,aANiCD"}
|
package/dist/caches/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
2
2
|
import { mapStoredMessageToChatMessage } from "../messages/utils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { sha256 } from "../utils/js-sha256/hash.js";
|
|
4
4
|
import "../utils/hash.js";
|
|
5
5
|
|
|
6
6
|
//#region src/caches/base.ts
|
|
@@ -8,24 +8,11 @@ var base_exports = {};
|
|
|
8
8
|
__export(base_exports, {
|
|
9
9
|
BaseCache: () => BaseCache,
|
|
10
10
|
InMemoryCache: () => InMemoryCache,
|
|
11
|
+
defaultHashKeyEncoder: () => defaultHashKeyEncoder,
|
|
11
12
|
deserializeStoredGeneration: () => deserializeStoredGeneration,
|
|
12
|
-
getCacheKey: () => getCacheKey,
|
|
13
13
|
serializeGeneration: () => serializeGeneration
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
* This cache key should be consistent across all versions of LangChain.
|
|
17
|
-
* It is currently NOT consistent across versions of LangChain.
|
|
18
|
-
*
|
|
19
|
-
* A huge benefit of having a remote cache (like redis) is that you can
|
|
20
|
-
* access the cache from different processes/machines. The allows you to
|
|
21
|
-
* separate concerns and scale horizontally.
|
|
22
|
-
*
|
|
23
|
-
* TODO: Make cache key consistent across versions of LangChain.
|
|
24
|
-
*
|
|
25
|
-
* @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
|
|
26
|
-
* This function will be removed in a future version.
|
|
27
|
-
*/
|
|
28
|
-
const getCacheKey = (...strings) => insecureHash(strings.join("_"));
|
|
15
|
+
const defaultHashKeyEncoder = (...strings) => sha256(strings.join("_"));
|
|
29
16
|
function deserializeStoredGeneration(storedGeneration) {
|
|
30
17
|
if (storedGeneration.message !== void 0) return {
|
|
31
18
|
text: storedGeneration.text,
|
|
@@ -42,7 +29,7 @@ function serializeGeneration(generation) {
|
|
|
42
29
|
* Base class for all caches. All caches should extend this class.
|
|
43
30
|
*/
|
|
44
31
|
var BaseCache = class {
|
|
45
|
-
keyEncoder =
|
|
32
|
+
keyEncoder = defaultHashKeyEncoder;
|
|
46
33
|
/**
|
|
47
34
|
* Sets a custom key encoder function for the cache.
|
|
48
35
|
* This function should take a prompt and an LLM key and return a string
|
|
@@ -93,5 +80,5 @@ var InMemoryCache = class InMemoryCache extends BaseCache {
|
|
|
93
80
|
};
|
|
94
81
|
|
|
95
82
|
//#endregion
|
|
96
|
-
export { BaseCache, InMemoryCache, base_exports,
|
|
83
|
+
export { BaseCache, InMemoryCache, base_exports, defaultHashKeyEncoder, deserializeStoredGeneration, serializeGeneration };
|
|
97
84
|
//# sourceMappingURL=base.js.map
|
package/dist/caches/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":["
|
|
1
|
+
{"version":3,"file":"base.js","names":["defaultHashKeyEncoder: HashKeyEncoder","storedGeneration: StoredGeneration","generation: Generation","serializedValue: StoredGeneration","keyEncoderFn: HashKeyEncoder","map?: Map<string, T>","prompt: string","llmKey: string","value: T"],"sources":["../../src/caches/base.ts"],"sourcesContent":["import { sha256, type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { mapStoredMessageToChatMessage } from \"../messages/utils.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n\nexport const defaultHashKeyEncoder: HashKeyEncoder = (...strings) =>\n sha256(strings.join(\"_\"));\n\nexport function deserializeStoredGeneration(\n storedGeneration: StoredGeneration\n) {\n if (storedGeneration.message !== undefined) {\n return {\n text: storedGeneration.text,\n message: mapStoredMessageToChatMessage(storedGeneration.message),\n };\n } else {\n return { text: storedGeneration.text };\n }\n}\n\nexport function serializeGeneration(generation: Generation) {\n const serializedValue: StoredGeneration = {\n text: generation.text,\n };\n if ((generation as ChatGeneration).message !== undefined) {\n serializedValue.message = (generation as ChatGeneration).message.toDict();\n }\n return serializedValue;\n}\n\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder = defaultHashKeyEncoder;\n\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void {\n this.keyEncoder = keyEncoderFn;\n }\n\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n\nconst GLOBAL_MAP = new Map();\n\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache: Map<string, T>;\n\n constructor(map?: Map<string, T>) {\n super();\n this.cache = map ?? new Map();\n }\n\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null> {\n return Promise.resolve(\n this.cache.get(this.keyEncoder(prompt, llmKey)) ?? null\n );\n }\n\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n async update(prompt: string, llmKey: string, value: T): Promise<void> {\n this.cache.set(this.keyEncoder(prompt, llmKey), value);\n }\n\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache {\n return new InMemoryCache(GLOBAL_MAP);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAaA,wBAAwC,CAAC,GAAG,YACvD,OAAO,QAAQ,KAAK,IAAI,CAAC;AAE3B,SAAgB,4BACdC,kBACA;AACA,KAAI,iBAAiB,YAAY,OAC/B,QAAO;EACL,MAAM,iBAAiB;EACvB,SAAS,8BAA8B,iBAAiB,QAAQ;CACjE;KAED,QAAO,EAAE,MAAM,iBAAiB,KAAM;AAEzC;AAED,SAAgB,oBAAoBC,YAAwB;CAC1D,MAAMC,kBAAoC,EACxC,MAAM,WAAW,KAClB;AACD,KAAK,WAA8B,YAAY,QAC7C,gBAAgB,UAAW,WAA8B,QAAQ,QAAQ;AAE3E,QAAO;AACR;;;;AAKD,IAAsB,YAAtB,MAAkD;CAChD,AAAU,aAA6B;;;;;;;CAQvC,sBAAsBC,cAAoC;EACxD,KAAK,aAAa;CACnB;AAKF;AAED,MAAM,6BAAa,IAAI;;;;AAKvB,IAAa,gBAAb,MAAa,sBAAwC,UAAa;CAChE,AAAQ;CAER,YAAYC,KAAsB;EAChC,OAAO;EACP,KAAK,QAAQ,uBAAO,IAAI;CACzB;;;;;;;;CASD,OAAOC,QAAgBC,QAAmC;AACxD,SAAO,QAAQ,QACb,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC,IAAI,KACpD;CACF;;;;;;;CAQD,MAAM,OAAOD,QAAgBC,QAAgBC,OAAyB;EACpE,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,EAAE,MAAM;CACvD;;;;;;CAOD,OAAO,SAAwB;AAC7B,SAAO,IAAI,cAAc;CAC1B;AACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AgentAction, AgentFinish } from "../agents.cjs";
|
|
2
2
|
import { SerializedFields } from "../load/map_keys.cjs";
|
|
3
3
|
import { Serializable, Serialized, SerializedNotImplemented } from "../load/serializable.cjs";
|
|
4
|
-
import { ChainValues } from "../utils/types/index.cjs";
|
|
5
4
|
import { BaseMessage } from "../messages/base.cjs";
|
|
5
|
+
import { MessageStructure, MessageType } from "../messages/message.cjs";
|
|
6
6
|
import { ChatGenerationChunk, GenerationChunk, LLMResult } from "../outputs.cjs";
|
|
7
|
+
import { ChainValues } from "../utils/types/index.cjs";
|
|
7
8
|
import { DocumentInterface } from "../documents/document.cjs";
|
|
8
9
|
|
|
9
10
|
//#region src/callbacks/base.d.ts
|
|
@@ -236,7 +237,7 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
|
|
|
236
237
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
237
238
|
* and the run ID.
|
|
238
239
|
*/
|
|
239
|
-
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
|
|
240
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage<MessageStructure, MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
|
|
240
241
|
/**
|
|
241
242
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
242
243
|
* and the run ID.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleCustomEvent?(eventName: string, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any, runId: string, tags?: string[], \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runType?: string | undefined, runName?: string | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n readonly lc_namespace: [\"langchain_core\", \"callbacks\", string];\n readonly lc_secrets: {\n [key: string]: string;\n } | undefined;\n readonly lc_attributes: {\n [key: string]: string;\n } | undefined;\n readonly lc_aliases: {\n [key: string]: string;\n } | undefined;\n readonly lc_serializable_keys: string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n readonly lc_id: string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n name: string;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n"],"mappings":";;;;;;;;;;KAQKY,KAAAA;AAF6D;AAQlE;AAaA;AAKA;;AACYP,UAnBKQ,wBAAAA,CAmBLR;EAAe,SAAGD,CAAAA,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;;;;sBASSG;UACZS;YACEd;0BACcC;8BACIU;;;;;yBAKHX,8FAA8FS,6EAA6EA;;;;2CAIzJH,wGAAwGC;;;;0HAIzBE;;;;0BAIhGX,uGAAuGW;;;;;+BAKlGT,sBAAsBP,gFAAgFgB,6EAA6EA;;;;;6BAKrLT,oBAAoBR,sGAAsGiB;;;;;eAKtIA;;;;;6BAKYjB;eACZiB;;;;;;2BAMUT,oHAAoHS;;;;;;;;;oHAS3BC;;;;;+BAKrFhB,mGAAmGgB;;;;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;;cAIXc"}
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","___messages_message_js5","MessageStructure","MessageType","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleCustomEvent?(eventName: string, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any, runId: string, tags?: string[], \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage<import(\"../messages/message.js\").MessageStructure, import(\"../messages/message.js\").MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runType?: string | undefined, runName?: string | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n readonly lc_namespace: [\"langchain_core\", \"callbacks\", string];\n readonly lc_secrets: {\n [key: string]: string;\n } | undefined;\n readonly lc_attributes: {\n [key: string]: string;\n } | undefined;\n readonly lc_aliases: {\n [key: string]: string;\n } | undefined;\n readonly lc_serializable_keys: string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n readonly lc_id: string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n name: string;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n"],"mappings":";;;;;;;;;;;KAQKY,KAAAA;;AAF6D;AAQlE;AAaA;AAKA;AAA2C,UAlB1BC,wBAAAA,CAkB0B;EAAA,SAC/BR,CAAAA,EAAAA,OAAAA;EAAe,WAAGD,CAAAA,EAAAA,OAAAA;EAAmB,WAAA,CAAA,EAAA,OAAA;EAO1BY,eAAAA,CAAAA,EAAAA,OAAAA;EAA+B,iBAAA,CAAA,EAAA,OAAA;EAAA,aAK7BR,CAAAA,EAAAA,OAAAA;EAAU,UAAwES,CAAAA,EAAAA,OAAAA;;;;;;AAiBlFL,UAnCRE,eAAAA,CAmCQF;EAAK,MAAsEK,EAAAA,MAAAA;EAAM,UACtGC,EAAAA,MAAAA;;;AAKAA,KApCQ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T,sBAAsBP,YAAZ,gBAAA,EAAyE,WAAA,sEAAoHgB,6EAA6EA;;;;;6BAKtRT,oBAAoBR,sGAAsGiB;;;;;eAKtIA;;;;;6BAKYjB;eACZiB;;;;;;2BAMUT,oHAAoHS;;;;;;;;;oHAS3BC;;;;;+BAKrFhB,mGAAmGgB;;;;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;;cAIXiB"}
|
package/dist/callbacks/base.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AgentAction, AgentFinish } from "../agents.js";
|
|
2
2
|
import { SerializedFields } from "../load/map_keys.js";
|
|
3
3
|
import { Serializable, Serialized, SerializedNotImplemented } from "../load/serializable.js";
|
|
4
|
-
import { ChainValues } from "../utils/types/index.js";
|
|
5
4
|
import { BaseMessage } from "../messages/base.js";
|
|
5
|
+
import { MessageStructure, MessageType } from "../messages/message.js";
|
|
6
6
|
import { ChatGenerationChunk, GenerationChunk, LLMResult } from "../outputs.js";
|
|
7
|
+
import { ChainValues } from "../utils/types/index.js";
|
|
7
8
|
import { DocumentInterface } from "../documents/document.js";
|
|
8
9
|
|
|
9
10
|
//#region src/callbacks/base.d.ts
|
|
@@ -236,7 +237,7 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
|
|
|
236
237
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
237
238
|
* and the run ID.
|
|
238
239
|
*/
|
|
239
|
-
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
|
|
240
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage<MessageStructure, MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
|
|
240
241
|
/**
|
|
241
242
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
242
243
|
* and the run ID.
|