@langchain/core 1.1.38 → 1.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/agents.cjs.map +1 -1
- package/dist/agents.js.map +1 -1
- package/dist/callbacks/base.cjs.map +1 -1
- package/dist/callbacks/base.d.cts +71 -40
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/callbacks/base.d.ts +71 -40
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/callbacks/base.js.map +1 -1
- package/dist/callbacks/dispatch/index.cjs.map +1 -1
- package/dist/callbacks/dispatch/index.d.cts +0 -1
- package/dist/callbacks/dispatch/index.d.cts.map +1 -1
- package/dist/callbacks/dispatch/index.d.ts +0 -1
- package/dist/callbacks/dispatch/index.d.ts.map +1 -1
- package/dist/callbacks/dispatch/index.js.map +1 -1
- package/dist/callbacks/dispatch/web.cjs.map +1 -1
- package/dist/callbacks/dispatch/web.d.cts +0 -1
- package/dist/callbacks/dispatch/web.d.cts.map +1 -1
- package/dist/callbacks/dispatch/web.d.ts +0 -1
- package/dist/callbacks/dispatch/web.d.ts.map +1 -1
- package/dist/callbacks/dispatch/web.js.map +1 -1
- package/dist/callbacks/manager.cjs.map +1 -1
- package/dist/callbacks/manager.js.map +1 -1
- package/dist/chat_history.d.cts +0 -1
- package/dist/chat_history.d.cts.map +1 -1
- package/dist/document_loaders/langsmith.cjs.map +1 -1
- package/dist/document_loaders/langsmith.js.map +1 -1
- package/dist/documents/document.cjs.map +1 -1
- package/dist/documents/document.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.map +1 -1
- package/dist/indexing/base.d.cts.map +1 -1
- package/dist/indexing/base.d.ts.map +1 -1
- 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 +1 -1
- package/dist/language_models/base.d.cts.map +1 -1
- package/dist/language_models/base.d.ts +1 -1
- 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.map +1 -1
- package/dist/language_models/chat_models.d.cts +0 -1
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts.map +1 -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.d.cts.map +1 -1
- package/dist/language_models/llms.d.ts.map +1 -1
- package/dist/language_models/llms.js.map +1 -1
- package/dist/language_models/structured_output.cjs.map +1 -1
- package/dist/language_models/structured_output.d.cts +0 -1
- package/dist/language_models/structured_output.d.cts.map +1 -1
- package/dist/language_models/structured_output.d.ts.map +1 -1
- package/dist/language_models/structured_output.js.map +1 -1
- package/dist/load/index.cjs +1 -2
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.js +1 -2
- package/dist/load/index.js.map +1 -1
- package/dist/load/map_keys.cjs.map +1 -1
- package/dist/load/map_keys.js.map +1 -1
- package/dist/load/serializable.cjs.map +1 -1
- package/dist/load/serializable.js.map +1 -1
- package/dist/memory.cjs +2 -8
- package/dist/memory.cjs.map +1 -1
- package/dist/memory.d.cts +2 -2
- package/dist/memory.d.cts.map +1 -1
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +2 -8
- package/dist/memory.js.map +1 -1
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/utils.cjs.map +1 -1
- package/dist/messages/block_translators/utils.js.map +1 -1
- package/dist/messages/chat.cjs.map +1 -1
- package/dist/messages/chat.js.map +1 -1
- package/dist/messages/content/data.cjs.map +1 -1
- package/dist/messages/content/data.d.cts.map +1 -1
- package/dist/messages/content/data.d.ts.map +1 -1
- package/dist/messages/content/data.js.map +1 -1
- package/dist/messages/content/index.cjs.map +1 -1
- package/dist/messages/content/index.js.map +1 -1
- package/dist/messages/content/multimodal.cjs.map +1 -1
- package/dist/messages/content/multimodal.js.map +1 -1
- package/dist/messages/content/tools.cjs.map +1 -1
- package/dist/messages/content/tools.js.map +1 -1
- package/dist/messages/message.cjs.map +1 -1
- package/dist/messages/message.d.cts +3 -2
- package/dist/messages/message.d.cts.map +1 -1
- package/dist/messages/message.d.ts +3 -2
- package/dist/messages/message.d.ts.map +1 -1
- package/dist/messages/message.js.map +1 -1
- package/dist/messages/tool.cjs.map +1 -1
- package/dist/messages/tool.js.map +1 -1
- package/dist/messages/transformers.cjs.map +1 -1
- package/dist/messages/transformers.js.map +1 -1
- package/dist/messages/utils.d.cts.map +1 -1
- package/dist/messages/utils.d.ts.map +1 -1
- package/dist/output_parsers/base.d.cts +0 -1
- package/dist/output_parsers/base.d.cts.map +1 -1
- package/dist/output_parsers/base.d.ts.map +1 -1
- package/dist/output_parsers/json.cjs.map +1 -1
- package/dist/output_parsers/json.d.cts.map +1 -1
- package/dist/output_parsers/json.js.map +1 -1
- package/dist/output_parsers/list.d.cts.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.js.map +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.map +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
- package/dist/output_parsers/standard_schema.cjs.map +1 -1
- package/dist/output_parsers/standard_schema.js.map +1 -1
- package/dist/output_parsers/string.d.cts.map +1 -1
- package/dist/output_parsers/transform.cjs.map +1 -1
- package/dist/output_parsers/transform.js.map +1 -1
- package/dist/output_parsers/xml.cjs +2 -2
- package/dist/output_parsers/xml.cjs.map +1 -1
- package/dist/output_parsers/xml.d.cts +1 -1
- package/dist/output_parsers/xml.d.ts +1 -1
- package/dist/output_parsers/xml.js +2 -2
- package/dist/output_parsers/xml.js.map +1 -1
- package/dist/outputs.cjs.map +1 -1
- package/dist/outputs.js.map +1 -1
- package/dist/prompt_values.cjs.map +1 -1
- package/dist/prompt_values.js.map +1 -1
- package/dist/prompts/base.cjs.map +1 -1
- package/dist/prompts/base.d.cts +0 -1
- package/dist/prompts/base.d.cts.map +1 -1
- package/dist/prompts/base.js.map +1 -1
- package/dist/prompts/chat.cjs.map +1 -1
- package/dist/prompts/chat.d.cts.map +1 -1
- package/dist/prompts/chat.js.map +1 -1
- package/dist/prompts/few_shot.cjs.map +1 -1
- package/dist/prompts/few_shot.d.cts.map +1 -1
- package/dist/prompts/few_shot.js.map +1 -1
- package/dist/prompts/image.cjs.map +1 -1
- package/dist/prompts/image.d.cts.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.map +1 -1
- package/dist/prompts/prompt.js.map +1 -1
- package/dist/prompts/serde.d.cts.map +1 -1
- package/dist/prompts/string.cjs.map +1 -1
- package/dist/prompts/string.js.map +1 -1
- package/dist/prompts/structured.cjs.map +1 -1
- package/dist/prompts/structured.d.cts.map +1 -1
- package/dist/prompts/structured.d.ts.map +1 -1
- package/dist/prompts/structured.js.map +1 -1
- package/dist/prompts/template.cjs +2 -5
- package/dist/prompts/template.cjs.map +1 -1
- package/dist/prompts/template.d.cts +0 -1
- package/dist/prompts/template.d.cts.map +1 -1
- package/dist/prompts/template.d.ts.map +1 -1
- package/dist/prompts/template.js +2 -5
- package/dist/prompts/template.js.map +1 -1
- package/dist/retrievers/document_compressors/index.cjs.map +1 -1
- package/dist/retrievers/document_compressors/index.js.map +1 -1
- package/dist/retrievers/index.cjs.map +1 -1
- package/dist/retrievers/index.d.cts.map +1 -1
- package/dist/retrievers/index.d.ts.map +1 -1
- package/dist/retrievers/index.js.map +1 -1
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.cjs.map +1 -1
- package/dist/runnables/branch.d.cts.map +1 -1
- package/dist/runnables/branch.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/runnables/graph.js.map +1 -1
- package/dist/runnables/history.cjs +2 -4
- package/dist/runnables/history.cjs.map +1 -1
- package/dist/runnables/history.d.cts +2 -4
- package/dist/runnables/history.d.cts.map +1 -1
- package/dist/runnables/history.d.ts +2 -4
- package/dist/runnables/history.d.ts.map +1 -1
- package/dist/runnables/history.js +2 -4
- package/dist/runnables/history.js.map +1 -1
- package/dist/runnables/passthrough.cjs.map +1 -1
- package/dist/runnables/passthrough.d.cts.map +1 -1
- package/dist/runnables/passthrough.d.ts.map +1 -1
- package/dist/runnables/passthrough.js.map +1 -1
- package/dist/runnables/router.cjs.map +1 -1
- package/dist/runnables/router.d.cts.map +1 -1
- package/dist/runnables/router.d.ts.map +1 -1
- package/dist/runnables/router.js.map +1 -1
- package/dist/runnables/utils.cjs.map +1 -1
- package/dist/runnables/utils.js.map +1 -1
- package/dist/singletons/async_local_storage/context.cjs.map +1 -1
- package/dist/singletons/async_local_storage/context.d.cts.map +1 -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/async_local_storage/globals.cjs.map +1 -1
- package/dist/singletons/async_local_storage/globals.js.map +1 -1
- package/dist/singletons/async_local_storage/index.cjs.map +1 -1
- package/dist/singletons/async_local_storage/index.js.map +1 -1
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.d.cts.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/stores.cjs.map +1 -1
- package/dist/stores.js.map +1 -1
- package/dist/structured_query/ir.d.cts.map +1 -1
- package/dist/structured_query/ir.d.ts.map +1 -1
- package/dist/structured_query/utils.cjs.map +1 -1
- package/dist/structured_query/utils.js.map +1 -1
- package/dist/testing/fake_model_builder.cjs.map +1 -1
- package/dist/testing/fake_model_builder.d.cts.map +1 -1
- package/dist/testing/fake_model_builder.js.map +1 -1
- package/dist/testing/matchers.cjs.map +1 -1
- package/dist/testing/matchers.d.cts +8 -8
- package/dist/testing/matchers.d.cts.map +1 -1
- package/dist/testing/matchers.d.ts +8 -8
- package/dist/testing/matchers.d.ts.map +1 -1
- package/dist/testing/matchers.js.map +1 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +3 -2
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts +3 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.d.cts +1 -1
- package/dist/tools/types.d.cts.map +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tracers/base.cjs.map +1 -1
- package/dist/tracers/base.d.cts +91 -91
- package/dist/tracers/base.d.cts.map +1 -1
- package/dist/tracers/base.d.ts +91 -91
- package/dist/tracers/base.d.ts.map +1 -1
- package/dist/tracers/base.js.map +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.js.map +1 -1
- package/dist/tracers/log_stream.cjs.map +1 -1
- package/dist/tracers/log_stream.d.cts.map +1 -1
- package/dist/tracers/log_stream.d.ts.map +1 -1
- package/dist/tracers/log_stream.js.map +1 -1
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/chunk_array.d.cts.map +1 -1
- package/dist/utils/chunk_array.d.ts.map +1 -1
- package/dist/utils/env.cjs.map +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 +2 -2
- package/dist/utils/event_source_parse.d.cts.map +1 -1
- package/dist/utils/event_source_parse.d.ts +2 -2
- package/dist/utils/event_source_parse.d.ts.map +1 -1
- package/dist/utils/event_source_parse.js.map +1 -1
- package/dist/utils/function_calling.cjs.map +1 -1
- package/dist/utils/function_calling.js.map +1 -1
- package/dist/utils/is-network-error/index.cjs.map +1 -1
- package/dist/utils/is-network-error/index.js.map +1 -1
- package/dist/utils/json.cjs.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/json_schema.d.cts.map +1 -1
- package/dist/utils/namespace.cjs.map +1 -1
- package/dist/utils/namespace.js.map +1 -1
- package/dist/utils/p-retry/index.cjs.map +1 -1
- package/dist/utils/p-retry/index.js.map +1 -1
- package/dist/utils/signal.cjs.map +1 -1
- package/dist/utils/signal.js.map +1 -1
- package/dist/utils/standard_schema.cjs.map +1 -1
- package/dist/utils/standard_schema.js.map +1 -1
- package/dist/utils/stream.cjs.map +1 -1
- package/dist/utils/stream.d.cts +2 -2
- package/dist/utils/stream.d.cts.map +1 -1
- package/dist/utils/stream.d.ts +2 -2
- package/dist/utils/stream.d.ts.map +1 -1
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/testing/chat_models.cjs.map +1 -1
- package/dist/utils/testing/chat_models.d.cts.map +1 -1
- package/dist/utils/testing/chat_models.js.map +1 -1
- package/dist/utils/testing/retrievers.cjs.map +1 -1
- package/dist/utils/testing/retrievers.js.map +1 -1
- package/dist/utils/testing/vectorstores.cjs.map +1 -1
- package/dist/utils/testing/vectorstores.js.map +1 -1
- package/dist/utils/types/index.cjs.map +1 -1
- package/dist/utils/types/index.js.map +1 -1
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.js.map +1 -1
- package/dist/utils/zod-to-json-schema/Options.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/Refs.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/index.d.cts +24 -0
- package/dist/utils/zod-to-json-schema/parseDef.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/branded.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/default.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/map.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/never.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/number.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/object.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/optional.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/set.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/string.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/union.d.cts +1 -2
- package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +0 -1
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -1
- package/dist/utils/zod-to-json-schema/selectParser.d.cts +1 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.d.cts +1 -0
- package/dist/vectorstores.cjs.map +1 -1
- package/dist/vectorstores.js.map +1 -1
- package/package.json +5 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @langchain/core
|
|
2
2
|
|
|
3
|
+
## 1.1.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#10430](https://github.com/langchain-ai/langchainjs/pull/10430) [`d3d0922`](https://github.com/langchain-ai/langchainjs/commit/d3d0922c24afcd3006fb94dcadd3ebe08fbf2383) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(langchain): support for browser tools
|
|
8
|
+
|
|
3
9
|
## 1.1.38
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/agents.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.cjs","names":[],"sources":["../src/agents.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n //
|
|
1
|
+
{"version":3,"file":"agents.cjs","names":[],"sources":["../src/agents.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n toolInput: string | Record<string, any>;\n log: string;\n};\n\nexport type AgentFinish = {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n returnValues: Record<string, any>;\n log: string;\n};\n\nexport type AgentStep = {\n action: AgentAction;\n observation: string;\n};\n"],"mappings":""}
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","names":[],"sources":["../src/agents.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n //
|
|
1
|
+
{"version":3,"file":"agents.js","names":[],"sources":["../src/agents.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n toolInput: string | Record<string, any>;\n log: string;\n};\n\nexport type AgentFinish = {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n returnValues: Record<string, any>;\n log: string;\n};\n\nexport type AgentStep = {\n action: AgentAction;\n observation: string;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","names":["get_lc_unique_name","getEnvironmentVariable","Serializable"],"sources":["../../src/callbacks/base.ts"],"sourcesContent":["import * as uuid from \"uuid\";\nimport type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type {\n ChatGenerationChunk,\n GenerationChunk,\n LLMResult,\n} from \"../outputs.js\";\nimport {\n Serializable,\n Serialized,\n SerializedNotImplemented,\n get_lc_unique_name,\n} from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n\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/**\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\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\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 */\nabstract 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?(\n llm: Serialized,\n prompts: string[],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(\n 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,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n fields?: HandleLLMNewTokenCallbackFields\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(\n output: LLMResult,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(\n llm: Serialized,\n messages: BaseMessage[][],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(\n chain: Serialized,\n inputs: ChainValues,\n runId: string,\n runType?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n parentRunId?: string,\n extra?: Record<string, unknown>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(\n outputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(\n tool: Serialized,\n input: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n toolCallId?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\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,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when a streaming tool yields a partial value. Tools that are async generators\n * invoke this once per yielded value.\n */\n handleToolEvent?(\n chunk: unknown,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleText?(\n text: string,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(\n action: AgentAction,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(\n action: AgentFinish,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n handleRetrieverStart?(\n retriever: Serialized,\n query: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n name?: string\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverEnd?(\n documents: DocumentInterface[],\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleCustomEvent?(\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n runId: string,\n tags?: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\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/**\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}\n\nexport function callbackHandlerPrefersStreaming(x: BaseCallbackHandler) {\n return \"lc_prefer_streaming\" in x && x.lc_prefer_streaming;\n}\n\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 abstract class BaseCallbackHandler\n extends BaseCallbackHandlerMethodsClass\n implements BaseCallbackHandlerInput, Serializable\n{\n lc_serializable = false;\n\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string] {\n return [\"langchain_core\", \"callbacks\", this.name];\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_attributes(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\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 return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof BaseCallbackHandler),\n ];\n }\n\n lc_kwargs: SerializedFields;\n\n abstract name: string;\n\n ignoreLLM = false;\n\n ignoreChain = false;\n\n ignoreAgent = false;\n\n ignoreRetriever = false;\n\n ignoreCustomEvent = false;\n\n raiseError = false;\n\n awaitHandlers =\n getEnvironmentVariable(\"LANGCHAIN_CALLBACKS_BACKGROUND\") === \"false\";\n\n constructor(input?: BaseCallbackHandlerInput) {\n super();\n this.lc_kwargs = input || {};\n if (input) {\n this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;\n this.ignoreChain = input.ignoreChain ?? this.ignoreChain;\n this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;\n this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;\n this.ignoreCustomEvent =\n input.ignoreCustomEvent ?? this.ignoreCustomEvent;\n this.raiseError = input.raiseError ?? this.raiseError;\n this.awaitHandlers =\n this.raiseError || (input._awaitHandler ?? this.awaitHandlers);\n }\n }\n\n copy(): BaseCallbackHandler {\n return new (this.constructor as new (\n input?: BaseCallbackHandlerInput\n ) => BaseCallbackHandler)(this);\n }\n\n toJSON(): Serialized {\n return Serializable.prototype.toJSON.call(this);\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return Serializable.prototype.toJSONNotImplemented.call(this);\n }\n\n static fromMethods(methods: CallbackHandlerMethods) {\n class Handler extends BaseCallbackHandler {\n name = uuid.v7();\n\n constructor() {\n super();\n Object.assign(this, methods);\n }\n }\n return new Handler();\n }\n}\n\nexport const isBaseCallbackHandler = (x: unknown) => {\n const callbackHandler = x as BaseCallbackHandler;\n return (\n callbackHandler !== undefined &&\n typeof callbackHandler.copy === \"function\" &&\n typeof callbackHandler.name === \"string\" &&\n typeof callbackHandler.awaitHandlers === \"boolean\"\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAe,kCAAf,MAA+C;AAgQ/C,SAAgB,gCAAgC,GAAwB;AACtE,QAAO,yBAAyB,KAAK,EAAE;;;;;;;;AASzC,IAAsB,sBAAtB,cACU,gCAEV;CACE,kBAAkB;CAElB,IAAI,eAAwD;AAC1D,SAAO;GAAC;GAAkB;GAAa,KAAK;GAAK;;CAGnD,IAAI,aAAoD;CAIxD,IAAI,gBAAuD;CAI3D,IAAI,aAAoD;CAIxD,IAAI,uBAA6C;;;;;;;CAUjD,OAAO,UAAkB;AACvB,SAAO,KAAK;;;;;CAMd,IAAI,QAAkB;AACpB,SAAO,CACL,GAAG,KAAK,cACRA,0BAAAA,mBAAmB,KAAK,YAA0C,CACnE;;CAGH;CAIA,YAAY;CAEZ,cAAc;CAEd,cAAc;CAEd,kBAAkB;CAElB,oBAAoB;CAEpB,aAAa;CAEb,gBACEC,kBAAAA,uBAAuB,iCAAiC,KAAK;CAE/D,YAAY,OAAkC;AAC5C,SAAO;AACP,OAAK,YAAY,SAAS,EAAE;AAC5B,MAAI,OAAO;AACT,QAAK,YAAY,MAAM,aAAa,KAAK;AACzC,QAAK,cAAc,MAAM,eAAe,KAAK;AAC7C,QAAK,cAAc,MAAM,eAAe,KAAK;AAC7C,QAAK,kBAAkB,MAAM,mBAAmB,KAAK;AACrD,QAAK,oBACH,MAAM,qBAAqB,KAAK;AAClC,QAAK,aAAa,MAAM,cAAc,KAAK;AAC3C,QAAK,gBACH,KAAK,eAAe,MAAM,iBAAiB,KAAK;;;CAItD,OAA4B;AAC1B,SAAO,IAAK,KAAK,YAES,KAAK;;CAGjC,SAAqB;AACnB,SAAOC,0BAAAA,aAAa,UAAU,OAAO,KAAK,KAAK;;CAGjD,uBAAiD;AAC/C,SAAOA,0BAAAA,aAAa,UAAU,qBAAqB,KAAK,KAAK;;CAG/D,OAAO,YAAY,SAAiC;EAClD,MAAM,gBAAgB,oBAAoB;GACxC,OAAO,KAAK,IAAI;GAEhB,cAAc;AACZ,WAAO;AACP,WAAO,OAAO,MAAM,QAAQ;;;AAGhC,SAAO,IAAI,SAAS;;;AAIxB,MAAa,yBAAyB,MAAe;CACnD,MAAM,kBAAkB;AACxB,QACE,oBAAoB,KAAA,KACpB,OAAO,gBAAgB,SAAS,cAChC,OAAO,gBAAgB,SAAS,YAChC,OAAO,gBAAgB,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["get_lc_unique_name","getEnvironmentVariable","Serializable"],"sources":["../../src/callbacks/base.ts"],"sourcesContent":["import * as uuid from \"uuid\";\nimport type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type {\n ChatGenerationChunk,\n GenerationChunk,\n LLMResult,\n} from \"../outputs.js\";\nimport {\n Serializable,\n Serialized,\n SerializedNotImplemented,\n get_lc_unique_name,\n} from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n\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/**\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\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\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 */\nabstract 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?(\n llm: Serialized,\n prompts: string[],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(\n 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,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n fields?: HandleLLMNewTokenCallbackFields\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(\n output: LLMResult,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n extraParams?: Record<string, unknown>\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(\n llm: Serialized,\n messages: BaseMessage[][],\n runId: string,\n parentRunId?: string,\n extraParams?: Record<string, unknown>,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(\n chain: Serialized,\n inputs: ChainValues,\n runId: string,\n runType?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n parentRunId?: string,\n extra?: Record<string, unknown>\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(\n outputs: ChainValues,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n kwargs?: { inputs?: Record<string, unknown> }\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(\n tool: Serialized,\n input: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n runName?: string,\n toolCallId?: string\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n output: any,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n /**\n * Called when a streaming tool yields a partial value. Tools that are async generators\n * invoke this once per yielded value.\n */\n handleToolEvent?(\n chunk: unknown,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleText?(\n text: string,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(\n action: AgentAction,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(\n action: AgentFinish,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): Promise<void> | void;\n\n handleRetrieverStart?(\n retriever: Serialized,\n query: string,\n runId: string,\n parentRunId?: string,\n tags?: string[],\n metadata?: Record<string, unknown>,\n name?: string\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverEnd?(\n documents: DocumentInterface[],\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleRetrieverError?(\n err: Error,\n runId: string,\n parentRunId?: string,\n tags?: string[]\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n\n handleCustomEvent?(\n eventName: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n data: any,\n runId: string,\n tags?: string[],\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\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/**\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}\n\nexport function callbackHandlerPrefersStreaming(x: BaseCallbackHandler) {\n return \"lc_prefer_streaming\" in x && x.lc_prefer_streaming;\n}\n\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 abstract class BaseCallbackHandler\n extends BaseCallbackHandlerMethodsClass\n implements BaseCallbackHandlerInput, Serializable\n{\n lc_serializable = false;\n\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string] {\n return [\"langchain_core\", \"callbacks\", this.name];\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_attributes(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\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 return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof BaseCallbackHandler),\n ];\n }\n\n lc_kwargs: SerializedFields;\n\n abstract name: string;\n\n ignoreLLM = false;\n\n ignoreChain = false;\n\n ignoreAgent = false;\n\n ignoreRetriever = false;\n\n ignoreCustomEvent = false;\n\n raiseError = false;\n\n awaitHandlers =\n getEnvironmentVariable(\"LANGCHAIN_CALLBACKS_BACKGROUND\") === \"false\";\n\n constructor(input?: BaseCallbackHandlerInput) {\n super();\n this.lc_kwargs = input || {};\n if (input) {\n this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;\n this.ignoreChain = input.ignoreChain ?? this.ignoreChain;\n this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;\n this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;\n this.ignoreCustomEvent =\n input.ignoreCustomEvent ?? this.ignoreCustomEvent;\n this.raiseError = input.raiseError ?? this.raiseError;\n this.awaitHandlers =\n this.raiseError || (input._awaitHandler ?? this.awaitHandlers);\n }\n }\n\n copy(): BaseCallbackHandler {\n return new (this.constructor as new (\n input?: BaseCallbackHandlerInput\n ) => BaseCallbackHandler)(this);\n }\n\n toJSON(): Serialized {\n return Serializable.prototype.toJSON.call(this);\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return Serializable.prototype.toJSONNotImplemented.call(this);\n }\n\n static fromMethods(methods: CallbackHandlerMethods) {\n class Handler extends BaseCallbackHandler {\n name = uuid.v7();\n\n constructor() {\n super();\n Object.assign(this, methods);\n }\n }\n return new Handler();\n }\n}\n\nexport const isBaseCallbackHandler = (x: unknown) => {\n const callbackHandler = x as BaseCallbackHandler;\n return (\n callbackHandler !== undefined &&\n typeof callbackHandler.copy === \"function\" &&\n typeof callbackHandler.name === \"string\" &&\n typeof callbackHandler.awaitHandlers === \"boolean\"\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,IAAe,kCAAf,MAA+C;AAgQ/C,SAAgB,gCAAgC,GAAwB;AACtE,QAAO,yBAAyB,KAAK,EAAE;;;;;;;;AASzC,IAAsB,sBAAtB,cACU,gCAEV;CACE,kBAAkB;CAElB,IAAI,eAAwD;AAC1D,SAAO;GAAC;GAAkB;GAAa,KAAK;GAAK;;CAGnD,IAAI,aAAoD;CAIxD,IAAI,gBAAuD;CAI3D,IAAI,aAAoD;CAIxD,IAAI,uBAA6C;;;;;;;CAUjD,OAAO,UAAkB;AACvB,SAAO,KAAK;;;;;CAMd,IAAI,QAAkB;AACpB,SAAO,CACL,GAAG,KAAK,cACRA,0BAAAA,mBAAmB,KAAK,YAA0C,CACnE;;CAGH;CAIA,YAAY;CAEZ,cAAc;CAEd,cAAc;CAEd,kBAAkB;CAElB,oBAAoB;CAEpB,aAAa;CAEb,gBACEC,kBAAAA,uBAAuB,iCAAiC,KAAK;CAE/D,YAAY,OAAkC;AAC5C,SAAO;AACP,OAAK,YAAY,SAAS,EAAE;AAC5B,MAAI,OAAO;AACT,QAAK,YAAY,MAAM,aAAa,KAAK;AACzC,QAAK,cAAc,MAAM,eAAe,KAAK;AAC7C,QAAK,cAAc,MAAM,eAAe,KAAK;AAC7C,QAAK,kBAAkB,MAAM,mBAAmB,KAAK;AACrD,QAAK,oBACH,MAAM,qBAAqB,KAAK;AAClC,QAAK,aAAa,MAAM,cAAc,KAAK;AAC3C,QAAK,gBACH,KAAK,eAAe,MAAM,iBAAiB,KAAK;;;CAItD,OAA4B;AAC1B,SAAO,IAAK,KAAK,YAES,KAAK;;CAGjC,SAAqB;AACnB,SAAOC,0BAAAA,aAAa,UAAU,OAAO,KAAK,KAAK;;CAGjD,uBAAiD;AAC/C,SAAOA,0BAAAA,aAAa,UAAU,qBAAqB,KAAK,KAAK;;CAG/D,OAAO,YAAY,SAAiC;EAClD,MAAM,gBAAgB,oBAAoB;GACxC,OAAO,KAAK,IAAI;GAEhB,cAAc;AACZ,WAAO;AACP,WAAO,OAAO,MAAM,QAAQ;;;AAGhC,SAAO,IAAI,SAAS;;;AAIxB,MAAa,yBAAyB,MAAe;CACnD,MAAM,kBAAkB;AACxB,QACE,oBAAoB,KAAA,KACpB,OAAO,gBAAgB,SAAS,cAChC,OAAO,gBAAgB,SAAS,YAChC,OAAO,gBAAgB,kBAAkB"}
|
|
@@ -2,7 +2,6 @@ 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
4
|
import { BaseMessage } from "../messages/base.cjs";
|
|
5
|
-
import { MessageStructure, MessageToolSet, MessageType } from "../messages/message.cjs";
|
|
6
5
|
import { ChatGenerationChunk, GenerationChunk, LLMResult } from "../outputs.cjs";
|
|
7
6
|
import { ChainValues } from "../utils/types/index.cjs";
|
|
8
7
|
import { DocumentInterface } from "../documents/document.cjs";
|
|
@@ -44,7 +43,8 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
44
43
|
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
45
44
|
* and the run ID.
|
|
46
45
|
*/
|
|
47
|
-
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string):
|
|
46
|
+
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
Promise<any> | any;
|
|
48
48
|
/**
|
|
49
49
|
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
50
50
|
*/
|
|
@@ -56,55 +56,66 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
56
56
|
* (if multiple completions per prompt are requested)
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields):
|
|
59
|
+
idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
Promise<any> | any;
|
|
60
61
|
/**
|
|
61
62
|
* Called if an LLM/ChatModel run encounters an error
|
|
62
63
|
*/
|
|
63
|
-
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>):
|
|
64
|
+
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
Promise<any> | any;
|
|
64
66
|
/**
|
|
65
67
|
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
66
68
|
*/
|
|
67
|
-
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>):
|
|
69
|
+
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
Promise<any> | any;
|
|
68
71
|
/**
|
|
69
72
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
70
73
|
* and the run ID.
|
|
71
74
|
*/
|
|
72
|
-
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string):
|
|
75
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
Promise<any> | any;
|
|
73
77
|
/**
|
|
74
78
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
75
79
|
* and the run ID.
|
|
76
80
|
*/
|
|
77
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>):
|
|
81
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
Promise<any> | any;
|
|
78
83
|
/**
|
|
79
84
|
* Called if a Chain run encounters an error
|
|
80
85
|
*/
|
|
81
86
|
handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
82
87
|
inputs?: Record<string, unknown>;
|
|
83
|
-
}):
|
|
88
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
Promise<any> | any;
|
|
84
90
|
/**
|
|
85
91
|
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
86
92
|
*/
|
|
87
93
|
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
88
94
|
inputs?: Record<string, unknown>;
|
|
89
|
-
}):
|
|
95
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
Promise<any> | any;
|
|
90
97
|
/**
|
|
91
98
|
* Called at the start of a Tool run, with the tool name and input
|
|
92
99
|
* and the run ID.
|
|
93
100
|
*/
|
|
94
|
-
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string):
|
|
101
|
+
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
Promise<any> | any;
|
|
95
103
|
/**
|
|
96
104
|
* Called if a Tool run encounters an error
|
|
97
105
|
*/
|
|
98
|
-
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]):
|
|
106
|
+
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
Promise<any> | any;
|
|
99
108
|
/**
|
|
100
109
|
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
101
110
|
*/
|
|
102
|
-
handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]):
|
|
111
|
+
handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
Promise<any> | any;
|
|
103
113
|
/**
|
|
104
114
|
* Called when a streaming tool yields a partial value. Tools that are async generators
|
|
105
115
|
* invoke this once per yielded value.
|
|
106
116
|
*/
|
|
107
|
-
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string, tags?: string[]):
|
|
117
|
+
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
Promise<any> | any;
|
|
108
119
|
handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
109
120
|
/**
|
|
110
121
|
* Called when an agent is about to execute an action,
|
|
@@ -116,10 +127,14 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
116
127
|
* with the final output and the run ID.
|
|
117
128
|
*/
|
|
118
129
|
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
119
|
-
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string):
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
Promise<any> | any;
|
|
132
|
+
handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
Promise<any> | any;
|
|
134
|
+
handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
Promise<any> | any;
|
|
136
|
+
handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
Promise<any> | any;
|
|
123
138
|
}
|
|
124
139
|
/**
|
|
125
140
|
* Base interface for callbacks. All methods are optional. If a method is not
|
|
@@ -189,74 +204,90 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
|
|
|
189
204
|
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
190
205
|
* and the run ID.
|
|
191
206
|
*/
|
|
192
|
-
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string
|
|
207
|
+
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
|
+
Promise<any> | any;
|
|
193
209
|
/**
|
|
194
210
|
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
195
211
|
*/
|
|
196
|
-
handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string
|
|
212
|
+
handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
213
|
+
Promise<any> | any;
|
|
197
214
|
/**
|
|
198
215
|
* Called if an LLM/ChatModel run encounters an error
|
|
199
216
|
*/
|
|
200
|
-
handleLLMError?(err:
|
|
217
|
+
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
|
+
Promise<any> | any;
|
|
201
219
|
/**
|
|
202
220
|
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
203
221
|
*/
|
|
204
|
-
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string
|
|
222
|
+
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
Promise<any> | any;
|
|
205
224
|
/**
|
|
206
225
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
207
226
|
* and the run ID.
|
|
208
227
|
*/
|
|
209
|
-
handleChatModelStart?(llm: Serialized, messages: BaseMessage
|
|
228
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
Promise<any> | any;
|
|
210
230
|
/**
|
|
211
231
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
212
232
|
* and the run ID.
|
|
213
233
|
*/
|
|
214
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string
|
|
234
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
235
|
+
Promise<any> | any;
|
|
215
236
|
/**
|
|
216
237
|
* Called if a Chain run encounters an error
|
|
217
238
|
*/
|
|
218
|
-
handleChainError?(err:
|
|
219
|
-
inputs?: Record<string, unknown
|
|
220
|
-
}
|
|
239
|
+
handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
240
|
+
inputs?: Record<string, unknown>;
|
|
241
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
+
Promise<any> | any;
|
|
221
243
|
/**
|
|
222
244
|
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
223
245
|
*/
|
|
224
|
-
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string
|
|
225
|
-
inputs?: Record<string, unknown
|
|
226
|
-
}
|
|
246
|
+
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
247
|
+
inputs?: Record<string, unknown>;
|
|
248
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
|
+
Promise<any> | any;
|
|
227
250
|
/**
|
|
228
251
|
* Called at the start of a Tool run, with the tool name and input
|
|
229
252
|
* and the run ID.
|
|
230
253
|
*/
|
|
231
|
-
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string
|
|
254
|
+
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
Promise<any> | any;
|
|
232
256
|
/**
|
|
233
257
|
* Called if a Tool run encounters an error
|
|
234
258
|
*/
|
|
235
|
-
handleToolError?(err:
|
|
259
|
+
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
+
Promise<any> | any;
|
|
236
261
|
/**
|
|
237
262
|
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
238
263
|
*/
|
|
239
|
-
handleToolEnd?(output: any, runId: string, parentRunId?: string
|
|
264
|
+
handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
Promise<any> | any;
|
|
240
266
|
/**
|
|
241
267
|
* Called when a streaming tool yields a partial value. Tools that are async generators
|
|
242
268
|
* invoke this once per yielded value.
|
|
243
269
|
*/
|
|
244
|
-
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string
|
|
245
|
-
|
|
270
|
+
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271
|
+
Promise<any> | any;
|
|
272
|
+
handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
246
273
|
/**
|
|
247
274
|
* Called when an agent is about to execute an action,
|
|
248
275
|
* with the action and the run ID.
|
|
249
276
|
*/
|
|
250
|
-
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string
|
|
277
|
+
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
251
278
|
/**
|
|
252
279
|
* Called when an agent finishes execution, before it exits.
|
|
253
280
|
* with the final output and the run ID.
|
|
254
281
|
*/
|
|
255
|
-
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string
|
|
256
|
-
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
282
|
+
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
283
|
+
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
|
+
Promise<any> | any;
|
|
285
|
+
handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
|
+
Promise<any> | any;
|
|
287
|
+
handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
|
+
Promise<any> | any;
|
|
289
|
+
handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
290
|
+
Promise<any> | any;
|
|
260
291
|
lc_serializable: boolean;
|
|
261
292
|
get lc_namespace(): ["langchain_core", "callbacks", string];
|
|
262
293
|
get lc_secrets(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":[],"sources":["../../src/callbacks/base.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":[],"sources":["../../src/callbacks/base.ts"],"mappings":"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"}
|
package/dist/callbacks/base.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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
4
|
import { BaseMessage } from "../messages/base.js";
|
|
5
|
-
import { MessageStructure, MessageToolSet, MessageType } from "../messages/message.js";
|
|
6
5
|
import { ChatGenerationChunk, GenerationChunk, LLMResult } from "../outputs.js";
|
|
7
6
|
import { ChainValues } from "../utils/types/index.js";
|
|
8
7
|
import { DocumentInterface } from "../documents/document.js";
|
|
@@ -44,7 +43,8 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
44
43
|
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
45
44
|
* and the run ID.
|
|
46
45
|
*/
|
|
47
|
-
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string):
|
|
46
|
+
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
Promise<any> | any;
|
|
48
48
|
/**
|
|
49
49
|
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
50
50
|
*/
|
|
@@ -56,55 +56,66 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
56
56
|
* (if multiple completions per prompt are requested)
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields):
|
|
59
|
+
idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
Promise<any> | any;
|
|
60
61
|
/**
|
|
61
62
|
* Called if an LLM/ChatModel run encounters an error
|
|
62
63
|
*/
|
|
63
|
-
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>):
|
|
64
|
+
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
Promise<any> | any;
|
|
64
66
|
/**
|
|
65
67
|
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
66
68
|
*/
|
|
67
|
-
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>):
|
|
69
|
+
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
Promise<any> | any;
|
|
68
71
|
/**
|
|
69
72
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
70
73
|
* and the run ID.
|
|
71
74
|
*/
|
|
72
|
-
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string):
|
|
75
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
Promise<any> | any;
|
|
73
77
|
/**
|
|
74
78
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
75
79
|
* and the run ID.
|
|
76
80
|
*/
|
|
77
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>):
|
|
81
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
Promise<any> | any;
|
|
78
83
|
/**
|
|
79
84
|
* Called if a Chain run encounters an error
|
|
80
85
|
*/
|
|
81
86
|
handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
82
87
|
inputs?: Record<string, unknown>;
|
|
83
|
-
}):
|
|
88
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
Promise<any> | any;
|
|
84
90
|
/**
|
|
85
91
|
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
86
92
|
*/
|
|
87
93
|
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
88
94
|
inputs?: Record<string, unknown>;
|
|
89
|
-
}):
|
|
95
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
Promise<any> | any;
|
|
90
97
|
/**
|
|
91
98
|
* Called at the start of a Tool run, with the tool name and input
|
|
92
99
|
* and the run ID.
|
|
93
100
|
*/
|
|
94
|
-
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string):
|
|
101
|
+
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
Promise<any> | any;
|
|
95
103
|
/**
|
|
96
104
|
* Called if a Tool run encounters an error
|
|
97
105
|
*/
|
|
98
|
-
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]):
|
|
106
|
+
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
Promise<any> | any;
|
|
99
108
|
/**
|
|
100
109
|
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
101
110
|
*/
|
|
102
|
-
handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]):
|
|
111
|
+
handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
Promise<any> | any;
|
|
103
113
|
/**
|
|
104
114
|
* Called when a streaming tool yields a partial value. Tools that are async generators
|
|
105
115
|
* invoke this once per yielded value.
|
|
106
116
|
*/
|
|
107
|
-
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string, tags?: string[]):
|
|
117
|
+
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
Promise<any> | any;
|
|
108
119
|
handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
109
120
|
/**
|
|
110
121
|
* Called when an agent is about to execute an action,
|
|
@@ -116,10 +127,14 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
116
127
|
* with the final output and the run ID.
|
|
117
128
|
*/
|
|
118
129
|
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
119
|
-
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string):
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
Promise<any> | any;
|
|
132
|
+
handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
Promise<any> | any;
|
|
134
|
+
handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
Promise<any> | any;
|
|
136
|
+
handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
Promise<any> | any;
|
|
123
138
|
}
|
|
124
139
|
/**
|
|
125
140
|
* Base interface for callbacks. All methods are optional. If a method is not
|
|
@@ -189,74 +204,90 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
|
|
|
189
204
|
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
190
205
|
* and the run ID.
|
|
191
206
|
*/
|
|
192
|
-
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string
|
|
207
|
+
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
|
+
Promise<any> | any;
|
|
193
209
|
/**
|
|
194
210
|
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
195
211
|
*/
|
|
196
|
-
handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string
|
|
212
|
+
handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
213
|
+
Promise<any> | any;
|
|
197
214
|
/**
|
|
198
215
|
* Called if an LLM/ChatModel run encounters an error
|
|
199
216
|
*/
|
|
200
|
-
handleLLMError?(err:
|
|
217
|
+
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
|
+
Promise<any> | any;
|
|
201
219
|
/**
|
|
202
220
|
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
203
221
|
*/
|
|
204
|
-
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string
|
|
222
|
+
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
Promise<any> | any;
|
|
205
224
|
/**
|
|
206
225
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
207
226
|
* and the run ID.
|
|
208
227
|
*/
|
|
209
|
-
handleChatModelStart?(llm: Serialized, messages: BaseMessage
|
|
228
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
Promise<any> | any;
|
|
210
230
|
/**
|
|
211
231
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
212
232
|
* and the run ID.
|
|
213
233
|
*/
|
|
214
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string
|
|
234
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, runType?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, extra?: Record<string, unknown>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
235
|
+
Promise<any> | any;
|
|
215
236
|
/**
|
|
216
237
|
* Called if a Chain run encounters an error
|
|
217
238
|
*/
|
|
218
|
-
handleChainError?(err:
|
|
219
|
-
inputs?: Record<string, unknown
|
|
220
|
-
}
|
|
239
|
+
handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
240
|
+
inputs?: Record<string, unknown>;
|
|
241
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
+
Promise<any> | any;
|
|
221
243
|
/**
|
|
222
244
|
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
223
245
|
*/
|
|
224
|
-
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string
|
|
225
|
-
inputs?: Record<string, unknown
|
|
226
|
-
}
|
|
246
|
+
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {
|
|
247
|
+
inputs?: Record<string, unknown>;
|
|
248
|
+
}): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
|
+
Promise<any> | any;
|
|
227
250
|
/**
|
|
228
251
|
* Called at the start of a Tool run, with the tool name and input
|
|
229
252
|
* and the run ID.
|
|
230
253
|
*/
|
|
231
|
-
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string
|
|
254
|
+
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
Promise<any> | any;
|
|
232
256
|
/**
|
|
233
257
|
* Called if a Tool run encounters an error
|
|
234
258
|
*/
|
|
235
|
-
handleToolError?(err:
|
|
259
|
+
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
+
Promise<any> | any;
|
|
236
261
|
/**
|
|
237
262
|
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
238
263
|
*/
|
|
239
|
-
handleToolEnd?(output: any, runId: string, parentRunId?: string
|
|
264
|
+
handleToolEnd?(output: any, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
Promise<any> | any;
|
|
240
266
|
/**
|
|
241
267
|
* Called when a streaming tool yields a partial value. Tools that are async generators
|
|
242
268
|
* invoke this once per yielded value.
|
|
243
269
|
*/
|
|
244
|
-
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string
|
|
245
|
-
|
|
270
|
+
handleToolEvent?(chunk: unknown, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271
|
+
Promise<any> | any;
|
|
272
|
+
handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
246
273
|
/**
|
|
247
274
|
* Called when an agent is about to execute an action,
|
|
248
275
|
* with the action and the run ID.
|
|
249
276
|
*/
|
|
250
|
-
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string
|
|
277
|
+
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
251
278
|
/**
|
|
252
279
|
* Called when an agent finishes execution, before it exits.
|
|
253
280
|
* with the final output and the run ID.
|
|
254
281
|
*/
|
|
255
|
-
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string
|
|
256
|
-
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
282
|
+
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
283
|
+
handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
|
+
Promise<any> | any;
|
|
285
|
+
handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
|
+
Promise<any> | any;
|
|
287
|
+
handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
|
+
Promise<any> | any;
|
|
289
|
+
handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): // oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
290
|
+
Promise<any> | any;
|
|
260
291
|
lc_serializable: boolean;
|
|
261
292
|
get lc_namespace(): ["langchain_core", "callbacks", string];
|
|
262
293
|
get lc_secrets(): {
|