@langchain/core 0.3.72 → 1.0.0-alpha.2
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 -3
- package/dist/_virtual/rolldown_runtime.cjs +32 -0
- package/dist/_virtual/rolldown_runtime.js +11 -0
- package/dist/agents.cjs +12 -2
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +19 -0
- package/dist/agents.d.cts.map +1 -0
- package/dist/agents.d.ts +16 -10
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +6 -1
- package/dist/agents.js.map +1 -0
- package/dist/caches/base.cjs +99 -104
- package/dist/caches/base.cjs.map +1 -0
- package/dist/caches/base.d.cts +83 -0
- package/dist/caches/base.d.cts.map +1 -0
- package/dist/caches/base.d.ts +60 -45
- package/dist/caches/base.d.ts.map +1 -0
- package/dist/caches/base.js +91 -98
- package/dist/caches/base.js.map +1 -0
- package/dist/callbacks/base.cjs +112 -185
- package/dist/callbacks/base.cjs.map +1 -0
- package/dist/callbacks/base.d.cts +318 -0
- package/dist/callbacks/base.d.cts.map +1 -0
- package/dist/callbacks/base.d.ts +234 -222
- package/dist/callbacks/base.d.ts.map +1 -0
- package/dist/callbacks/base.js +107 -149
- package/dist/callbacks/base.js.map +1 -0
- package/dist/callbacks/dispatch/index.cjs +56 -46
- package/dist/callbacks/dispatch/index.cjs.map +1 -0
- package/dist/callbacks/dispatch/index.d.cts +43 -0
- package/dist/callbacks/dispatch/index.d.cts.map +1 -0
- package/dist/callbacks/dispatch/index.d.ts +10 -2
- package/dist/callbacks/dispatch/index.d.ts.map +1 -0
- package/dist/callbacks/dispatch/index.js +48 -41
- package/dist/callbacks/dispatch/index.js.map +1 -0
- package/dist/callbacks/dispatch/web.cjs +60 -56
- package/dist/callbacks/dispatch/web.cjs.map +1 -0
- package/dist/callbacks/dispatch/web.d.cts +40 -0
- package/dist/callbacks/dispatch/web.d.cts.map +1 -0
- package/dist/callbacks/dispatch/web.d.ts +10 -2
- package/dist/callbacks/dispatch/web.d.ts.map +1 -0
- package/dist/callbacks/dispatch/web.js +54 -53
- package/dist/callbacks/dispatch/web.js.map +1 -0
- package/dist/callbacks/manager.cjs +580 -877
- package/dist/callbacks/manager.cjs.map +1 -0
- package/dist/callbacks/manager.d.cts +192 -0
- package/dist/callbacks/manager.d.cts.map +1 -0
- package/dist/callbacks/manager.d.ts +146 -133
- package/dist/callbacks/manager.d.ts.map +1 -0
- package/dist/callbacks/manager.js +564 -863
- package/dist/callbacks/manager.js.map +1 -0
- package/dist/callbacks/promises.cjs +20 -6
- package/dist/callbacks/promises.cjs.map +1 -0
- package/dist/callbacks/promises.d.cts +2 -0
- package/dist/callbacks/promises.d.ts +1 -1
- package/dist/callbacks/promises.js +12 -1
- package/dist/callbacks/promises.js.map +1 -0
- package/dist/chat_history.cjs +126 -119
- package/dist/chat_history.cjs.map +1 -0
- package/dist/chat_history.d.cts +99 -0
- package/dist/chat_history.d.cts.map +1 -0
- package/dist/chat_history.d.ts +82 -75
- package/dist/chat_history.d.ts.map +1 -0
- package/dist/chat_history.js +118 -113
- package/dist/chat_history.js.map +1 -0
- package/dist/context.cjs +29 -18
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +7 -0
- package/dist/context.d.cts.map +1 -0
- package/dist/context.d.ts +7 -2
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +18 -11
- package/dist/context.js.map +1 -0
- package/dist/document_loaders/base.cjs +31 -22
- package/dist/document_loaders/base.cjs.map +1 -0
- package/dist/document_loaders/base.d.cts +34 -0
- package/dist/document_loaders/base.d.cts.map +1 -0
- package/dist/document_loaders/base.d.ts +22 -16
- package/dist/document_loaders/base.d.ts.map +1 -0
- package/dist/document_loaders/base.js +26 -19
- package/dist/document_loaders/base.js.map +1 -0
- package/dist/document_loaders/langsmith.cjs +128 -195
- package/dist/document_loaders/langsmith.cjs.map +1 -0
- package/dist/document_loaders/langsmith.d.cts +103 -0
- package/dist/document_loaders/langsmith.d.cts.map +1 -0
- package/dist/document_loaders/langsmith.d.ts +52 -45
- package/dist/document_loaders/langsmith.d.ts.map +1 -0
- package/dist/document_loaders/langsmith.js +121 -190
- package/dist/document_loaders/langsmith.js.map +1 -0
- package/dist/documents/document.cjs +23 -40
- package/dist/documents/document.cjs.map +1 -0
- package/dist/documents/document.d.cts +50 -0
- package/dist/documents/document.d.cts.map +1 -0
- package/dist/documents/document.d.ts +44 -31
- package/dist/documents/document.d.ts.map +1 -0
- package/dist/documents/document.js +23 -37
- package/dist/documents/document.js.map +1 -0
- package/dist/documents/index.cjs +23 -18
- package/dist/documents/index.cjs.map +1 -0
- package/dist/documents/index.d.cts +3 -0
- package/dist/documents/index.d.ts +3 -2
- package/dist/documents/index.js +15 -2
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/transformers.cjs +46 -48
- package/dist/documents/transformers.cjs.map +1 -0
- package/dist/documents/transformers.d.cts +44 -0
- package/dist/documents/transformers.d.cts.map +1 -0
- package/dist/documents/transformers.d.ts +27 -21
- package/dist/documents/transformers.d.ts.map +1 -0
- package/dist/documents/transformers.js +45 -43
- package/dist/documents/transformers.js.map +1 -0
- package/dist/embeddings.cjs +28 -22
- package/dist/embeddings.cjs.map +1 -0
- package/dist/embeddings.d.cts +56 -0
- package/dist/embeddings.d.cts.map +1 -0
- package/dist/embeddings.d.ts +45 -39
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +22 -18
- package/dist/embeddings.js.map +1 -0
- package/dist/errors/index.cjs +9 -8
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.js +9 -6
- package/dist/errors/index.js.map +1 -0
- package/dist/example_selectors/base.cjs +15 -17
- package/dist/example_selectors/base.cjs.map +1 -0
- package/dist/example_selectors/base.d.cts +26 -0
- package/dist/example_selectors/base.d.cts.map +1 -0
- package/dist/example_selectors/base.d.ts +21 -15
- package/dist/example_selectors/base.d.ts.map +1 -0
- package/dist/example_selectors/base.js +15 -13
- package/dist/example_selectors/base.js.map +1 -0
- package/dist/example_selectors/conditional.cjs +56 -68
- package/dist/example_selectors/conditional.cjs.map +1 -0
- package/dist/example_selectors/conditional.d.cts +62 -0
- package/dist/example_selectors/conditional.d.cts.map +1 -0
- package/dist/example_selectors/conditional.d.ts +42 -43
- package/dist/example_selectors/conditional.d.ts.map +1 -0
- package/dist/example_selectors/conditional.js +54 -63
- package/dist/example_selectors/conditional.js.map +1 -0
- package/dist/example_selectors/index.cjs +33 -20
- package/dist/example_selectors/index.cjs.map +1 -0
- package/dist/example_selectors/index.d.cts +5 -0
- package/dist/example_selectors/index.d.ts +5 -4
- package/dist/example_selectors/index.js +21 -4
- package/dist/example_selectors/index.js.map +1 -0
- package/dist/example_selectors/length_based.cjs +118 -145
- package/dist/example_selectors/length_based.cjs.map +1 -0
- package/dist/example_selectors/length_based.d.cts +95 -0
- package/dist/example_selectors/length_based.d.cts.map +1 -0
- package/dist/example_selectors/length_based.d.ts +45 -39
- package/dist/example_selectors/length_based.d.ts.map +1 -0
- package/dist/example_selectors/length_based.js +118 -141
- package/dist/example_selectors/length_based.js.map +1 -0
- package/dist/example_selectors/semantic_similarity.cjs +118 -135
- package/dist/example_selectors/semantic_similarity.cjs.map +1 -0
- package/dist/example_selectors/semantic_similarity.d.cts +97 -0
- package/dist/example_selectors/semantic_similarity.d.cts.map +1 -0
- package/dist/example_selectors/semantic_similarity.d.ts +59 -53
- package/dist/example_selectors/semantic_similarity.d.ts.map +1 -0
- package/dist/example_selectors/semantic_similarity.js +117 -130
- package/dist/example_selectors/semantic_similarity.js.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing/base.cjs +207 -272
- package/dist/indexing/base.cjs.map +1 -0
- package/dist/indexing/base.d.cts +125 -0
- package/dist/indexing/base.d.cts.map +1 -0
- package/dist/indexing/base.d.ts +88 -80
- package/dist/indexing/base.d.ts.map +1 -0
- package/dist/indexing/base.js +205 -267
- package/dist/indexing/base.js.map +1 -0
- package/dist/indexing/index.cjs +33 -18
- package/dist/indexing/index.cjs.map +1 -0
- package/dist/indexing/index.d.cts +3 -0
- package/dist/indexing/index.d.ts +3 -2
- package/dist/indexing/index.js +20 -2
- package/dist/indexing/index.js.map +1 -0
- package/dist/indexing/record_manager.cjs +11 -17
- package/dist/indexing/record_manager.cjs.map +1 -0
- package/dist/indexing/record_manager.d.cts +70 -0
- package/dist/indexing/record_manager.d.cts.map +1 -0
- package/dist/indexing/record_manager.d.ts +65 -59
- package/dist/indexing/record_manager.d.ts.map +1 -0
- package/dist/indexing/record_manager.js +10 -13
- package/dist/indexing/record_manager.js.map +1 -0
- package/dist/language_models/base.cjs +212 -293
- package/dist/language_models/base.cjs.map +1 -0
- package/dist/language_models/base.d.cts +301 -0
- package/dist/language_models/base.d.cts.map +1 -0
- package/dist/language_models/base.d.ts +256 -212
- package/dist/language_models/base.d.ts.map +1 -0
- package/dist/language_models/base.js +202 -285
- package/dist/language_models/base.js.map +1 -0
- package/dist/language_models/chat_models.cjs +500 -622
- package/dist/language_models/chat_models.cjs.map +1 -0
- package/dist/language_models/chat_models.d.cts +261 -0
- package/dist/language_models/chat_models.d.cts.map +1 -0
- package/dist/language_models/chat_models.d.ts +228 -172
- package/dist/language_models/chat_models.d.ts.map +1 -0
- package/dist/language_models/chat_models.js +492 -616
- package/dist/language_models/chat_models.js.map +1 -0
- package/dist/language_models/llms.cjs +328 -376
- package/dist/language_models/llms.cjs.map +1 -0
- package/dist/language_models/llms.d.cts +149 -0
- package/dist/language_models/llms.d.cts.map +1 -0
- package/dist/language_models/llms.d.ts +135 -115
- package/dist/language_models/llms.d.ts.map +1 -0
- package/dist/language_models/llms.js +321 -371
- package/dist/language_models/llms.js.map +1 -0
- package/dist/language_models/utils.cjs +19 -0
- package/dist/language_models/utils.cjs.map +1 -0
- package/dist/language_models/utils.js +17 -0
- package/dist/language_models/utils.js.map +1 -0
- package/dist/load/import_constants.cjs +7 -5
- package/dist/load/import_constants.cjs.map +1 -0
- package/dist/load/import_constants.js +6 -2
- package/dist/load/import_constants.js.map +1 -0
- package/dist/load/import_map.cjs +138 -79
- package/dist/load/import_map.cjs.map +1 -0
- package/dist/load/import_map.js +134 -44
- package/dist/load/import_map.js.map +1 -0
- package/dist/load/import_type.d.cts +7 -0
- package/dist/load/import_type.d.cts.map +1 -0
- package/dist/load/import_type.d.ts +7 -4
- package/dist/load/import_type.d.ts.map +1 -0
- package/dist/load/index.cjs +85 -192
- package/dist/load/index.cjs.map +1 -0
- package/dist/load/index.d.cts +12 -0
- package/dist/load/index.d.cts.map +1 -0
- package/dist/load/index.d.ts +11 -6
- package/dist/load/index.d.ts.map +1 -0
- package/dist/load/index.js +84 -155
- package/dist/load/index.js.map +1 -0
- package/dist/load/map_keys.cjs +16 -19
- package/dist/load/map_keys.cjs.map +1 -0
- package/dist/load/map_keys.d.cts +8 -0
- package/dist/load/map_keys.d.cts.map +1 -0
- package/dist/load/map_keys.d.ts +7 -8
- package/dist/load/map_keys.d.ts.map +1 -0
- package/dist/load/map_keys.js +14 -12
- package/dist/load/map_keys.js.map +1 -0
- package/dist/load/serializable.cjs +143 -185
- package/dist/load/serializable.cjs.map +1 -0
- package/dist/load/serializable.d.cts +82 -0
- package/dist/load/serializable.d.cts.map +1 -0
- package/dist/load/serializable.d.ts +74 -68
- package/dist/load/serializable.d.ts.map +1 -0
- package/dist/load/serializable.js +136 -180
- package/dist/load/serializable.js.map +1 -0
- package/dist/memory.cjs +60 -51
- package/dist/memory.cjs.map +1 -0
- package/dist/memory.d.cts +69 -0
- package/dist/memory.d.cts.map +1 -0
- package/dist/memory.d.ts +34 -27
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +54 -47
- package/dist/memory.js.map +1 -0
- package/dist/messages/ai.cjs +280 -333
- package/dist/messages/ai.cjs.map +1 -0
- package/dist/messages/ai.d.cts +148 -0
- package/dist/messages/ai.d.cts.map +1 -0
- package/dist/messages/ai.d.ts +119 -107
- package/dist/messages/ai.d.ts.map +1 -0
- package/dist/messages/ai.js +279 -328
- package/dist/messages/ai.js.map +1 -0
- package/dist/messages/base.cjs +225 -364
- package/dist/messages/base.cjs.map +1 -0
- package/dist/messages/base.d.cts +188 -0
- package/dist/messages/base.d.cts.map +1 -0
- package/dist/messages/base.d.ts +147 -147
- package/dist/messages/base.d.ts.map +1 -0
- package/dist/messages/base.js +222 -357
- package/dist/messages/base.js.map +1 -0
- package/dist/messages/block_translators/anthropic.cjs +320 -0
- package/dist/messages/block_translators/anthropic.cjs.map +1 -0
- package/dist/messages/block_translators/anthropic.js +319 -0
- package/dist/messages/block_translators/anthropic.js.map +1 -0
- package/dist/messages/block_translators/data.cjs +71 -0
- package/dist/messages/block_translators/data.cjs.map +1 -0
- package/dist/messages/block_translators/data.js +69 -0
- package/dist/messages/block_translators/data.js.map +1 -0
- package/dist/messages/block_translators/index.cjs +12 -0
- package/dist/messages/block_translators/index.cjs.map +1 -0
- package/dist/messages/block_translators/index.js +12 -0
- package/dist/messages/block_translators/index.js.map +1 -0
- package/dist/messages/block_translators/openai.cjs +324 -0
- package/dist/messages/block_translators/openai.cjs.map +1 -0
- package/dist/messages/block_translators/openai.js +323 -0
- package/dist/messages/block_translators/openai.js.map +1 -0
- package/dist/messages/block_translators/utils.cjs +35 -0
- package/dist/messages/block_translators/utils.cjs.map +1 -0
- package/dist/messages/block_translators/utils.js +28 -0
- package/dist/messages/block_translators/utils.js.map +1 -0
- package/dist/messages/chat.cjs +78 -86
- package/dist/messages/chat.cjs.map +1 -0
- package/dist/messages/chat.d.cts +37 -0
- package/dist/messages/chat.d.cts.map +1 -0
- package/dist/messages/chat.d.ts +27 -22
- package/dist/messages/chat.d.ts.map +1 -0
- package/dist/messages/chat.js +77 -81
- package/dist/messages/chat.js.map +1 -0
- package/dist/messages/content/base.d.cts +20 -0
- package/dist/messages/content/base.d.cts.map +1 -0
- package/dist/messages/content/base.d.ts +20 -0
- package/dist/messages/content/base.d.ts.map +1 -0
- package/dist/messages/content/data.cjs +146 -0
- package/dist/messages/content/data.cjs.map +1 -0
- package/dist/messages/content/data.d.cts +280 -0
- package/dist/messages/content/data.d.cts.map +1 -0
- package/dist/messages/content/data.d.ts +280 -0
- package/dist/messages/content/data.d.ts.map +1 -0
- package/dist/messages/content/data.js +137 -0
- package/dist/messages/content/data.js.map +1 -0
- package/dist/messages/content/index.cjs +14 -0
- package/dist/messages/content/index.cjs.map +1 -0
- package/dist/messages/content/index.d.cts +101 -0
- package/dist/messages/content/index.d.cts.map +1 -0
- package/dist/messages/content/index.d.ts +101 -0
- package/dist/messages/content/index.d.ts.map +1 -0
- package/dist/messages/content/index.js +14 -0
- package/dist/messages/content/index.js.map +1 -0
- package/dist/messages/content/multimodal.cjs +13 -0
- package/dist/messages/content/multimodal.cjs.map +1 -0
- package/dist/messages/content/multimodal.d.cts +108 -0
- package/dist/messages/content/multimodal.d.cts.map +1 -0
- package/dist/messages/content/multimodal.d.ts +108 -0
- package/dist/messages/content/multimodal.d.ts.map +1 -0
- package/dist/messages/content/multimodal.js +12 -0
- package/dist/messages/content/multimodal.js.map +1 -0
- package/dist/messages/content/tools.cjs +15 -0
- package/dist/messages/content/tools.cjs.map +1 -0
- package/dist/messages/content/tools.d.cts +151 -0
- package/dist/messages/content/tools.d.cts.map +1 -0
- package/dist/messages/content/tools.d.ts +151 -0
- package/dist/messages/content/tools.d.ts.map +1 -0
- package/dist/messages/content/tools.js +14 -0
- package/dist/messages/content/tools.js.map +1 -0
- package/dist/messages/function.cjs +49 -49
- package/dist/messages/function.cjs.map +1 -0
- package/dist/messages/function.d.cts +30 -0
- package/dist/messages/function.d.cts.map +1 -0
- package/dist/messages/function.d.ts +20 -16
- package/dist/messages/function.d.ts.map +1 -0
- package/dist/messages/function.js +48 -44
- package/dist/messages/function.js.map +1 -0
- package/dist/messages/human.cjs +47 -49
- package/dist/messages/human.cjs.map +1 -0
- package/dist/messages/human.d.cts +31 -0
- package/dist/messages/human.d.cts.map +1 -0
- package/dist/messages/human.d.ts +22 -22
- package/dist/messages/human.d.ts.map +1 -0
- package/dist/messages/human.js +46 -44
- package/dist/messages/human.js.map +1 -0
- package/dist/messages/index.cjs +139 -34
- package/dist/messages/index.cjs.map +1 -0
- package/dist/messages/index.d.cts +13 -0
- package/dist/messages/index.d.ts +13 -11
- package/dist/messages/index.js +78 -13
- package/dist/messages/index.js.map +1 -0
- package/dist/messages/modifier.cjs +30 -33
- package/dist/messages/modifier.cjs.map +1 -0
- package/dist/messages/modifier.d.cts +24 -0
- package/dist/messages/modifier.d.cts.map +1 -0
- package/dist/messages/modifier.d.ts +18 -13
- package/dist/messages/modifier.d.ts.map +1 -0
- package/dist/messages/modifier.js +30 -29
- package/dist/messages/modifier.js.map +1 -0
- package/dist/messages/system.cjs +47 -49
- package/dist/messages/system.cjs.map +1 -0
- package/dist/messages/system.d.cts +31 -0
- package/dist/messages/system.d.cts.map +1 -0
- package/dist/messages/system.d.ts +22 -22
- package/dist/messages/system.d.ts.map +1 -0
- package/dist/messages/system.js +46 -44
- package/dist/messages/system.js.map +1 -0
- package/dist/messages/tool.cjs +153 -189
- package/dist/messages/tool.cjs.map +1 -0
- package/dist/messages/tool.d.cts +173 -0
- package/dist/messages/tool.d.cts.map +1 -0
- package/dist/messages/tool.d.ts +96 -90
- package/dist/messages/tool.d.ts.map +1 -0
- package/dist/messages/tool.js +145 -183
- package/dist/messages/tool.js.map +1 -0
- package/dist/messages/transformers.cjs +287 -431
- package/dist/messages/transformers.cjs.map +1 -0
- package/dist/messages/transformers.d.cts +472 -0
- package/dist/messages/transformers.d.cts.map +1 -0
- package/dist/messages/transformers.d.ts +111 -105
- package/dist/messages/transformers.d.ts.map +1 -0
- package/dist/messages/transformers.js +284 -425
- package/dist/messages/transformers.js.map +1 -0
- package/dist/messages/utils.cjs +172 -267
- package/dist/messages/utils.cjs.map +1 -0
- package/dist/messages/utils.d.cts +36 -0
- package/dist/messages/utils.d.cts.map +1 -0
- package/dist/messages/utils.d.ts +13 -8
- package/dist/messages/utils.d.ts.map +1 -0
- package/dist/messages/utils.js +170 -262
- package/dist/messages/utils.js.map +1 -0
- package/dist/output_parsers/base.cjs +104 -120
- package/dist/output_parsers/base.cjs.map +1 -0
- package/dist/output_parsers/base.d.cts +108 -0
- package/dist/output_parsers/base.d.cts.map +1 -0
- package/dist/output_parsers/base.d.ts +76 -71
- package/dist/output_parsers/base.d.ts.map +1 -0
- package/dist/output_parsers/base.js +102 -114
- package/dist/output_parsers/base.js.map +1 -0
- package/dist/output_parsers/bytes.cjs +27 -39
- package/dist/output_parsers/bytes.cjs.map +1 -0
- package/dist/output_parsers/bytes.d.cts +19 -0
- package/dist/output_parsers/bytes.d.cts.map +1 -0
- package/dist/output_parsers/bytes.d.ts +13 -7
- package/dist/output_parsers/bytes.d.ts.map +1 -0
- package/dist/output_parsers/bytes.js +27 -35
- package/dist/output_parsers/bytes.js.map +1 -0
- package/dist/output_parsers/index.cjs +66 -24
- package/dist/output_parsers/index.cjs.map +1 -0
- package/dist/output_parsers/index.d.cts +10 -0
- package/dist/output_parsers/index.d.ts +10 -8
- package/dist/output_parsers/index.js +40 -8
- package/dist/output_parsers/index.js.map +1 -0
- package/dist/output_parsers/json.cjs +36 -57
- package/dist/output_parsers/json.cjs.map +1 -0
- package/dist/output_parsers/json.d.cts +26 -0
- package/dist/output_parsers/json.d.cts.map +1 -0
- package/dist/output_parsers/json.d.ts +20 -13
- package/dist/output_parsers/json.d.ts.map +1 -0
- package/dist/output_parsers/json.js +36 -52
- package/dist/output_parsers/json.js.map +1 -0
- package/dist/output_parsers/list.cjs +155 -239
- package/dist/output_parsers/list.cjs.map +1 -0
- package/dist/output_parsers/list.d.cts +85 -0
- package/dist/output_parsers/list.d.cts.map +1 -0
- package/dist/output_parsers/list.d.ts +67 -58
- package/dist/output_parsers/list.d.ts.map +1 -0
- package/dist/output_parsers/list.js +151 -231
- package/dist/output_parsers/list.js.map +1 -0
- package/dist/output_parsers/openai_functions/index.cjs +22 -17
- package/dist/output_parsers/openai_functions/index.cjs.map +1 -0
- package/dist/output_parsers/openai_functions/index.d.cts +2 -0
- package/dist/output_parsers/openai_functions/index.d.ts +2 -1
- package/dist/output_parsers/openai_functions/index.js +14 -1
- package/dist/output_parsers/openai_functions/index.js.map +1 -0
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs +140 -203
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs.map +1 -0
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +90 -0
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -0
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +68 -58
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -0
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.js +138 -197
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.js.map +1 -0
- package/dist/output_parsers/openai_tools/index.cjs +26 -17
- package/dist/output_parsers/openai_tools/index.cjs.map +1 -0
- package/dist/output_parsers/openai_tools/index.d.cts +2 -0
- package/dist/output_parsers/openai_tools/index.d.ts +2 -1
- package/dist/output_parsers/openai_tools/index.js +16 -1
- package/dist/output_parsers/openai_tools/index.js.map +1 -0
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +176 -256
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -0
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +120 -0
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -0
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +98 -70
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -0
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +173 -249
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -0
- package/dist/output_parsers/string.cjs +70 -84
- package/dist/output_parsers/string.cjs.map +1 -0
- package/dist/output_parsers/string.d.cts +45 -0
- package/dist/output_parsers/string.d.cts.map +1 -0
- package/dist/output_parsers/string.d.ts +25 -19
- package/dist/output_parsers/string.d.ts.map +1 -0
- package/dist/output_parsers/string.js +70 -80
- package/dist/output_parsers/string.js.map +1 -0
- package/dist/output_parsers/structured.cjs +148 -181
- package/dist/output_parsers/structured.cjs.map +1 -0
- package/dist/output_parsers/structured.d.cts +97 -0
- package/dist/output_parsers/structured.d.cts.map +1 -0
- package/dist/output_parsers/structured.d.ts +82 -74
- package/dist/output_parsers/structured.d.ts.map +1 -0
- package/dist/output_parsers/structured.js +144 -174
- package/dist/output_parsers/structured.js.map +1 -0
- package/dist/output_parsers/transform.cjs +79 -109
- package/dist/output_parsers/transform.cjs.map +1 -0
- package/dist/output_parsers/transform.d.cts +41 -0
- package/dist/output_parsers/transform.d.cts.map +1 -0
- package/dist/output_parsers/transform.d.ts +29 -22
- package/dist/output_parsers/transform.d.ts.map +1 -0
- package/dist/output_parsers/transform.js +77 -104
- package/dist/output_parsers/transform.js.map +1 -0
- package/dist/output_parsers/xml.cjs +95 -129
- package/dist/output_parsers/xml.cjs.map +1 -0
- package/dist/output_parsers/xml.d.cts +34 -0
- package/dist/output_parsers/xml.d.cts.map +1 -0
- package/dist/output_parsers/xml.d.ts +29 -24
- package/dist/output_parsers/xml.d.ts.map +1 -0
- package/dist/output_parsers/xml.js +93 -124
- package/dist/output_parsers/xml.js.map +1 -0
- package/dist/outputs.cjs +57 -57
- package/dist/outputs.cjs.map +1 -0
- package/dist/outputs.d.cts +72 -0
- package/dist/outputs.d.cts.map +1 -0
- package/dist/outputs.d.ts +55 -44
- package/dist/outputs.d.ts.map +1 -0
- package/dist/outputs.js +50 -53
- package/dist/outputs.js.map +1 -0
- package/dist/prompt_values.cjs +101 -148
- package/dist/prompt_values.cjs.map +1 -0
- package/dist/prompt_values.d.cts +83 -0
- package/dist/prompt_values.d.cts.map +1 -0
- package/dist/prompt_values.d.ts +53 -48
- package/dist/prompt_values.d.ts.map +1 -0
- package/dist/prompt_values.js +90 -139
- package/dist/prompt_values.js.map +1 -0
- package/dist/prompts/base.cjs +106 -173
- package/dist/prompts/base.cjs.map +1 -0
- package/dist/prompts/base.d.cts +108 -0
- package/dist/prompts/base.d.cts.map +1 -0
- package/dist/prompts/base.d.ts +98 -85
- package/dist/prompts/base.d.ts.map +1 -0
- package/dist/prompts/base.js +106 -136
- package/dist/prompts/base.js.map +1 -0
- package/dist/prompts/chat.cjs +533 -786
- package/dist/prompts/chat.cjs.map +1 -0
- package/dist/prompts/chat.d.cts +296 -0
- package/dist/prompts/chat.d.cts.map +1 -0
- package/dist/prompts/chat.d.ts +191 -136
- package/dist/prompts/chat.d.ts.map +1 -0
- package/dist/prompts/chat.js +522 -771
- package/dist/prompts/chat.js.map +1 -0
- package/dist/prompts/dict.cjs +60 -110
- package/dist/prompts/dict.cjs.map +1 -0
- package/dist/prompts/dict.d.cts +23 -0
- package/dist/prompts/dict.d.cts.map +1 -0
- package/dist/prompts/dict.d.ts +19 -14
- package/dist/prompts/dict.d.ts.map +1 -0
- package/dist/prompts/dict.js +58 -104
- package/dist/prompts/dict.js.map +1 -0
- package/dist/prompts/few_shot.cjs +239 -352
- package/dist/prompts/few_shot.cjs.map +1 -0
- package/dist/prompts/few_shot.d.cts +204 -0
- package/dist/prompts/few_shot.d.cts.map +1 -0
- package/dist/prompts/few_shot.d.ts +157 -148
- package/dist/prompts/few_shot.d.ts.map +1 -0
- package/dist/prompts/few_shot.js +237 -346
- package/dist/prompts/few_shot.js.map +1 -0
- package/dist/prompts/image.cjs +92 -126
- package/dist/prompts/image.cjs.map +1 -0
- package/dist/prompts/image.d.cts +86 -0
- package/dist/prompts/image.d.cts.map +1 -0
- package/dist/prompts/image.d.ts +76 -60
- package/dist/prompts/image.d.ts.map +1 -0
- package/dist/prompts/image.js +92 -122
- package/dist/prompts/image.js.map +1 -0
- package/dist/prompts/index.cjs +79 -27
- package/dist/prompts/index.cjs.map +1 -0
- package/dist/prompts/index.d.cts +12 -0
- package/dist/prompts/index.d.ts +12 -11
- package/dist/prompts/index.js +47 -11
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/pipeline.cjs +128 -142
- package/dist/prompts/pipeline.cjs.map +1 -0
- package/dist/prompts/pipeline.d.cts +104 -0
- package/dist/prompts/pipeline.d.cts.map +1 -0
- package/dist/prompts/pipeline.d.ts +48 -42
- package/dist/prompts/pipeline.d.ts.map +1 -0
- package/dist/prompts/pipeline.js +127 -137
- package/dist/prompts/pipeline.js.map +1 -0
- package/dist/prompts/prompt.cjs +131 -164
- package/dist/prompts/prompt.cjs.map +1 -0
- package/dist/prompts/prompt.d.cts +134 -0
- package/dist/prompts/prompt.d.cts.map +1 -0
- package/dist/prompts/prompt.d.ts +106 -79
- package/dist/prompts/prompt.d.ts.map +1 -0
- package/dist/prompts/prompt.js +131 -160
- package/dist/prompts/prompt.js.map +1 -0
- package/dist/prompts/serde.d.cts +50 -0
- package/dist/prompts/serde.d.cts.map +1 -0
- package/dist/prompts/serde.d.ts +24 -17
- package/dist/prompts/serde.d.ts.map +1 -0
- package/dist/prompts/string.cjs +23 -23
- package/dist/prompts/string.cjs.map +1 -0
- package/dist/prompts/string.d.cts +27 -0
- package/dist/prompts/string.d.cts.map +1 -0
- package/dist/prompts/string.d.ts +21 -11
- package/dist/prompts/string.d.ts.map +1 -0
- package/dist/prompts/string.js +23 -19
- package/dist/prompts/string.js.map +1 -0
- package/dist/prompts/structured.cjs +46 -70
- package/dist/prompts/structured.cjs.map +1 -0
- package/dist/prompts/structured.d.cts +40 -0
- package/dist/prompts/structured.d.cts.map +1 -0
- package/dist/prompts/structured.d.ts +33 -14
- package/dist/prompts/structured.d.ts.map +1 -0
- package/dist/prompts/structured.js +46 -66
- package/dist/prompts/structured.js.map +1 -0
- package/dist/prompts/template.cjs +138 -157
- package/dist/prompts/template.cjs.map +1 -0
- package/dist/prompts/template.d.cts +48 -0
- package/dist/prompts/template.d.cts.map +1 -0
- package/dist/prompts/template.d.ts +24 -19
- package/dist/prompts/template.d.ts.map +1 -0
- package/dist/prompts/template.js +135 -150
- package/dist/prompts/template.js.map +1 -0
- package/dist/retrievers/document_compressors/base.cjs +21 -11
- package/dist/retrievers/document_compressors/base.cjs.map +1 -0
- package/dist/retrievers/document_compressors/base.d.cts +25 -0
- package/dist/retrievers/document_compressors/base.d.cts.map +1 -0
- package/dist/retrievers/document_compressors/base.d.ts +20 -13
- package/dist/retrievers/document_compressors/base.d.ts.map +1 -0
- package/dist/retrievers/document_compressors/base.js +16 -8
- package/dist/retrievers/document_compressors/base.js.map +1 -0
- package/dist/retrievers/index.cjs +119 -129
- package/dist/retrievers/index.cjs.map +1 -0
- package/dist/retrievers/index.d.cts +144 -0
- package/dist/retrievers/index.d.cts.map +1 -0
- package/dist/retrievers/index.d.ts +98 -88
- package/dist/retrievers/index.d.ts.map +1 -0
- package/dist/retrievers/index.js +113 -125
- package/dist/retrievers/index.js.map +1 -0
- package/dist/runnables/base.cjs +1808 -2421
- package/dist/runnables/base.cjs.map +1 -0
- package/dist/runnables/base.d.cts +990 -0
- package/dist/runnables/base.d.cts.map +1 -0
- package/dist/runnables/base.d.ts +633 -592
- package/dist/runnables/base.d.ts.map +1 -0
- package/dist/runnables/base.js +1791 -2396
- package/dist/runnables/base.js.map +1 -0
- package/dist/runnables/branch.cjs +151 -205
- package/dist/runnables/branch.cjs.map +1 -0
- package/dist/runnables/branch.d.cts +94 -0
- package/dist/runnables/branch.d.cts.map +1 -0
- package/dist/runnables/branch.d.ts +50 -51
- package/dist/runnables/branch.d.ts.map +1 -0
- package/dist/runnables/branch.js +151 -201
- package/dist/runnables/branch.js.map +1 -0
- package/dist/runnables/config.cjs +136 -212
- package/dist/runnables/config.cjs.map +1 -0
- package/dist/runnables/config.d.cts +26 -0
- package/dist/runnables/config.d.cts.map +1 -0
- package/dist/runnables/config.d.ts +18 -7
- package/dist/runnables/config.d.ts.map +1 -0
- package/dist/runnables/config.js +134 -207
- package/dist/runnables/config.js.map +1 -0
- package/dist/runnables/graph.cjs +215 -260
- package/dist/runnables/graph.cjs.map +1 -0
- package/dist/runnables/graph.d.cts +52 -0
- package/dist/runnables/graph.d.cts.map +1 -0
- package/dist/runnables/graph.d.ts +49 -41
- package/dist/runnables/graph.d.ts.map +1 -0
- package/dist/runnables/graph.js +206 -253
- package/dist/runnables/graph.js.map +1 -0
- package/dist/runnables/graph_mermaid.cjs +86 -141
- package/dist/runnables/graph_mermaid.cjs.map +1 -0
- package/dist/runnables/graph_mermaid.js +86 -139
- package/dist/runnables/graph_mermaid.js.map +1 -0
- package/dist/runnables/history.cjs +160 -260
- package/dist/runnables/history.cjs.map +1 -0
- package/dist/runnables/history.d.cts +104 -0
- package/dist/runnables/history.d.cts.map +1 -0
- package/dist/runnables/history.d.ts +38 -26
- package/dist/runnables/history.d.ts.map +1 -0
- package/dist/runnables/history.js +160 -256
- package/dist/runnables/history.js.map +1 -0
- package/dist/runnables/index.cjs +65 -31
- package/dist/runnables/index.cjs.map +1 -0
- package/dist/runnables/index.d.cts +8 -0
- package/dist/runnables/index.d.ts +8 -7
- package/dist/runnables/index.js +38 -6
- package/dist/runnables/index.js.map +1 -0
- package/dist/runnables/iter.cjs +27 -42
- package/dist/runnables/iter.cjs.map +1 -0
- package/dist/runnables/iter.js +26 -37
- package/dist/runnables/iter.js.map +1 -0
- package/dist/runnables/passthrough.cjs +97 -125
- package/dist/runnables/passthrough.cjs.map +1 -0
- package/dist/runnables/passthrough.d.cts +76 -0
- package/dist/runnables/passthrough.d.cts.map +1 -0
- package/dist/runnables/passthrough.d.ts +46 -40
- package/dist/runnables/passthrough.d.ts.map +1 -0
- package/dist/runnables/passthrough.js +97 -121
- package/dist/runnables/passthrough.js.map +1 -0
- package/dist/runnables/remote.cjs +387 -508
- package/dist/runnables/remote.cjs.map +1 -0
- package/dist/runnables/remote.d.cts +73 -0
- package/dist/runnables/remote.d.cts.map +1 -0
- package/dist/runnables/remote.d.ts +52 -40
- package/dist/runnables/remote.d.ts.map +1 -0
- package/dist/runnables/remote.js +379 -502
- package/dist/runnables/remote.js.map +1 -0
- package/dist/runnables/router.cjs +74 -95
- package/dist/runnables/router.cjs.map +1 -0
- package/dist/runnables/router.d.cts +58 -0
- package/dist/runnables/router.d.cts.map +1 -0
- package/dist/runnables/router.d.ts +27 -21
- package/dist/runnables/router.d.ts.map +1 -0
- package/dist/runnables/router.js +74 -91
- package/dist/runnables/router.js.map +1 -0
- package/dist/runnables/types.d.cts +81 -0
- package/dist/runnables/types.d.cts.map +1 -0
- package/dist/runnables/types.d.ts +68 -55
- package/dist/runnables/types.d.ts.map +1 -0
- package/dist/runnables/utils.cjs +40 -85
- package/dist/runnables/utils.cjs.map +1 -0
- package/dist/runnables/utils.js +40 -82
- package/dist/runnables/utils.js.map +1 -0
- package/dist/runnables/wrappers.cjs +14 -15
- package/dist/runnables/wrappers.cjs.map +1 -0
- package/dist/runnables/wrappers.js +14 -12
- package/dist/runnables/wrappers.js.map +1 -0
- package/dist/singletons/async_local_storage/context.cjs +167 -177
- package/dist/singletons/async_local_storage/context.cjs.map +1 -0
- package/dist/singletons/async_local_storage/context.d.cts +163 -0
- package/dist/singletons/async_local_storage/context.d.cts.map +1 -0
- package/dist/singletons/async_local_storage/context.d.ts +17 -9
- package/dist/singletons/async_local_storage/context.d.ts.map +1 -0
- package/dist/singletons/async_local_storage/context.js +168 -175
- package/dist/singletons/async_local_storage/context.js.map +1 -0
- package/dist/singletons/async_local_storage/globals.cjs +11 -8
- package/dist/singletons/async_local_storage/globals.cjs.map +1 -0
- package/dist/singletons/async_local_storage/globals.d.cts +11 -0
- package/dist/singletons/async_local_storage/globals.d.cts.map +1 -0
- package/dist/singletons/async_local_storage/globals.d.ts +10 -8
- package/dist/singletons/async_local_storage/globals.d.ts.map +1 -0
- package/dist/singletons/async_local_storage/globals.js +11 -6
- package/dist/singletons/async_local_storage/globals.js.map +1 -0
- package/dist/singletons/async_local_storage/index.cjs +55 -65
- package/dist/singletons/async_local_storage/index.cjs.map +1 -0
- package/dist/singletons/async_local_storage/index.d.cts +18 -0
- package/dist/singletons/async_local_storage/index.d.cts.map +1 -0
- package/dist/singletons/async_local_storage/index.d.ts +13 -9
- package/dist/singletons/async_local_storage/index.d.ts.map +1 -0
- package/dist/singletons/async_local_storage/index.js +53 -61
- package/dist/singletons/async_local_storage/index.js.map +1 -0
- package/dist/singletons/callbacks.cjs +43 -60
- package/dist/singletons/callbacks.cjs.map +1 -0
- package/dist/singletons/callbacks.d.cts +16 -0
- package/dist/singletons/callbacks.d.cts.map +1 -0
- package/dist/singletons/callbacks.d.ts +8 -3
- package/dist/singletons/callbacks.d.ts.map +1 -0
- package/dist/singletons/callbacks.js +43 -54
- package/dist/singletons/callbacks.js.map +1 -0
- package/dist/singletons/index.cjs +23 -8
- package/dist/singletons/index.cjs.map +1 -0
- package/dist/singletons/index.d.cts +3 -0
- package/dist/singletons/index.d.ts +3 -4
- package/dist/singletons/index.js +14 -3
- package/dist/singletons/index.js.map +1 -0
- package/dist/singletons/tracer.cjs +13 -19
- package/dist/singletons/tracer.cjs.map +1 -0
- package/dist/singletons/tracer.js +13 -15
- package/dist/singletons/tracer.js.map +1 -0
- package/dist/stores.cjs +78 -87
- package/dist/stores.cjs.map +1 -0
- package/dist/stores.d.cts +111 -0
- package/dist/stores.d.cts.map +1 -0
- package/dist/stores.d.ts +84 -78
- package/dist/stores.d.ts.map +1 -0
- package/dist/stores.js +71 -82
- package/dist/stores.js.map +1 -0
- package/dist/structured_query/base.cjs +86 -136
- package/dist/structured_query/base.cjs.map +1 -0
- package/dist/structured_query/base.d.cts +75 -0
- package/dist/structured_query/base.d.cts.map +1 -0
- package/dist/structured_query/base.d.ts +53 -47
- package/dist/structured_query/base.d.ts.map +1 -0
- package/dist/structured_query/base.js +86 -132
- package/dist/structured_query/base.js.map +1 -0
- package/dist/structured_query/functional.cjs +163 -234
- package/dist/structured_query/functional.cjs.map +1 -0
- package/dist/structured_query/functional.d.cts +98 -0
- package/dist/structured_query/functional.d.cts.map +1 -0
- package/dist/structured_query/functional.d.ts +72 -67
- package/dist/structured_query/functional.d.ts.map +1 -0
- package/dist/structured_query/functional.js +163 -230
- package/dist/structured_query/functional.js.map +1 -0
- package/dist/structured_query/index.cjs +55 -20
- package/dist/structured_query/index.cjs.map +1 -0
- package/dist/structured_query/index.d.cts +5 -0
- package/dist/structured_query/index.d.ts +5 -4
- package/dist/structured_query/index.js +32 -4
- package/dist/structured_query/index.js.map +1 -0
- package/dist/structured_query/ir.cjs +76 -132
- package/dist/structured_query/ir.cjs.map +1 -0
- package/dist/structured_query/ir.d.cts +143 -0
- package/dist/structured_query/ir.d.cts.map +1 -0
- package/dist/structured_query/ir.d.ts +61 -56
- package/dist/structured_query/ir.d.ts.map +1 -0
- package/dist/structured_query/ir.js +69 -124
- package/dist/structured_query/ir.js.map +1 -0
- package/dist/structured_query/utils.cjs +58 -83
- package/dist/structured_query/utils.cjs.map +1 -0
- package/dist/structured_query/utils.d.cts +40 -0
- package/dist/structured_query/utils.d.cts.map +1 -0
- package/dist/structured_query/utils.d.ts +14 -7
- package/dist/structured_query/utils.d.ts.map +1 -0
- package/dist/structured_query/utils.js +57 -80
- package/dist/structured_query/utils.js.map +1 -0
- package/dist/tools/index.cjs +321 -437
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.cts +209 -0
- package/dist/tools/index.d.cts.map +1 -0
- package/dist/tools/index.d.ts +153 -149
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +305 -424
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/types.cjs +44 -52
- package/dist/tools/types.cjs.map +1 -0
- package/dist/tools/types.d.cts +283 -0
- package/dist/tools/types.d.cts.map +1 -0
- package/dist/tools/types.d.ts +149 -138
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +45 -50
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/utils.cjs +20 -32
- package/dist/tools/utils.cjs.map +1 -0
- package/dist/tools/utils.d.cts +14 -0
- package/dist/tools/utils.d.cts.map +1 -0
- package/dist/tools/utils.d.ts +8 -10
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +20 -29
- package/dist/tools/utils.js.map +1 -0
- package/dist/tracers/base.cjs +441 -529
- package/dist/tracers/base.cjs.map +1 -0
- package/dist/tracers/base.d.cts +304 -0
- package/dist/tracers/base.d.cts.map +1 -0
- package/dist/tracers/base.d.ts +296 -271
- package/dist/tracers/base.d.ts.map +1 -0
- package/dist/tracers/base.js +435 -525
- package/dist/tracers/base.js.map +1 -0
- package/dist/tracers/console.cjs +206 -223
- package/dist/tracers/console.cjs.map +1 -0
- package/dist/tracers/console.d.cts +125 -0
- package/dist/tracers/console.d.cts.map +1 -0
- package/dist/tracers/console.d.ts +109 -101
- package/dist/tracers/console.d.ts.map +1 -0
- package/dist/tracers/console.js +199 -215
- package/dist/tracers/console.js.map +1 -0
- package/dist/tracers/event_stream.cjs +357 -529
- package/dist/tracers/event_stream.cjs.map +1 -0
- package/dist/tracers/event_stream.d.cts +98 -0
- package/dist/tracers/event_stream.d.cts.map +1 -0
- package/dist/tracers/event_stream.d.ts +87 -129
- package/dist/tracers/event_stream.d.ts.map +1 -0
- package/dist/tracers/event_stream.js +355 -523
- package/dist/tracers/event_stream.js.map +1 -0
- package/dist/tracers/initialize.cjs +40 -29
- package/dist/tracers/initialize.cjs.map +1 -0
- package/dist/tracers/initialize.d.cts +26 -0
- package/dist/tracers/initialize.d.cts.map +1 -0
- package/dist/tracers/initialize.d.ts +8 -2
- package/dist/tracers/initialize.d.ts.map +1 -0
- package/dist/tracers/initialize.js +33 -25
- package/dist/tracers/initialize.js.map +1 -0
- package/dist/tracers/log_stream.cjs +264 -425
- package/dist/tracers/log_stream.cjs.map +1 -0
- package/dist/tracers/log_stream.d.cts +129 -0
- package/dist/tracers/log_stream.d.cts.map +1 -0
- package/dist/tracers/log_stream.d.ts +103 -92
- package/dist/tracers/log_stream.d.ts.map +1 -0
- package/dist/tracers/log_stream.js +255 -418
- package/dist/tracers/log_stream.js.map +1 -0
- package/dist/tracers/root_listener.cjs +41 -80
- package/dist/tracers/root_listener.cjs.map +1 -0
- package/dist/tracers/root_listener.js +41 -76
- package/dist/tracers/root_listener.js.map +1 -0
- package/dist/tracers/run_collector.cjs +44 -48
- package/dist/tracers/run_collector.cjs.map +1 -0
- package/dist/tracers/run_collector.d.cts +34 -0
- package/dist/tracers/run_collector.d.cts.map +1 -0
- package/dist/tracers/run_collector.d.ts +27 -19
- package/dist/tracers/run_collector.d.ts.map +1 -0
- package/dist/tracers/run_collector.js +38 -44
- package/dist/tracers/run_collector.js.map +1 -0
- package/dist/tracers/tracer_langchain.cjs +91 -123
- package/dist/tracers/tracer_langchain.cjs.map +1 -0
- package/dist/tracers/tracer_langchain.d.cts +49 -0
- package/dist/tracers/tracer_langchain.d.cts.map +1 -0
- package/dist/tracers/tracer_langchain.d.ts +43 -38
- package/dist/tracers/tracer_langchain.d.ts.map +1 -0
- package/dist/tracers/tracer_langchain.js +84 -118
- package/dist/tracers/tracer_langchain.js.map +1 -0
- package/dist/tracers/tracer_langchain_v1.cjs +166 -198
- package/dist/tracers/tracer_langchain_v1.cjs.map +1 -0
- package/dist/tracers/tracer_langchain_v1.d.cts +64 -0
- package/dist/tracers/tracer_langchain_v1.d.cts.map +1 -0
- package/dist/tracers/tracer_langchain_v1.d.ts +56 -51
- package/dist/tracers/tracer_langchain_v1.d.ts.map +1 -0
- package/dist/tracers/tracer_langchain_v1.js +158 -192
- package/dist/tracers/tracer_langchain_v1.js.map +1 -0
- package/dist/types/_internal.d.cts +8 -0
- package/dist/types/_internal.d.cts.map +1 -0
- package/dist/types/_internal.d.ts +8 -1
- package/dist/types/_internal.d.ts.map +1 -0
- package/dist/types/stream.cjs +12 -2
- package/dist/types/stream.cjs.map +1 -0
- package/dist/types/stream.d.cts +3 -0
- package/dist/types/stream.d.ts +3 -2
- package/dist/types/stream.js +6 -1
- package/dist/types/stream.js.map +1 -0
- package/dist/types/type-utils.d.cts +7 -0
- package/dist/types/type-utils.d.cts.map +1 -0
- package/dist/types/type-utils.d.ts +7 -1
- package/dist/types/type-utils.d.ts.map +1 -0
- package/dist/utils/async_caller.cjs +81 -122
- package/dist/utils/async_caller.cjs.map +1 -0
- package/dist/utils/async_caller.d.cts +52 -0
- package/dist/utils/async_caller.d.cts.map +1 -0
- package/dist/utils/async_caller.d.ts +36 -29
- package/dist/utils/async_caller.d.ts.map +1 -0
- package/dist/utils/async_caller.js +74 -114
- package/dist/utils/async_caller.js.map +1 -0
- package/dist/utils/callbacks.cjs +14 -14
- package/dist/utils/callbacks.cjs.map +1 -0
- package/dist/utils/callbacks.js +15 -11
- package/dist/utils/callbacks.js.map +1 -0
- package/dist/utils/chunk_array.cjs +18 -8
- package/dist/utils/chunk_array.cjs.map +1 -0
- package/dist/utils/chunk_array.d.cts +5 -0
- package/dist/utils/chunk_array.d.cts.map +1 -0
- package/dist/utils/chunk_array.d.ts +5 -1
- package/dist/utils/chunk_array.d.ts.map +1 -0
- package/dist/utils/chunk_array.js +14 -6
- package/dist/utils/chunk_array.js.map +1 -0
- package/dist/utils/env.cjs +62 -72
- package/dist/utils/env.cjs.map +1 -0
- package/dist/utils/env.d.cts +36 -0
- package/dist/utils/env.d.cts.map +1 -0
- package/dist/utils/env.d.ts +30 -22
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +54 -66
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/event_source_parse.cjs +172 -225
- package/dist/utils/event_source_parse.cjs.map +1 -0
- package/dist/utils/event_source_parse.d.cts +47 -0
- package/dist/utils/event_source_parse.d.cts.map +1 -0
- package/dist/utils/event_source_parse.d.ts +22 -14
- package/dist/utils/event_source_parse.d.ts.map +1 -0
- package/dist/utils/event_source_parse.js +164 -220
- package/dist/utils/event_source_parse.js.map +1 -0
- package/dist/utils/fast-json-patch/index.cjs +14 -58
- package/dist/utils/fast-json-patch/index.cjs.map +1 -0
- package/dist/utils/fast-json-patch/index.js +14 -15
- package/dist/utils/fast-json-patch/index.js.map +1 -0
- package/dist/utils/fast-json-patch/src/core.cjs +319 -445
- package/dist/utils/fast-json-patch/src/core.cjs.map +1 -0
- package/dist/utils/fast-json-patch/src/core.d.cts +80 -0
- package/dist/utils/fast-json-patch/src/core.d.cts.map +1 -0
- package/dist/utils/fast-json-patch/src/core.d.ts +38 -69
- package/dist/utils/fast-json-patch/src/core.d.ts.map +1 -0
- package/dist/utils/fast-json-patch/src/core.js +314 -442
- package/dist/utils/fast-json-patch/src/core.js.map +1 -0
- package/dist/utils/fast-json-patch/src/duplex.cjs +72 -231
- package/dist/utils/fast-json-patch/src/duplex.cjs.map +1 -0
- package/dist/utils/fast-json-patch/src/duplex.d.cts +11 -0
- package/dist/utils/fast-json-patch/src/duplex.d.cts.map +1 -0
- package/dist/utils/fast-json-patch/src/duplex.d.ts +7 -19
- package/dist/utils/fast-json-patch/src/duplex.d.ts.map +1 -0
- package/dist/utils/fast-json-patch/src/duplex.js +73 -226
- package/dist/utils/fast-json-patch/src/duplex.js.map +1 -0
- package/dist/utils/fast-json-patch/src/helpers.cjs +99 -171
- package/dist/utils/fast-json-patch/src/helpers.cjs.map +1 -0
- package/dist/utils/fast-json-patch/src/helpers.js +99 -166
- package/dist/utils/fast-json-patch/src/helpers.js.map +1 -0
- package/dist/utils/function_calling.cjs +62 -59
- package/dist/utils/function_calling.cjs.map +1 -0
- package/dist/utils/function_calling.d.cts +43 -0
- package/dist/utils/function_calling.d.cts.map +1 -0
- package/dist/utils/function_calling.d.ts +22 -15
- package/dist/utils/function_calling.d.ts.map +1 -0
- package/dist/utils/function_calling.js +51 -50
- package/dist/utils/function_calling.js.map +1 -0
- package/dist/utils/hash.cjs +21 -7
- package/dist/utils/hash.cjs.map +1 -0
- package/dist/utils/hash.d.cts +14 -0
- package/dist/utils/hash.d.cts.map +1 -0
- package/dist/utils/hash.d.ts +9 -3
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +14 -2
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/js-sha1/hash.cjs +272 -356
- package/dist/utils/js-sha1/hash.cjs.map +1 -0
- package/dist/utils/js-sha1/hash.d.cts +9 -0
- package/dist/utils/js-sha1/hash.d.cts.map +1 -0
- package/dist/utils/js-sha1/hash.d.ts +5 -1
- package/dist/utils/js-sha1/hash.d.ts.map +1 -0
- package/dist/utils/js-sha1/hash.js +268 -356
- package/dist/utils/js-sha1/hash.js.map +1 -0
- package/dist/utils/js-sha256/hash.cjs +332 -430
- package/dist/utils/js-sha256/hash.cjs.map +1 -0
- package/dist/utils/js-sha256/hash.d.cts +5 -0
- package/dist/utils/js-sha256/hash.d.cts.map +1 -0
- package/dist/utils/js-sha256/hash.d.ts +5 -1
- package/dist/utils/js-sha256/hash.d.ts.map +1 -0
- package/dist/utils/js-sha256/hash.js +328 -430
- package/dist/utils/js-sha256/hash.js.map +1 -0
- package/dist/utils/json.cjs +47 -101
- package/dist/utils/json.cjs.map +1 -0
- package/dist/utils/json.d.cts +8 -0
- package/dist/utils/json.d.cts.map +1 -0
- package/dist/utils/json.d.ts +8 -2
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +47 -99
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/json_patch.cjs +22 -6
- package/dist/utils/json_patch.cjs.map +1 -0
- package/dist/utils/json_patch.d.cts +3 -0
- package/dist/utils/json_patch.d.ts +3 -1
- package/dist/utils/json_patch.js +15 -1
- package/dist/utils/json_patch.js.map +1 -0
- package/dist/utils/json_schema.cjs +77 -92
- package/dist/utils/json_schema.cjs.map +1 -0
- package/dist/utils/json_schema.d.cts +28 -0
- package/dist/utils/json_schema.d.cts.map +1 -0
- package/dist/utils/json_schema.d.ts +15 -6
- package/dist/utils/json_schema.d.ts.map +1 -0
- package/dist/utils/json_schema.js +58 -85
- package/dist/utils/json_schema.js.map +1 -0
- package/dist/utils/math.cjs +112 -108
- package/dist/utils/math.cjs.map +1 -0
- package/dist/utils/math.d.cts +43 -0
- package/dist/utils/math.d.cts.map +1 -0
- package/dist/utils/math.d.ts +10 -7
- package/dist/utils/math.d.ts.map +1 -0
- package/dist/utils/math.js +103 -102
- package/dist/utils/math.js.map +1 -0
- package/dist/utils/ml-distance/distances.cjs +15 -14
- package/dist/utils/ml-distance/distances.cjs.map +1 -0
- package/dist/utils/ml-distance/distances.js +15 -12
- package/dist/utils/ml-distance/distances.js.map +1 -0
- package/dist/utils/ml-distance/similarities.cjs +20 -17
- package/dist/utils/ml-distance/similarities.cjs.map +1 -0
- package/dist/utils/ml-distance/similarities.d.cts +11 -0
- package/dist/utils/ml-distance/similarities.d.cts.map +1 -0
- package/dist/utils/ml-distance/similarities.d.ts +5 -1
- package/dist/utils/ml-distance/similarities.d.ts.map +1 -0
- package/dist/utils/ml-distance/similarities.js +20 -15
- package/dist/utils/ml-distance/similarities.js.map +1 -0
- package/dist/utils/ml-distance-euclidean/euclidean.cjs +10 -10
- package/dist/utils/ml-distance-euclidean/euclidean.cjs.map +1 -0
- package/dist/utils/ml-distance-euclidean/euclidean.js +11 -8
- package/dist/utils/ml-distance-euclidean/euclidean.js.map +1 -0
- package/dist/utils/sax-js/sax.cjs +1206 -1556
- package/dist/utils/sax-js/sax.cjs.map +1 -0
- package/dist/utils/sax-js/sax.js +1205 -1553
- package/dist/utils/sax-js/sax.js.map +1 -0
- package/dist/utils/signal.cjs +39 -27
- package/dist/utils/signal.cjs.map +1 -0
- package/dist/utils/signal.js +38 -25
- package/dist/utils/signal.js.map +1 -0
- package/dist/utils/stream.cjs +186 -268
- package/dist/utils/stream.cjs.map +1 -0
- package/dist/utils/stream.d.cts +54 -0
- package/dist/utils/stream.d.cts.map +1 -0
- package/dist/utils/stream.d.ts +49 -33
- package/dist/utils/stream.d.ts.map +1 -0
- package/dist/utils/stream.js +177 -261
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/testing/index.cjs +664 -888
- package/dist/utils/testing/index.cjs.map +1 -0
- package/dist/utils/testing/index.d.cts +383 -0
- package/dist/utils/testing/index.d.cts.map +1 -0
- package/dist/utils/testing/index.d.ts +280 -250
- package/dist/utils/testing/index.d.ts.map +1 -0
- package/dist/utils/testing/index.js +639 -865
- package/dist/utils/testing/index.js.map +1 -0
- package/dist/utils/tiktoken.cjs +28 -19
- package/dist/utils/tiktoken.cjs.map +1 -0
- package/dist/utils/tiktoken.d.cts +8 -0
- package/dist/utils/tiktoken.d.cts.map +1 -0
- package/dist/utils/tiktoken.d.ts +7 -2
- package/dist/utils/tiktoken.d.ts.map +1 -0
- package/dist/utils/tiktoken.js +22 -16
- package/dist/utils/tiktoken.js.map +1 -0
- package/dist/utils/types/index.cjs +60 -17
- package/dist/utils/types/index.cjs.map +1 -0
- package/dist/utils/types/index.d.cts +16 -0
- package/dist/utils/types/index.d.cts.map +1 -0
- package/dist/utils/types/index.d.ts +13 -5
- package/dist/utils/types/index.d.ts.map +1 -0
- package/dist/utils/types/index.js +33 -1
- package/dist/utils/types/index.js.map +1 -0
- package/dist/utils/types/zod.cjs +376 -554
- package/dist/utils/types/zod.cjs.map +1 -0
- package/dist/utils/types/zod.d.cts +213 -0
- package/dist/utils/types/zod.d.cts.map +1 -0
- package/dist/utils/types/zod.d.ts +49 -48
- package/dist/utils/types/zod.d.ts.map +1 -0
- package/dist/utils/types/zod.js +376 -552
- package/dist/utils/types/zod.js.map +1 -0
- package/dist/vectorstores.cjs +391 -424
- package/dist/vectorstores.cjs.map +1 -0
- package/dist/vectorstores.d.cts +661 -0
- package/dist/vectorstores.d.cts.map +1 -0
- package/dist/vectorstores.d.ts +488 -471
- package/dist/vectorstores.d.ts.map +1 -0
- package/dist/vectorstores.js +383 -418
- package/dist/vectorstores.js.map +1 -0
- package/package.json +536 -654
- package/agents.cjs +0 -1
- package/agents.d.cts +0 -1
- package/agents.d.ts +0 -1
- package/agents.js +0 -1
- package/caches.cjs +0 -1
- package/caches.d.cts +0 -1
- package/caches.d.ts +0 -1
- package/caches.js +0 -1
- package/callbacks/base.cjs +0 -1
- package/callbacks/base.d.cts +0 -1
- package/callbacks/base.d.ts +0 -1
- package/callbacks/base.js +0 -1
- package/callbacks/dispatch/web.cjs +0 -1
- package/callbacks/dispatch/web.d.cts +0 -1
- package/callbacks/dispatch/web.d.ts +0 -1
- package/callbacks/dispatch/web.js +0 -1
- package/callbacks/dispatch.cjs +0 -1
- package/callbacks/dispatch.d.cts +0 -1
- package/callbacks/dispatch.d.ts +0 -1
- package/callbacks/dispatch.js +0 -1
- package/callbacks/manager.cjs +0 -1
- package/callbacks/manager.d.cts +0 -1
- package/callbacks/manager.d.ts +0 -1
- package/callbacks/manager.js +0 -1
- package/callbacks/promises.cjs +0 -1
- package/callbacks/promises.d.cts +0 -1
- package/callbacks/promises.d.ts +0 -1
- package/callbacks/promises.js +0 -1
- package/chat_history.cjs +0 -1
- package/chat_history.d.cts +0 -1
- package/chat_history.d.ts +0 -1
- package/chat_history.js +0 -1
- package/context.cjs +0 -1
- package/context.d.cts +0 -1
- package/context.d.ts +0 -1
- package/context.js +0 -1
- package/dist/errors/index.d.ts +0 -2
- package/dist/load/import_constants.d.ts +0 -1
- package/dist/load/import_map.d.ts +0 -43
- package/dist/load/import_type.cjs +0 -3
- package/dist/load/import_type.js +0 -2
- package/dist/messages/content_blocks.cjs +0 -165
- package/dist/messages/content_blocks.d.ts +0 -151
- package/dist/messages/content_blocks.js +0 -154
- package/dist/prompts/serde.cjs +0 -2
- package/dist/prompts/serde.js +0 -1
- package/dist/runnables/graph_mermaid.d.ts +0 -18
- package/dist/runnables/iter.d.ts +0 -6
- package/dist/runnables/types.cjs +0 -2
- package/dist/runnables/types.js +0 -1
- package/dist/runnables/utils.d.ts +0 -27
- package/dist/runnables/wrappers.d.ts +0 -2
- package/dist/singletons/tracer.d.ts +0 -3
- package/dist/tracers/root_listener.d.ts +0 -25
- package/dist/types/_internal.cjs +0 -2
- package/dist/types/_internal.js +0 -1
- package/dist/types/type-utils.cjs +0 -2
- package/dist/types/type-utils.js +0 -1
- package/dist/utils/callbacks.d.ts +0 -1
- package/dist/utils/fast-json-patch/index.d.ts +0 -22
- package/dist/utils/fast-json-patch/src/helpers.d.ts +0 -36
- package/dist/utils/ml-distance/distances.d.ts +0 -8
- package/dist/utils/ml-distance-euclidean/euclidean.d.ts +0 -2
- package/dist/utils/sax-js/sax.d.ts +0 -2
- package/dist/utils/signal.d.ts +0 -1
- package/dist/utils/testing/helpers.cjs +0 -7
- package/dist/utils/testing/helpers.d.ts +0 -3
- package/dist/utils/testing/helpers.js +0 -3
- package/document_loaders/base.cjs +0 -1
- package/document_loaders/base.d.cts +0 -1
- package/document_loaders/base.d.ts +0 -1
- package/document_loaders/base.js +0 -1
- package/document_loaders/langsmith.cjs +0 -1
- package/document_loaders/langsmith.d.cts +0 -1
- package/document_loaders/langsmith.d.ts +0 -1
- package/document_loaders/langsmith.js +0 -1
- package/documents.cjs +0 -1
- package/documents.d.cts +0 -1
- package/documents.d.ts +0 -1
- package/documents.js +0 -1
- package/embeddings.cjs +0 -1
- package/embeddings.d.cts +0 -1
- package/embeddings.d.ts +0 -1
- package/embeddings.js +0 -1
- package/example_selectors.cjs +0 -1
- package/example_selectors.d.cts +0 -1
- package/example_selectors.d.ts +0 -1
- package/example_selectors.js +0 -1
- package/indexing.cjs +0 -1
- package/indexing.d.cts +0 -1
- package/indexing.d.ts +0 -1
- package/indexing.js +0 -1
- package/language_models/base.cjs +0 -1
- package/language_models/base.d.cts +0 -1
- package/language_models/base.d.ts +0 -1
- package/language_models/base.js +0 -1
- package/language_models/chat_models.cjs +0 -1
- package/language_models/chat_models.d.cts +0 -1
- package/language_models/chat_models.d.ts +0 -1
- package/language_models/chat_models.js +0 -1
- package/language_models/llms.cjs +0 -1
- package/language_models/llms.d.cts +0 -1
- package/language_models/llms.d.ts +0 -1
- package/language_models/llms.js +0 -1
- package/load/serializable.cjs +0 -1
- package/load/serializable.d.cts +0 -1
- package/load/serializable.d.ts +0 -1
- package/load/serializable.js +0 -1
- package/load.cjs +0 -1
- package/load.d.cts +0 -1
- package/load.d.ts +0 -1
- package/load.js +0 -1
- package/memory.cjs +0 -1
- package/memory.d.cts +0 -1
- package/memory.d.ts +0 -1
- package/memory.js +0 -1
- package/messages/tool.cjs +0 -1
- package/messages/tool.d.cts +0 -1
- package/messages/tool.d.ts +0 -1
- package/messages/tool.js +0 -1
- package/messages.cjs +0 -1
- package/messages.d.cts +0 -1
- package/messages.d.ts +0 -1
- package/messages.js +0 -1
- package/output_parsers/openai_functions.cjs +0 -1
- package/output_parsers/openai_functions.d.cts +0 -1
- package/output_parsers/openai_functions.d.ts +0 -1
- package/output_parsers/openai_functions.js +0 -1
- package/output_parsers/openai_tools.cjs +0 -1
- package/output_parsers/openai_tools.d.cts +0 -1
- package/output_parsers/openai_tools.d.ts +0 -1
- package/output_parsers/openai_tools.js +0 -1
- package/output_parsers.cjs +0 -1
- package/output_parsers.d.cts +0 -1
- package/output_parsers.d.ts +0 -1
- package/output_parsers.js +0 -1
- package/outputs.cjs +0 -1
- package/outputs.d.cts +0 -1
- package/outputs.d.ts +0 -1
- package/outputs.js +0 -1
- package/prompt_values.cjs +0 -1
- package/prompt_values.d.cts +0 -1
- package/prompt_values.d.ts +0 -1
- package/prompt_values.js +0 -1
- package/prompts.cjs +0 -1
- package/prompts.d.cts +0 -1
- package/prompts.d.ts +0 -1
- package/prompts.js +0 -1
- package/retrievers/document_compressors.cjs +0 -1
- package/retrievers/document_compressors.d.cts +0 -1
- package/retrievers/document_compressors.d.ts +0 -1
- package/retrievers/document_compressors.js +0 -1
- package/retrievers.cjs +0 -1
- package/retrievers.d.cts +0 -1
- package/retrievers.d.ts +0 -1
- package/retrievers.js +0 -1
- package/runnables/graph.cjs +0 -1
- package/runnables/graph.d.cts +0 -1
- package/runnables/graph.d.ts +0 -1
- package/runnables/graph.js +0 -1
- package/runnables/remote.cjs +0 -1
- package/runnables/remote.d.cts +0 -1
- package/runnables/remote.d.ts +0 -1
- package/runnables/remote.js +0 -1
- package/runnables.cjs +0 -1
- package/runnables.d.cts +0 -1
- package/runnables.d.ts +0 -1
- package/runnables.js +0 -1
- package/singletons.cjs +0 -1
- package/singletons.d.cts +0 -1
- package/singletons.d.ts +0 -1
- package/singletons.js +0 -1
- package/stores.cjs +0 -1
- package/stores.d.cts +0 -1
- package/stores.d.ts +0 -1
- package/stores.js +0 -1
- package/structured_query.cjs +0 -1
- package/structured_query.d.cts +0 -1
- package/structured_query.d.ts +0 -1
- package/structured_query.js +0 -1
- package/tools.cjs +0 -1
- package/tools.d.cts +0 -1
- package/tools.d.ts +0 -1
- package/tools.js +0 -1
- package/tracers/base.cjs +0 -1
- package/tracers/base.d.cts +0 -1
- package/tracers/base.d.ts +0 -1
- package/tracers/base.js +0 -1
- package/tracers/console.cjs +0 -1
- package/tracers/console.d.cts +0 -1
- package/tracers/console.d.ts +0 -1
- package/tracers/console.js +0 -1
- package/tracers/initialize.cjs +0 -1
- package/tracers/initialize.d.cts +0 -1
- package/tracers/initialize.d.ts +0 -1
- package/tracers/initialize.js +0 -1
- package/tracers/log_stream.cjs +0 -1
- package/tracers/log_stream.d.cts +0 -1
- package/tracers/log_stream.d.ts +0 -1
- package/tracers/log_stream.js +0 -1
- package/tracers/run_collector.cjs +0 -1
- package/tracers/run_collector.d.cts +0 -1
- package/tracers/run_collector.d.ts +0 -1
- package/tracers/run_collector.js +0 -1
- package/tracers/tracer_langchain.cjs +0 -1
- package/tracers/tracer_langchain.d.cts +0 -1
- package/tracers/tracer_langchain.d.ts +0 -1
- package/tracers/tracer_langchain.js +0 -1
- package/tracers/tracer_langchain_v1.cjs +0 -1
- package/tracers/tracer_langchain_v1.d.cts +0 -1
- package/tracers/tracer_langchain_v1.d.ts +0 -1
- package/tracers/tracer_langchain_v1.js +0 -1
- package/types/stream.cjs +0 -1
- package/types/stream.d.cts +0 -1
- package/types/stream.d.ts +0 -1
- package/types/stream.js +0 -1
- package/utils/async_caller.cjs +0 -1
- package/utils/async_caller.d.cts +0 -1
- package/utils/async_caller.d.ts +0 -1
- package/utils/async_caller.js +0 -1
- package/utils/chunk_array.cjs +0 -1
- package/utils/chunk_array.d.cts +0 -1
- package/utils/chunk_array.d.ts +0 -1
- package/utils/chunk_array.js +0 -1
- package/utils/env.cjs +0 -1
- package/utils/env.d.cts +0 -1
- package/utils/env.d.ts +0 -1
- package/utils/env.js +0 -1
- package/utils/event_source_parse.cjs +0 -1
- package/utils/event_source_parse.d.cts +0 -1
- package/utils/event_source_parse.d.ts +0 -1
- package/utils/event_source_parse.js +0 -1
- package/utils/function_calling.cjs +0 -1
- package/utils/function_calling.d.cts +0 -1
- package/utils/function_calling.d.ts +0 -1
- package/utils/function_calling.js +0 -1
- package/utils/hash/insecure.cjs +0 -1
- package/utils/hash/insecure.d.cts +0 -1
- package/utils/hash/insecure.d.ts +0 -1
- package/utils/hash/insecure.js +0 -1
- package/utils/hash/sha256.cjs +0 -1
- package/utils/hash/sha256.d.cts +0 -1
- package/utils/hash/sha256.d.ts +0 -1
- package/utils/hash/sha256.js +0 -1
- package/utils/hash.cjs +0 -1
- package/utils/hash.d.cts +0 -1
- package/utils/hash.d.ts +0 -1
- package/utils/hash.js +0 -1
- package/utils/json_patch.cjs +0 -1
- package/utils/json_patch.d.cts +0 -1
- package/utils/json_patch.d.ts +0 -1
- package/utils/json_patch.js +0 -1
- package/utils/json_schema.cjs +0 -1
- package/utils/json_schema.d.cts +0 -1
- package/utils/json_schema.d.ts +0 -1
- package/utils/json_schema.js +0 -1
- package/utils/math.cjs +0 -1
- package/utils/math.d.cts +0 -1
- package/utils/math.d.ts +0 -1
- package/utils/math.js +0 -1
- package/utils/stream.cjs +0 -1
- package/utils/stream.d.cts +0 -1
- package/utils/stream.d.ts +0 -1
- package/utils/stream.js +0 -1
- package/utils/testing.cjs +0 -1
- package/utils/testing.d.cts +0 -1
- package/utils/testing.d.ts +0 -1
- package/utils/testing.js +0 -1
- package/utils/tiktoken.cjs +0 -1
- package/utils/tiktoken.d.cts +0 -1
- package/utils/tiktoken.d.ts +0 -1
- package/utils/tiktoken.js +0 -1
- package/utils/types.cjs +0 -1
- package/utils/types.d.cts +0 -1
- package/utils/types.d.ts +0 -1
- package/utils/types.js +0 -1
- package/vectorstores.cjs +0 -1
- package/vectorstores.d.cts +0 -1
- package/vectorstores.d.ts +0 -1
- package/vectorstores.js +0 -1
|
@@ -1,875 +1,649 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
import { __export } from "../../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { AIMessage, AIMessageChunk } from "../../messages/ai.js";
|
|
3
|
+
import { HumanMessage } from "../../messages/human.js";
|
|
4
|
+
import { BaseTracer } from "../../tracers/base.js";
|
|
5
|
+
import { ChatGenerationChunk } from "../../outputs.js";
|
|
6
|
+
import { toJsonSchema } from "../json_schema.js";
|
|
7
|
+
import { Runnable, RunnableLambda } from "../../runnables/base.js";
|
|
8
|
+
import "../../messages/index.js";
|
|
9
|
+
import { BaseChatMessageHistory, BaseListChatMessageHistory } from "../../chat_history.js";
|
|
10
|
+
import { Embeddings } from "../../embeddings.js";
|
|
11
|
+
import { BaseRetriever } from "../../retrievers/index.js";
|
|
12
|
+
import { VectorStore } from "../../vectorstores.js";
|
|
5
13
|
import { Document } from "../../documents/document.js";
|
|
6
|
-
import { BaseChatModel
|
|
14
|
+
import { BaseChatModel } from "../../language_models/chat_models.js";
|
|
7
15
|
import { LLM } from "../../language_models/llms.js";
|
|
8
|
-
import { AIMessage, AIMessageChunk, HumanMessage, } from "../../messages/index.js";
|
|
9
16
|
import { BaseOutputParser } from "../../output_parsers/base.js";
|
|
10
|
-
import { ChatGenerationChunk, } from "../../outputs.js";
|
|
11
|
-
import { BaseRetriever } from "../../retrievers/index.js";
|
|
12
|
-
import { Runnable, RunnableLambda } from "../../runnables/base.js";
|
|
13
17
|
import { StructuredTool } from "../../tools/index.js";
|
|
14
|
-
import { BaseTracer } from "../../tracers/base.js";
|
|
15
|
-
import { Embeddings, } from "../../embeddings.js";
|
|
16
|
-
import { toJsonSchema } from "../json_schema.js";
|
|
17
|
-
import { VectorStore } from "../../vectorstores.js";
|
|
18
18
|
import { cosine } from "../ml-distance/similarities.js";
|
|
19
|
+
|
|
20
|
+
//#region src/utils/testing/index.ts
|
|
21
|
+
var testing_exports = {};
|
|
22
|
+
__export(testing_exports, {
|
|
23
|
+
FakeChatMessageHistory: () => FakeChatMessageHistory,
|
|
24
|
+
FakeChatModel: () => FakeChatModel,
|
|
25
|
+
FakeEmbeddings: () => FakeEmbeddings,
|
|
26
|
+
FakeLLM: () => FakeLLM,
|
|
27
|
+
FakeListChatMessageHistory: () => FakeListChatMessageHistory,
|
|
28
|
+
FakeListChatModel: () => FakeListChatModel,
|
|
29
|
+
FakeRetriever: () => FakeRetriever,
|
|
30
|
+
FakeRunnable: () => FakeRunnable,
|
|
31
|
+
FakeSplitIntoListParser: () => FakeSplitIntoListParser,
|
|
32
|
+
FakeStreamingChatModel: () => FakeStreamingChatModel,
|
|
33
|
+
FakeStreamingLLM: () => FakeStreamingLLM,
|
|
34
|
+
FakeTool: () => FakeTool,
|
|
35
|
+
FakeTracer: () => FakeTracer,
|
|
36
|
+
FakeVectorStore: () => FakeVectorStore,
|
|
37
|
+
SingleRunExtractor: () => SingleRunExtractor,
|
|
38
|
+
SyntheticEmbeddings: () => SyntheticEmbeddings
|
|
39
|
+
});
|
|
19
40
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
case "openai":
|
|
234
|
-
return {
|
|
235
|
-
type: "function",
|
|
236
|
-
function: {
|
|
237
|
-
name: t.name,
|
|
238
|
-
description: t.description,
|
|
239
|
-
parameters: toJsonSchema(t.schema),
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
case "anthropic":
|
|
243
|
-
return {
|
|
244
|
-
name: t.name,
|
|
245
|
-
description: t.description,
|
|
246
|
-
input_schema: toJsonSchema(t.schema),
|
|
247
|
-
};
|
|
248
|
-
case "bedrock":
|
|
249
|
-
return {
|
|
250
|
-
toolSpec: {
|
|
251
|
-
name: t.name,
|
|
252
|
-
description: t.description,
|
|
253
|
-
inputSchema: toJsonSchema(t.schema),
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
case "google":
|
|
257
|
-
return {
|
|
258
|
-
name: t.name,
|
|
259
|
-
description: t.description,
|
|
260
|
-
parameters: toJsonSchema(t.schema),
|
|
261
|
-
};
|
|
262
|
-
default:
|
|
263
|
-
throw new Error(`Unsupported tool style: ${this.toolStyle}`);
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
const wrapped = this.toolStyle === "google"
|
|
267
|
-
? [{ functionDeclarations: toolDicts }]
|
|
268
|
-
: toolDicts;
|
|
269
|
-
/* creating a *new* instance – mirrors LangChain .bind semantics for type-safety and avoiding noise */
|
|
270
|
-
const next = new FakeStreamingChatModel({
|
|
271
|
-
sleep: this.sleep,
|
|
272
|
-
responses: this.responses,
|
|
273
|
-
chunks: this.chunks,
|
|
274
|
-
toolStyle: this.toolStyle,
|
|
275
|
-
thrownErrorString: this.thrownErrorString,
|
|
276
|
-
});
|
|
277
|
-
next.tools = merged;
|
|
278
|
-
return next.withConfig({ tools: wrapped });
|
|
279
|
-
}
|
|
280
|
-
async _generate(messages, _options, _runManager) {
|
|
281
|
-
if (this.thrownErrorString) {
|
|
282
|
-
throw new Error(this.thrownErrorString);
|
|
283
|
-
}
|
|
284
|
-
const content = this.responses?.[0]?.content ?? messages[0].content ?? "";
|
|
285
|
-
const generation = {
|
|
286
|
-
generations: [
|
|
287
|
-
{
|
|
288
|
-
text: "",
|
|
289
|
-
message: new AIMessage({
|
|
290
|
-
content,
|
|
291
|
-
tool_calls: this.chunks?.[0]?.tool_calls,
|
|
292
|
-
}),
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
};
|
|
296
|
-
return generation;
|
|
297
|
-
}
|
|
298
|
-
async *_streamResponseChunks(_messages, _options, runManager) {
|
|
299
|
-
if (this.thrownErrorString) {
|
|
300
|
-
throw new Error(this.thrownErrorString);
|
|
301
|
-
}
|
|
302
|
-
if (this.chunks?.length) {
|
|
303
|
-
for (const msgChunk of this.chunks) {
|
|
304
|
-
const cg = new ChatGenerationChunk({
|
|
305
|
-
message: new AIMessageChunk({
|
|
306
|
-
content: msgChunk.content,
|
|
307
|
-
tool_calls: msgChunk.tool_calls,
|
|
308
|
-
additional_kwargs: msgChunk.additional_kwargs ?? {},
|
|
309
|
-
}),
|
|
310
|
-
text: msgChunk.content?.toString() ?? "",
|
|
311
|
-
});
|
|
312
|
-
yield cg;
|
|
313
|
-
await runManager?.handleLLMNewToken(msgChunk.content, undefined, undefined, undefined, undefined, { chunk: cg });
|
|
314
|
-
}
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
const fallback = this.responses?.[0] ??
|
|
318
|
-
new AIMessage(typeof _messages[0].content === "string" ? _messages[0].content : "");
|
|
319
|
-
const text = typeof fallback.content === "string" ? fallback.content : "";
|
|
320
|
-
for (const ch of text) {
|
|
321
|
-
await new Promise((r) => setTimeout(r, this.sleep));
|
|
322
|
-
const cg = new ChatGenerationChunk({
|
|
323
|
-
message: new AIMessageChunk({ content: ch }),
|
|
324
|
-
text: ch,
|
|
325
|
-
});
|
|
326
|
-
yield cg;
|
|
327
|
-
await runManager?.handleLLMNewToken(ch, undefined, undefined, undefined, undefined, { chunk: cg });
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
export class FakeRetriever extends BaseRetriever {
|
|
332
|
-
constructor(fields) {
|
|
333
|
-
super();
|
|
334
|
-
Object.defineProperty(this, "lc_namespace", {
|
|
335
|
-
enumerable: true,
|
|
336
|
-
configurable: true,
|
|
337
|
-
writable: true,
|
|
338
|
-
value: ["test", "fake"]
|
|
339
|
-
});
|
|
340
|
-
Object.defineProperty(this, "output", {
|
|
341
|
-
enumerable: true,
|
|
342
|
-
configurable: true,
|
|
343
|
-
writable: true,
|
|
344
|
-
value: [
|
|
345
|
-
new Document({ pageContent: "foo" }),
|
|
346
|
-
new Document({ pageContent: "bar" }),
|
|
347
|
-
]
|
|
348
|
-
});
|
|
349
|
-
this.output = fields?.output ?? this.output;
|
|
350
|
-
}
|
|
351
|
-
async _getRelevantDocuments(_query
|
|
352
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
353
|
-
) {
|
|
354
|
-
return this.output;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
41
|
+
* Parser for comma-separated values. It splits the input text by commas
|
|
42
|
+
* and trims the resulting values.
|
|
43
|
+
*/
|
|
44
|
+
var FakeSplitIntoListParser = class extends BaseOutputParser {
|
|
45
|
+
lc_namespace = ["tests", "fake"];
|
|
46
|
+
getFormatInstructions() {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
async parse(text) {
|
|
50
|
+
return text.split(",").map((value) => value.trim());
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var FakeRunnable = class extends Runnable {
|
|
54
|
+
lc_namespace = ["tests", "fake"];
|
|
55
|
+
returnOptions;
|
|
56
|
+
constructor(fields) {
|
|
57
|
+
super(fields);
|
|
58
|
+
this.returnOptions = fields.returnOptions;
|
|
59
|
+
}
|
|
60
|
+
async invoke(input, options) {
|
|
61
|
+
if (this.returnOptions) return options ?? {};
|
|
62
|
+
return { input };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var FakeLLM = class extends LLM {
|
|
66
|
+
response;
|
|
67
|
+
thrownErrorString;
|
|
68
|
+
constructor(fields) {
|
|
69
|
+
super(fields);
|
|
70
|
+
this.response = fields.response;
|
|
71
|
+
this.thrownErrorString = fields.thrownErrorString;
|
|
72
|
+
}
|
|
73
|
+
_llmType() {
|
|
74
|
+
return "fake";
|
|
75
|
+
}
|
|
76
|
+
async _call(prompt, _options, runManager) {
|
|
77
|
+
if (this.thrownErrorString) throw new Error(this.thrownErrorString);
|
|
78
|
+
const response = this.response ?? prompt;
|
|
79
|
+
await runManager?.handleLLMNewToken(response);
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var FakeStreamingLLM = class extends LLM {
|
|
84
|
+
sleep = 50;
|
|
85
|
+
responses;
|
|
86
|
+
thrownErrorString;
|
|
87
|
+
constructor(fields) {
|
|
88
|
+
super(fields);
|
|
89
|
+
this.sleep = fields.sleep ?? this.sleep;
|
|
90
|
+
this.responses = fields.responses;
|
|
91
|
+
this.thrownErrorString = fields.thrownErrorString;
|
|
92
|
+
}
|
|
93
|
+
_llmType() {
|
|
94
|
+
return "fake";
|
|
95
|
+
}
|
|
96
|
+
async _call(prompt) {
|
|
97
|
+
if (this.thrownErrorString) throw new Error(this.thrownErrorString);
|
|
98
|
+
const response = this.responses?.[0];
|
|
99
|
+
this.responses = this.responses?.slice(1);
|
|
100
|
+
return response ?? prompt;
|
|
101
|
+
}
|
|
102
|
+
async *_streamResponseChunks(input, _options, runManager) {
|
|
103
|
+
if (this.thrownErrorString) throw new Error(this.thrownErrorString);
|
|
104
|
+
const response = this.responses?.[0];
|
|
105
|
+
this.responses = this.responses?.slice(1);
|
|
106
|
+
for (const c of response ?? input) {
|
|
107
|
+
await new Promise((resolve) => setTimeout(resolve, this.sleep));
|
|
108
|
+
yield {
|
|
109
|
+
text: c,
|
|
110
|
+
generationInfo: {}
|
|
111
|
+
};
|
|
112
|
+
await runManager?.handleLLMNewToken(c);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var FakeChatModel = class extends BaseChatModel {
|
|
117
|
+
_combineLLMOutput() {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
_llmType() {
|
|
121
|
+
return "fake";
|
|
122
|
+
}
|
|
123
|
+
async _generate(messages, options, runManager) {
|
|
124
|
+
if (options?.stop?.length) return { generations: [{
|
|
125
|
+
message: new AIMessage(options.stop[0]),
|
|
126
|
+
text: options.stop[0]
|
|
127
|
+
}] };
|
|
128
|
+
const text = messages.map((m) => {
|
|
129
|
+
if (typeof m.content === "string") return m.content;
|
|
130
|
+
return JSON.stringify(m.content, null, 2);
|
|
131
|
+
}).join("\n");
|
|
132
|
+
await runManager?.handleLLMNewToken(text);
|
|
133
|
+
return {
|
|
134
|
+
generations: [{
|
|
135
|
+
message: new AIMessage(text),
|
|
136
|
+
text
|
|
137
|
+
}],
|
|
138
|
+
llmOutput: {}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var FakeStreamingChatModel = class FakeStreamingChatModel extends BaseChatModel {
|
|
143
|
+
sleep = 50;
|
|
144
|
+
responses = [];
|
|
145
|
+
chunks = [];
|
|
146
|
+
toolStyle = "openai";
|
|
147
|
+
thrownErrorString;
|
|
148
|
+
tools = [];
|
|
149
|
+
constructor({ sleep = 50, responses = [], chunks = [], toolStyle = "openai", thrownErrorString,...rest }) {
|
|
150
|
+
super(rest);
|
|
151
|
+
this.sleep = sleep;
|
|
152
|
+
this.responses = responses;
|
|
153
|
+
this.chunks = chunks;
|
|
154
|
+
this.toolStyle = toolStyle;
|
|
155
|
+
this.thrownErrorString = thrownErrorString;
|
|
156
|
+
}
|
|
157
|
+
_llmType() {
|
|
158
|
+
return "fake";
|
|
159
|
+
}
|
|
160
|
+
bindTools(tools) {
|
|
161
|
+
const merged = [...this.tools, ...tools];
|
|
162
|
+
const toolDicts = merged.map((t) => {
|
|
163
|
+
switch (this.toolStyle) {
|
|
164
|
+
case "openai": return {
|
|
165
|
+
type: "function",
|
|
166
|
+
function: {
|
|
167
|
+
name: t.name,
|
|
168
|
+
description: t.description,
|
|
169
|
+
parameters: toJsonSchema(t.schema)
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
case "anthropic": return {
|
|
173
|
+
name: t.name,
|
|
174
|
+
description: t.description,
|
|
175
|
+
input_schema: toJsonSchema(t.schema)
|
|
176
|
+
};
|
|
177
|
+
case "bedrock": return { toolSpec: {
|
|
178
|
+
name: t.name,
|
|
179
|
+
description: t.description,
|
|
180
|
+
inputSchema: toJsonSchema(t.schema)
|
|
181
|
+
} };
|
|
182
|
+
case "google": return {
|
|
183
|
+
name: t.name,
|
|
184
|
+
description: t.description,
|
|
185
|
+
parameters: toJsonSchema(t.schema)
|
|
186
|
+
};
|
|
187
|
+
default: throw new Error(`Unsupported tool style: ${this.toolStyle}`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const wrapped = this.toolStyle === "google" ? [{ functionDeclarations: toolDicts }] : toolDicts;
|
|
191
|
+
const next = new FakeStreamingChatModel({
|
|
192
|
+
sleep: this.sleep,
|
|
193
|
+
responses: this.responses,
|
|
194
|
+
chunks: this.chunks,
|
|
195
|
+
toolStyle: this.toolStyle,
|
|
196
|
+
thrownErrorString: this.thrownErrorString
|
|
197
|
+
});
|
|
198
|
+
next.tools = merged;
|
|
199
|
+
return next.withConfig({ tools: wrapped });
|
|
200
|
+
}
|
|
201
|
+
async _generate(messages, _options, _runManager) {
|
|
202
|
+
if (this.thrownErrorString) throw new Error(this.thrownErrorString);
|
|
203
|
+
const content = this.responses?.[0]?.content ?? messages[0].content ?? "";
|
|
204
|
+
const generation = { generations: [{
|
|
205
|
+
text: "",
|
|
206
|
+
message: new AIMessage({
|
|
207
|
+
content,
|
|
208
|
+
tool_calls: this.chunks?.[0]?.tool_calls
|
|
209
|
+
})
|
|
210
|
+
}] };
|
|
211
|
+
return generation;
|
|
212
|
+
}
|
|
213
|
+
async *_streamResponseChunks(_messages, _options, runManager) {
|
|
214
|
+
if (this.thrownErrorString) throw new Error(this.thrownErrorString);
|
|
215
|
+
if (this.chunks?.length) {
|
|
216
|
+
for (const msgChunk of this.chunks) {
|
|
217
|
+
const cg = new ChatGenerationChunk({
|
|
218
|
+
message: new AIMessageChunk({
|
|
219
|
+
content: msgChunk.content,
|
|
220
|
+
tool_calls: msgChunk.tool_calls,
|
|
221
|
+
additional_kwargs: msgChunk.additional_kwargs ?? {}
|
|
222
|
+
}),
|
|
223
|
+
text: msgChunk.content?.toString() ?? ""
|
|
224
|
+
});
|
|
225
|
+
yield cg;
|
|
226
|
+
await runManager?.handleLLMNewToken(msgChunk.content, void 0, void 0, void 0, void 0, { chunk: cg });
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const fallback = this.responses?.[0] ?? new AIMessage(typeof _messages[0].content === "string" ? _messages[0].content : "");
|
|
231
|
+
const text = typeof fallback.content === "string" ? fallback.content : "";
|
|
232
|
+
for (const ch of text) {
|
|
233
|
+
await new Promise((r) => setTimeout(r, this.sleep));
|
|
234
|
+
const cg = new ChatGenerationChunk({
|
|
235
|
+
message: new AIMessageChunk({ content: ch }),
|
|
236
|
+
text: ch
|
|
237
|
+
});
|
|
238
|
+
yield cg;
|
|
239
|
+
await runManager?.handleLLMNewToken(ch, void 0, void 0, void 0, void 0, { chunk: cg });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var FakeRetriever = class extends BaseRetriever {
|
|
244
|
+
lc_namespace = ["test", "fake"];
|
|
245
|
+
output = [new Document({ pageContent: "foo" }), new Document({ pageContent: "bar" })];
|
|
246
|
+
constructor(fields) {
|
|
247
|
+
super();
|
|
248
|
+
this.output = fields?.output ?? this.output;
|
|
249
|
+
}
|
|
250
|
+
async _getRelevantDocuments(_query) {
|
|
251
|
+
return this.output;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
357
254
|
/**
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
return this.messages;
|
|
530
|
-
}
|
|
531
|
-
async addMessage(message) {
|
|
532
|
-
this.messages.push(message);
|
|
533
|
-
}
|
|
534
|
-
async addUserMessage(message) {
|
|
535
|
-
this.messages.push(new HumanMessage(message));
|
|
536
|
-
}
|
|
537
|
-
async addAIChatMessage(message) {
|
|
538
|
-
this.messages.push(new AIMessage(message));
|
|
539
|
-
}
|
|
540
|
-
async clear() {
|
|
541
|
-
this.messages = [];
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
export class FakeListChatMessageHistory extends BaseListChatMessageHistory {
|
|
545
|
-
constructor() {
|
|
546
|
-
super();
|
|
547
|
-
Object.defineProperty(this, "lc_namespace", {
|
|
548
|
-
enumerable: true,
|
|
549
|
-
configurable: true,
|
|
550
|
-
writable: true,
|
|
551
|
-
value: ["langchain_core", "message", "fake"]
|
|
552
|
-
});
|
|
553
|
-
Object.defineProperty(this, "messages", {
|
|
554
|
-
enumerable: true,
|
|
555
|
-
configurable: true,
|
|
556
|
-
writable: true,
|
|
557
|
-
value: []
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
async addMessage(message) {
|
|
561
|
-
this.messages.push(message);
|
|
562
|
-
}
|
|
563
|
-
async getMessages() {
|
|
564
|
-
return this.messages;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
export class FakeTracer extends BaseTracer {
|
|
568
|
-
constructor() {
|
|
569
|
-
super();
|
|
570
|
-
Object.defineProperty(this, "name", {
|
|
571
|
-
enumerable: true,
|
|
572
|
-
configurable: true,
|
|
573
|
-
writable: true,
|
|
574
|
-
value: "fake_tracer"
|
|
575
|
-
});
|
|
576
|
-
Object.defineProperty(this, "runs", {
|
|
577
|
-
enumerable: true,
|
|
578
|
-
configurable: true,
|
|
579
|
-
writable: true,
|
|
580
|
-
value: []
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
persistRun(run) {
|
|
584
|
-
this.runs.push(run);
|
|
585
|
-
return Promise.resolve();
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
export class FakeTool extends StructuredTool {
|
|
589
|
-
constructor(fields) {
|
|
590
|
-
super(fields);
|
|
591
|
-
Object.defineProperty(this, "name", {
|
|
592
|
-
enumerable: true,
|
|
593
|
-
configurable: true,
|
|
594
|
-
writable: true,
|
|
595
|
-
value: void 0
|
|
596
|
-
});
|
|
597
|
-
Object.defineProperty(this, "description", {
|
|
598
|
-
enumerable: true,
|
|
599
|
-
configurable: true,
|
|
600
|
-
writable: true,
|
|
601
|
-
value: void 0
|
|
602
|
-
});
|
|
603
|
-
Object.defineProperty(this, "schema", {
|
|
604
|
-
enumerable: true,
|
|
605
|
-
configurable: true,
|
|
606
|
-
writable: true,
|
|
607
|
-
value: void 0
|
|
608
|
-
});
|
|
609
|
-
this.name = fields.name;
|
|
610
|
-
this.description = fields.description;
|
|
611
|
-
this.schema = fields.schema;
|
|
612
|
-
}
|
|
613
|
-
async _call(arg, _runManager) {
|
|
614
|
-
return JSON.stringify(arg);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
255
|
+
* A fake Chat Model that returns a predefined list of responses. It can be used
|
|
256
|
+
* for testing purposes.
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* const chat = new FakeListChatModel({
|
|
260
|
+
* responses: ["I'll callback later.", "You 'console' them!"]
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* const firstMessage = new HumanMessage("You want to hear a JavaScript joke?");
|
|
264
|
+
* const secondMessage = new HumanMessage("How do you cheer up a JavaScript developer?");
|
|
265
|
+
*
|
|
266
|
+
* // Call the chat model with a message and log the response
|
|
267
|
+
* const firstResponse = await chat.call([firstMessage]);
|
|
268
|
+
* console.log({ firstResponse });
|
|
269
|
+
*
|
|
270
|
+
* const secondResponse = await chat.call([secondMessage]);
|
|
271
|
+
* console.log({ secondResponse });
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
var FakeListChatModel = class extends BaseChatModel {
|
|
275
|
+
static lc_name() {
|
|
276
|
+
return "FakeListChatModel";
|
|
277
|
+
}
|
|
278
|
+
lc_serializable = true;
|
|
279
|
+
responses;
|
|
280
|
+
i = 0;
|
|
281
|
+
sleep;
|
|
282
|
+
emitCustomEvent = false;
|
|
283
|
+
constructor(params) {
|
|
284
|
+
super(params);
|
|
285
|
+
const { responses, sleep, emitCustomEvent } = params;
|
|
286
|
+
this.responses = responses;
|
|
287
|
+
this.sleep = sleep;
|
|
288
|
+
this.emitCustomEvent = emitCustomEvent ?? this.emitCustomEvent;
|
|
289
|
+
}
|
|
290
|
+
_combineLLMOutput() {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
_llmType() {
|
|
294
|
+
return "fake-list";
|
|
295
|
+
}
|
|
296
|
+
async _generate(_messages, options, runManager) {
|
|
297
|
+
await this._sleepIfRequested();
|
|
298
|
+
if (options?.thrownErrorString) throw new Error(options.thrownErrorString);
|
|
299
|
+
if (this.emitCustomEvent) await runManager?.handleCustomEvent("some_test_event", { someval: true });
|
|
300
|
+
if (options?.stop?.length) return { generations: [this._formatGeneration(options.stop[0])] };
|
|
301
|
+
else {
|
|
302
|
+
const response = this._currentResponse();
|
|
303
|
+
this._incrementResponse();
|
|
304
|
+
return {
|
|
305
|
+
generations: [this._formatGeneration(response)],
|
|
306
|
+
llmOutput: {}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
_formatGeneration(text) {
|
|
311
|
+
return {
|
|
312
|
+
message: new AIMessage(text),
|
|
313
|
+
text
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
async *_streamResponseChunks(_messages, options, runManager) {
|
|
317
|
+
const response = this._currentResponse();
|
|
318
|
+
this._incrementResponse();
|
|
319
|
+
if (this.emitCustomEvent) await runManager?.handleCustomEvent("some_test_event", { someval: true });
|
|
320
|
+
for await (const text of response) {
|
|
321
|
+
await this._sleepIfRequested();
|
|
322
|
+
if (options?.thrownErrorString) throw new Error(options.thrownErrorString);
|
|
323
|
+
const chunk = this._createResponseChunk(text);
|
|
324
|
+
yield chunk;
|
|
325
|
+
runManager?.handleLLMNewToken(text);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
async _sleepIfRequested() {
|
|
329
|
+
if (this.sleep !== void 0) await this._sleep();
|
|
330
|
+
}
|
|
331
|
+
async _sleep() {
|
|
332
|
+
return new Promise((resolve) => {
|
|
333
|
+
setTimeout(() => resolve(), this.sleep);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
_createResponseChunk(text) {
|
|
337
|
+
return new ChatGenerationChunk({
|
|
338
|
+
message: new AIMessageChunk({ content: text }),
|
|
339
|
+
text
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
_currentResponse() {
|
|
343
|
+
return this.responses[this.i];
|
|
344
|
+
}
|
|
345
|
+
_incrementResponse() {
|
|
346
|
+
if (this.i < this.responses.length - 1) this.i += 1;
|
|
347
|
+
else this.i = 0;
|
|
348
|
+
}
|
|
349
|
+
withStructuredOutput(_params, _config) {
|
|
350
|
+
return RunnableLambda.from(async (input) => {
|
|
351
|
+
const message = await this.invoke(input);
|
|
352
|
+
if (message.tool_calls?.[0]?.args) return message.tool_calls[0].args;
|
|
353
|
+
if (typeof message.content === "string") return JSON.parse(message.content);
|
|
354
|
+
throw new Error("No structured output found");
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var FakeChatMessageHistory = class extends BaseChatMessageHistory {
|
|
359
|
+
lc_namespace = [
|
|
360
|
+
"langchain_core",
|
|
361
|
+
"message",
|
|
362
|
+
"fake"
|
|
363
|
+
];
|
|
364
|
+
messages = [];
|
|
365
|
+
constructor() {
|
|
366
|
+
super();
|
|
367
|
+
}
|
|
368
|
+
async getMessages() {
|
|
369
|
+
return this.messages;
|
|
370
|
+
}
|
|
371
|
+
async addMessage(message) {
|
|
372
|
+
this.messages.push(message);
|
|
373
|
+
}
|
|
374
|
+
async addUserMessage(message) {
|
|
375
|
+
this.messages.push(new HumanMessage(message));
|
|
376
|
+
}
|
|
377
|
+
async addAIChatMessage(message) {
|
|
378
|
+
this.messages.push(new AIMessage(message));
|
|
379
|
+
}
|
|
380
|
+
async clear() {
|
|
381
|
+
this.messages = [];
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
var FakeListChatMessageHistory = class extends BaseListChatMessageHistory {
|
|
385
|
+
lc_namespace = [
|
|
386
|
+
"langchain_core",
|
|
387
|
+
"message",
|
|
388
|
+
"fake"
|
|
389
|
+
];
|
|
390
|
+
messages = [];
|
|
391
|
+
constructor() {
|
|
392
|
+
super();
|
|
393
|
+
}
|
|
394
|
+
async addMessage(message) {
|
|
395
|
+
this.messages.push(message);
|
|
396
|
+
}
|
|
397
|
+
async getMessages() {
|
|
398
|
+
return this.messages;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
var FakeTracer = class extends BaseTracer {
|
|
402
|
+
name = "fake_tracer";
|
|
403
|
+
runs = [];
|
|
404
|
+
constructor() {
|
|
405
|
+
super();
|
|
406
|
+
}
|
|
407
|
+
persistRun(run) {
|
|
408
|
+
this.runs.push(run);
|
|
409
|
+
return Promise.resolve();
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
var FakeTool = class extends StructuredTool {
|
|
413
|
+
name;
|
|
414
|
+
description;
|
|
415
|
+
schema;
|
|
416
|
+
constructor(fields) {
|
|
417
|
+
super(fields);
|
|
418
|
+
this.name = fields.name;
|
|
419
|
+
this.description = fields.description;
|
|
420
|
+
this.schema = fields.schema;
|
|
421
|
+
}
|
|
422
|
+
async _call(arg, _runManager) {
|
|
423
|
+
return JSON.stringify(arg);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
617
426
|
/**
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
427
|
+
* A class that provides fake embeddings by overriding the embedDocuments
|
|
428
|
+
* and embedQuery methods to return fixed values.
|
|
429
|
+
*/
|
|
430
|
+
var FakeEmbeddings = class extends Embeddings {
|
|
431
|
+
constructor(params) {
|
|
432
|
+
super(params ?? {});
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Generates fixed embeddings for a list of documents.
|
|
436
|
+
* @param documents List of documents to generate embeddings for.
|
|
437
|
+
* @returns A promise that resolves with a list of fixed embeddings for each document.
|
|
438
|
+
*/
|
|
439
|
+
embedDocuments(documents) {
|
|
440
|
+
return Promise.resolve(documents.map(() => [
|
|
441
|
+
.1,
|
|
442
|
+
.2,
|
|
443
|
+
.3,
|
|
444
|
+
.4
|
|
445
|
+
]));
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Generates a fixed embedding for a query.
|
|
449
|
+
* @param _ The query to generate an embedding for.
|
|
450
|
+
* @returns A promise that resolves with a fixed embedding for the query.
|
|
451
|
+
*/
|
|
452
|
+
embedQuery(_) {
|
|
453
|
+
return Promise.resolve([
|
|
454
|
+
.1,
|
|
455
|
+
.2,
|
|
456
|
+
.3,
|
|
457
|
+
.4
|
|
458
|
+
]);
|
|
459
|
+
}
|
|
460
|
+
};
|
|
642
461
|
/**
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
super();
|
|
708
|
-
Object.defineProperty(this, "runPromiseResolver", {
|
|
709
|
-
enumerable: true,
|
|
710
|
-
configurable: true,
|
|
711
|
-
writable: true,
|
|
712
|
-
value: void 0
|
|
713
|
-
});
|
|
714
|
-
Object.defineProperty(this, "runPromise", {
|
|
715
|
-
enumerable: true,
|
|
716
|
-
configurable: true,
|
|
717
|
-
writable: true,
|
|
718
|
-
value: void 0
|
|
719
|
-
});
|
|
720
|
-
/** The name of the callback handler. */
|
|
721
|
-
Object.defineProperty(this, "name", {
|
|
722
|
-
enumerable: true,
|
|
723
|
-
configurable: true,
|
|
724
|
-
writable: true,
|
|
725
|
-
value: "single_run_extractor"
|
|
726
|
-
});
|
|
727
|
-
this.runPromise = new Promise((extract) => {
|
|
728
|
-
this.runPromiseResolver = extract;
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
async persistRun(run) {
|
|
732
|
-
this.runPromiseResolver(run);
|
|
733
|
-
}
|
|
734
|
-
async extract() {
|
|
735
|
-
return this.runPromise;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
462
|
+
* A class that provides synthetic embeddings by overriding the
|
|
463
|
+
* embedDocuments and embedQuery methods to generate embeddings based on
|
|
464
|
+
* the input documents. The embeddings are generated by converting each
|
|
465
|
+
* document into chunks, calculating a numerical value for each chunk, and
|
|
466
|
+
* returning an array of these values as the embedding.
|
|
467
|
+
*/
|
|
468
|
+
var SyntheticEmbeddings = class extends Embeddings {
|
|
469
|
+
vectorSize;
|
|
470
|
+
constructor(params) {
|
|
471
|
+
super(params ?? {});
|
|
472
|
+
this.vectorSize = params?.vectorSize ?? 4;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Generates synthetic embeddings for a list of documents.
|
|
476
|
+
* @param documents List of documents to generate embeddings for.
|
|
477
|
+
* @returns A promise that resolves with a list of synthetic embeddings for each document.
|
|
478
|
+
*/
|
|
479
|
+
async embedDocuments(documents) {
|
|
480
|
+
return Promise.all(documents.map((doc) => this.embedQuery(doc)));
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Generates a synthetic embedding for a document. The document is
|
|
484
|
+
* converted into chunks, a numerical value is calculated for each chunk,
|
|
485
|
+
* and an array of these values is returned as the embedding.
|
|
486
|
+
* @param document The document to generate an embedding for.
|
|
487
|
+
* @returns A promise that resolves with a synthetic embedding for the document.
|
|
488
|
+
*/
|
|
489
|
+
async embedQuery(document) {
|
|
490
|
+
let doc = document;
|
|
491
|
+
doc = doc.toLowerCase().replaceAll(/[^a-z ]/g, "");
|
|
492
|
+
const padMod = doc.length % this.vectorSize;
|
|
493
|
+
const padGapSize = padMod === 0 ? 0 : this.vectorSize - padMod;
|
|
494
|
+
const padSize = doc.length + padGapSize;
|
|
495
|
+
doc = doc.padEnd(padSize, " ");
|
|
496
|
+
const chunkSize = doc.length / this.vectorSize;
|
|
497
|
+
const docChunk = [];
|
|
498
|
+
for (let co = 0; co < doc.length; co += chunkSize) docChunk.push(doc.slice(co, co + chunkSize));
|
|
499
|
+
const ret = docChunk.map((s) => {
|
|
500
|
+
let sum = 0;
|
|
501
|
+
for (let co = 0; co < s.length; co += 1) sum += s === " " ? 0 : s.charCodeAt(co);
|
|
502
|
+
const ret$1 = sum % 26 / 26;
|
|
503
|
+
return ret$1;
|
|
504
|
+
});
|
|
505
|
+
return ret;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
var SingleRunExtractor = class extends BaseTracer {
|
|
509
|
+
runPromiseResolver;
|
|
510
|
+
runPromise;
|
|
511
|
+
/** The name of the callback handler. */
|
|
512
|
+
name = "single_run_extractor";
|
|
513
|
+
constructor() {
|
|
514
|
+
super();
|
|
515
|
+
this.runPromise = new Promise((extract) => {
|
|
516
|
+
this.runPromiseResolver = extract;
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
async persistRun(run) {
|
|
520
|
+
this.runPromiseResolver(run);
|
|
521
|
+
}
|
|
522
|
+
async extract() {
|
|
523
|
+
return this.runPromise;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
738
526
|
/**
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Static method to create a `FakeVectorStore` instance from an existing
|
|
865
|
-
* index. It creates a new `FakeVectorStore` instance without adding any
|
|
866
|
-
* documents or vectors.
|
|
867
|
-
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
868
|
-
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
869
|
-
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
870
|
-
*/
|
|
871
|
-
static async fromExistingIndex(embeddings, dbConfig) {
|
|
872
|
-
const instance = new this(embeddings, dbConfig);
|
|
873
|
-
return instance;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
527
|
+
* Class that extends `VectorStore` to store vectors in memory. Provides
|
|
528
|
+
* methods for adding documents, performing similarity searches, and
|
|
529
|
+
* creating instances from texts, documents, or an existing index.
|
|
530
|
+
*/
|
|
531
|
+
var FakeVectorStore = class FakeVectorStore extends VectorStore {
|
|
532
|
+
memoryVectors = [];
|
|
533
|
+
similarity;
|
|
534
|
+
_vectorstoreType() {
|
|
535
|
+
return "memory";
|
|
536
|
+
}
|
|
537
|
+
constructor(embeddings, { similarity,...rest } = {}) {
|
|
538
|
+
super(embeddings, rest);
|
|
539
|
+
this.similarity = similarity ?? cosine;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Method to add documents to the memory vector store. It extracts the
|
|
543
|
+
* text from each document, generates embeddings for them, and adds the
|
|
544
|
+
* resulting vectors to the store.
|
|
545
|
+
* @param documents Array of `Document` instances to be added to the store.
|
|
546
|
+
* @returns Promise that resolves when all documents have been added.
|
|
547
|
+
*/
|
|
548
|
+
async addDocuments(documents) {
|
|
549
|
+
const texts = documents.map(({ pageContent }) => pageContent);
|
|
550
|
+
return this.addVectors(await this.embeddings.embedDocuments(texts), documents);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Method to add vectors to the memory vector store. It creates
|
|
554
|
+
* `MemoryVector` instances for each vector and document pair and adds
|
|
555
|
+
* them to the store.
|
|
556
|
+
* @param vectors Array of vectors to be added to the store.
|
|
557
|
+
* @param documents Array of `Document` instances corresponding to the vectors.
|
|
558
|
+
* @returns Promise that resolves when all vectors have been added.
|
|
559
|
+
*/
|
|
560
|
+
async addVectors(vectors, documents) {
|
|
561
|
+
const memoryVectors = vectors.map((embedding, idx) => ({
|
|
562
|
+
content: documents[idx].pageContent,
|
|
563
|
+
embedding,
|
|
564
|
+
metadata: documents[idx].metadata
|
|
565
|
+
}));
|
|
566
|
+
this.memoryVectors = this.memoryVectors.concat(memoryVectors);
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Method to perform a similarity search in the memory vector store. It
|
|
570
|
+
* calculates the similarity between the query vector and each vector in
|
|
571
|
+
* the store, sorts the results by similarity, and returns the top `k`
|
|
572
|
+
* results along with their scores.
|
|
573
|
+
* @param query Query vector to compare against the vectors in the store.
|
|
574
|
+
* @param k Number of top results to return.
|
|
575
|
+
* @param filter Optional filter function to apply to the vectors before performing the search.
|
|
576
|
+
* @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
|
|
577
|
+
*/
|
|
578
|
+
async similaritySearchVectorWithScore(query, k, filter) {
|
|
579
|
+
const filterFunction = (memoryVector) => {
|
|
580
|
+
if (!filter) return true;
|
|
581
|
+
const doc = new Document({
|
|
582
|
+
metadata: memoryVector.metadata,
|
|
583
|
+
pageContent: memoryVector.content
|
|
584
|
+
});
|
|
585
|
+
return filter(doc);
|
|
586
|
+
};
|
|
587
|
+
const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);
|
|
588
|
+
const searches = filteredMemoryVectors.map((vector, index) => ({
|
|
589
|
+
similarity: this.similarity(query, vector.embedding),
|
|
590
|
+
index
|
|
591
|
+
})).sort((a, b) => a.similarity > b.similarity ? -1 : 0).slice(0, k);
|
|
592
|
+
const result = searches.map((search) => [new Document({
|
|
593
|
+
metadata: filteredMemoryVectors[search.index].metadata,
|
|
594
|
+
pageContent: filteredMemoryVectors[search.index].content
|
|
595
|
+
}), search.similarity]);
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
600
|
+
* texts. It creates a `Document` for each text and metadata pair, and
|
|
601
|
+
* adds them to the store.
|
|
602
|
+
* @param texts Array of texts to be added to the store.
|
|
603
|
+
* @param metadatas Array or single object of metadata corresponding to the texts.
|
|
604
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the texts.
|
|
605
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
606
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
607
|
+
*/
|
|
608
|
+
static async fromTexts(texts, metadatas, embeddings, dbConfig) {
|
|
609
|
+
const docs = [];
|
|
610
|
+
for (let i = 0; i < texts.length; i += 1) {
|
|
611
|
+
const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;
|
|
612
|
+
const newDoc = new Document({
|
|
613
|
+
pageContent: texts[i],
|
|
614
|
+
metadata
|
|
615
|
+
});
|
|
616
|
+
docs.push(newDoc);
|
|
617
|
+
}
|
|
618
|
+
return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
622
|
+
* `Document` instances. It adds the documents to the store.
|
|
623
|
+
* @param docs Array of `Document` instances to be added to the store.
|
|
624
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
625
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
626
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
627
|
+
*/
|
|
628
|
+
static async fromDocuments(docs, embeddings, dbConfig) {
|
|
629
|
+
const instance = new this(embeddings, dbConfig);
|
|
630
|
+
await instance.addDocuments(docs);
|
|
631
|
+
return instance;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Static method to create a `FakeVectorStore` instance from an existing
|
|
635
|
+
* index. It creates a new `FakeVectorStore` instance without adding any
|
|
636
|
+
* documents or vectors.
|
|
637
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
638
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
639
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
640
|
+
*/
|
|
641
|
+
static async fromExistingIndex(embeddings, dbConfig) {
|
|
642
|
+
const instance = new this(embeddings, dbConfig);
|
|
643
|
+
return instance;
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
//#endregion
|
|
648
|
+
export { FakeChatMessageHistory, FakeChatModel, FakeEmbeddings, FakeLLM, FakeListChatMessageHistory, FakeListChatModel, FakeRetriever, FakeRunnable, FakeSplitIntoListParser, FakeStreamingChatModel, FakeStreamingLLM, FakeTool, FakeTracer, FakeVectorStore, SingleRunExtractor, SyntheticEmbeddings, testing_exports };
|
|
649
|
+
//# sourceMappingURL=index.js.map
|