@langchain/core 1.0.0-alpha.2 → 1.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (595) hide show
  1. package/README.md +3 -19
  2. package/dist/agents.d.ts.map +1 -1
  3. package/dist/caches/base.cjs +5 -18
  4. package/dist/caches/base.cjs.map +1 -1
  5. package/dist/caches/base.d.cts +4 -20
  6. package/dist/caches/base.d.cts.map +1 -1
  7. package/dist/caches/base.d.ts +4 -20
  8. package/dist/caches/base.d.ts.map +1 -1
  9. package/dist/caches/base.js +5 -18
  10. package/dist/caches/base.js.map +1 -1
  11. package/dist/callbacks/base.d.cts +3 -2
  12. package/dist/callbacks/base.d.cts.map +1 -1
  13. package/dist/callbacks/base.d.ts +3 -2
  14. package/dist/callbacks/base.d.ts.map +1 -1
  15. package/dist/callbacks/manager.d.cts +1 -1
  16. package/dist/callbacks/manager.d.ts +1 -1
  17. package/dist/document_loaders/langsmith.cjs +1 -1
  18. package/dist/document_loaders/langsmith.cjs.map +1 -1
  19. package/dist/document_loaders/langsmith.js +1 -1
  20. package/dist/document_loaders/langsmith.js.map +1 -1
  21. package/dist/embeddings.cjs.map +1 -1
  22. package/dist/embeddings.d.cts +6 -6
  23. package/dist/embeddings.d.cts.map +1 -1
  24. package/dist/embeddings.d.ts +6 -6
  25. package/dist/embeddings.d.ts.map +1 -1
  26. package/dist/embeddings.js.map +1 -1
  27. package/dist/errors/index.cjs.map +1 -1
  28. package/dist/errors/index.js.map +1 -1
  29. package/dist/indexing/base.cjs +2 -2
  30. package/dist/indexing/base.cjs.map +1 -1
  31. package/dist/indexing/base.d.cts +0 -3
  32. package/dist/indexing/base.d.cts.map +1 -1
  33. package/dist/indexing/base.d.ts +0 -3
  34. package/dist/indexing/base.d.ts.map +1 -1
  35. package/dist/indexing/base.js +2 -2
  36. package/dist/indexing/base.js.map +1 -1
  37. package/dist/language_models/base.cjs +1 -1
  38. package/dist/language_models/base.cjs.map +1 -1
  39. package/dist/language_models/base.d.cts +4 -4
  40. package/dist/language_models/base.d.cts.map +1 -1
  41. package/dist/language_models/base.d.ts +4 -4
  42. package/dist/language_models/base.d.ts.map +1 -1
  43. package/dist/language_models/base.js +1 -1
  44. package/dist/language_models/base.js.map +1 -1
  45. package/dist/language_models/chat_models.cjs +1 -0
  46. package/dist/language_models/chat_models.cjs.map +1 -1
  47. package/dist/language_models/chat_models.d.cts +2 -1
  48. package/dist/language_models/chat_models.d.cts.map +1 -1
  49. package/dist/language_models/chat_models.d.ts +2 -1
  50. package/dist/language_models/chat_models.d.ts.map +1 -1
  51. package/dist/language_models/chat_models.js +2 -1
  52. package/dist/language_models/chat_models.js.map +1 -1
  53. package/dist/language_models/llms.cjs.map +1 -1
  54. package/dist/language_models/llms.js.map +1 -1
  55. package/dist/load/import_map.cjs +1 -5
  56. package/dist/load/import_map.cjs.map +1 -1
  57. package/dist/load/import_map.js +3 -7
  58. package/dist/load/import_map.js.map +1 -1
  59. package/dist/load/index.cjs.map +1 -1
  60. package/dist/load/index.js.map +1 -1
  61. package/dist/load/serializable.cjs.map +1 -1
  62. package/dist/load/serializable.d.cts +1 -3
  63. package/dist/load/serializable.d.cts.map +1 -1
  64. package/dist/load/serializable.d.ts +1 -3
  65. package/dist/load/serializable.d.ts.map +1 -1
  66. package/dist/load/serializable.js.map +1 -1
  67. package/dist/messages/ai.cjs +34 -62
  68. package/dist/messages/ai.cjs.map +1 -1
  69. package/dist/messages/ai.d.cts +26 -119
  70. package/dist/messages/ai.d.cts.map +1 -1
  71. package/dist/messages/ai.d.ts +26 -119
  72. package/dist/messages/ai.d.ts.map +1 -1
  73. package/dist/messages/ai.js +34 -62
  74. package/dist/messages/ai.js.map +1 -1
  75. package/dist/messages/base.cjs +53 -33
  76. package/dist/messages/base.cjs.map +1 -1
  77. package/dist/messages/base.d.cts +38 -41
  78. package/dist/messages/base.d.cts.map +1 -1
  79. package/dist/messages/base.d.ts +38 -41
  80. package/dist/messages/base.d.ts.map +1 -1
  81. package/dist/messages/base.js +53 -33
  82. package/dist/messages/base.js.map +1 -1
  83. package/dist/messages/block_translators/utils.cjs +1 -1
  84. package/dist/messages/block_translators/utils.cjs.map +1 -1
  85. package/dist/messages/block_translators/utils.js +1 -1
  86. package/dist/messages/block_translators/utils.js.map +1 -1
  87. package/dist/messages/chat.cjs +18 -12
  88. package/dist/messages/chat.cjs.map +1 -1
  89. package/dist/messages/chat.d.cts +21 -13
  90. package/dist/messages/chat.d.cts.map +1 -1
  91. package/dist/messages/chat.d.ts +21 -13
  92. package/dist/messages/chat.d.ts.map +1 -1
  93. package/dist/messages/chat.js +18 -12
  94. package/dist/messages/chat.js.map +1 -1
  95. package/dist/messages/content/index.cjs.map +1 -1
  96. package/dist/messages/content/index.d.cts +1 -1
  97. package/dist/messages/content/index.d.cts.map +1 -1
  98. package/dist/messages/content/index.d.ts +1 -1
  99. package/dist/messages/content/index.d.ts.map +1 -1
  100. package/dist/messages/content/index.js.map +1 -1
  101. package/dist/messages/function.cjs +8 -13
  102. package/dist/messages/function.cjs.map +1 -1
  103. package/dist/messages/function.d.cts +11 -11
  104. package/dist/messages/function.d.cts.map +1 -1
  105. package/dist/messages/function.d.ts +11 -11
  106. package/dist/messages/function.d.ts.map +1 -1
  107. package/dist/messages/function.js +8 -13
  108. package/dist/messages/function.js.map +1 -1
  109. package/dist/messages/human.cjs +20 -11
  110. package/dist/messages/human.cjs.map +1 -1
  111. package/dist/messages/human.d.cts +20 -15
  112. package/dist/messages/human.d.cts.map +1 -1
  113. package/dist/messages/human.d.ts +20 -15
  114. package/dist/messages/human.d.ts.map +1 -1
  115. package/dist/messages/human.js +20 -11
  116. package/dist/messages/human.js.map +1 -1
  117. package/dist/messages/index.cjs +11 -1
  118. package/dist/messages/index.cjs.map +1 -1
  119. package/dist/messages/index.d.cts +9 -7
  120. package/dist/messages/index.d.ts +9 -7
  121. package/dist/messages/index.js +8 -2
  122. package/dist/messages/index.js.map +1 -1
  123. package/dist/messages/message.cjs +15 -0
  124. package/dist/messages/message.cjs.map +1 -0
  125. package/dist/messages/message.d.cts +598 -0
  126. package/dist/messages/message.d.cts.map +1 -0
  127. package/dist/messages/message.d.ts +598 -0
  128. package/dist/messages/message.d.ts.map +1 -0
  129. package/dist/messages/message.js +14 -0
  130. package/dist/messages/message.js.map +1 -0
  131. package/dist/messages/metadata.cjs +41 -0
  132. package/dist/messages/metadata.cjs.map +1 -0
  133. package/dist/messages/metadata.d.cts +98 -0
  134. package/dist/messages/metadata.d.cts.map +1 -0
  135. package/dist/messages/metadata.d.ts +98 -0
  136. package/dist/messages/metadata.d.ts.map +1 -0
  137. package/dist/messages/metadata.js +40 -0
  138. package/dist/messages/metadata.js.map +1 -0
  139. package/dist/messages/modifier.cjs +5 -4
  140. package/dist/messages/modifier.cjs.map +1 -1
  141. package/dist/messages/modifier.d.cts +7 -5
  142. package/dist/messages/modifier.d.cts.map +1 -1
  143. package/dist/messages/modifier.d.ts +7 -5
  144. package/dist/messages/modifier.d.ts.map +1 -1
  145. package/dist/messages/modifier.js +5 -4
  146. package/dist/messages/modifier.js.map +1 -1
  147. package/dist/messages/system.cjs +20 -11
  148. package/dist/messages/system.cjs.map +1 -1
  149. package/dist/messages/system.d.cts +20 -15
  150. package/dist/messages/system.d.cts.map +1 -1
  151. package/dist/messages/system.d.ts +20 -15
  152. package/dist/messages/system.d.ts.map +1 -1
  153. package/dist/messages/system.js +20 -11
  154. package/dist/messages/system.js.map +1 -1
  155. package/dist/messages/tool.cjs +21 -19
  156. package/dist/messages/tool.cjs.map +1 -1
  157. package/dist/messages/tool.d.cts +72 -46
  158. package/dist/messages/tool.d.cts.map +1 -1
  159. package/dist/messages/tool.d.ts +72 -46
  160. package/dist/messages/tool.d.ts.map +1 -1
  161. package/dist/messages/tool.js +21 -19
  162. package/dist/messages/tool.js.map +1 -1
  163. package/dist/messages/transformers.cjs +2 -2
  164. package/dist/messages/transformers.cjs.map +1 -1
  165. package/dist/messages/transformers.d.cts +2 -1
  166. package/dist/messages/transformers.d.cts.map +1 -1
  167. package/dist/messages/transformers.d.ts +2 -1
  168. package/dist/messages/transformers.d.ts.map +1 -1
  169. package/dist/messages/transformers.js +2 -2
  170. package/dist/messages/transformers.js.map +1 -1
  171. package/dist/messages/utils.cjs +13 -1
  172. package/dist/messages/utils.cjs.map +1 -1
  173. package/dist/messages/utils.d.cts +83 -3
  174. package/dist/messages/utils.d.cts.map +1 -1
  175. package/dist/messages/utils.d.ts +83 -3
  176. package/dist/messages/utils.d.ts.map +1 -1
  177. package/dist/messages/utils.js +13 -2
  178. package/dist/messages/utils.js.map +1 -1
  179. package/dist/output_parsers/list.cjs +1 -1
  180. package/dist/output_parsers/list.cjs.map +1 -1
  181. package/dist/output_parsers/list.js +1 -1
  182. package/dist/output_parsers/list.js.map +1 -1
  183. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
  184. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
  185. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +1 -1
  186. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  187. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +1 -1
  188. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +1 -1
  189. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +1 -1
  190. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  191. package/dist/output_parsers/structured.cjs +2 -1
  192. package/dist/output_parsers/structured.cjs.map +1 -1
  193. package/dist/output_parsers/structured.js +2 -1
  194. package/dist/output_parsers/structured.js.map +1 -1
  195. package/dist/prompt_values.d.cts +4 -3
  196. package/dist/prompt_values.d.cts.map +1 -1
  197. package/dist/prompt_values.d.ts +4 -3
  198. package/dist/prompt_values.d.ts.map +1 -1
  199. package/dist/prompts/chat.cjs +3 -1
  200. package/dist/prompts/chat.cjs.map +1 -1
  201. package/dist/prompts/chat.d.cts +7 -15
  202. package/dist/prompts/chat.d.cts.map +1 -1
  203. package/dist/prompts/chat.d.ts +7 -15
  204. package/dist/prompts/chat.d.ts.map +1 -1
  205. package/dist/prompts/chat.js +3 -1
  206. package/dist/prompts/chat.js.map +1 -1
  207. package/dist/prompts/few_shot.d.cts +1 -1
  208. package/dist/prompts/few_shot.d.ts +1 -1
  209. package/dist/prompts/image.cjs.map +1 -1
  210. package/dist/prompts/image.d.cts +1 -3
  211. package/dist/prompts/image.d.cts.map +1 -1
  212. package/dist/prompts/image.d.ts +1 -3
  213. package/dist/prompts/image.d.ts.map +1 -1
  214. package/dist/prompts/image.js.map +1 -1
  215. package/dist/prompts/pipeline.cjs.map +1 -1
  216. package/dist/prompts/pipeline.js.map +1 -1
  217. package/dist/prompts/prompt.cjs.map +1 -1
  218. package/dist/prompts/prompt.d.cts +5 -17
  219. package/dist/prompts/prompt.d.cts.map +1 -1
  220. package/dist/prompts/prompt.d.ts +5 -17
  221. package/dist/prompts/prompt.d.ts.map +1 -1
  222. package/dist/prompts/prompt.js.map +1 -1
  223. package/dist/prompts/structured.cjs.map +1 -1
  224. package/dist/prompts/structured.js.map +1 -1
  225. package/dist/prompts/template.cjs +4 -2
  226. package/dist/prompts/template.cjs.map +1 -1
  227. package/dist/prompts/template.d.cts +1 -1
  228. package/dist/prompts/template.d.ts +1 -1
  229. package/dist/prompts/template.js +4 -2
  230. package/dist/prompts/template.js.map +1 -1
  231. package/dist/runnables/base.cjs +6 -6
  232. package/dist/runnables/base.cjs.map +1 -1
  233. package/dist/runnables/base.d.cts +1 -4
  234. package/dist/runnables/base.d.cts.map +1 -1
  235. package/dist/runnables/base.d.ts +1 -4
  236. package/dist/runnables/base.d.ts.map +1 -1
  237. package/dist/runnables/base.js +6 -6
  238. package/dist/runnables/base.js.map +1 -1
  239. package/dist/runnables/branch.cjs +2 -2
  240. package/dist/runnables/branch.cjs.map +1 -1
  241. package/dist/runnables/branch.js +2 -2
  242. package/dist/runnables/branch.js.map +1 -1
  243. package/dist/runnables/config.cjs.map +1 -1
  244. package/dist/runnables/config.js.map +1 -1
  245. package/dist/runnables/graph.cjs +1 -1
  246. package/dist/runnables/graph.cjs.map +1 -1
  247. package/dist/runnables/graph.js +1 -1
  248. package/dist/runnables/graph.js.map +1 -1
  249. package/dist/runnables/graph_mermaid.cjs +26 -3
  250. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  251. package/dist/runnables/graph_mermaid.js +26 -3
  252. package/dist/runnables/graph_mermaid.js.map +1 -1
  253. package/dist/runnables/remote.cjs.map +1 -1
  254. package/dist/runnables/remote.js.map +1 -1
  255. package/dist/runnables/types.d.cts +0 -1
  256. package/dist/runnables/types.d.cts.map +1 -1
  257. package/dist/runnables/types.d.ts +0 -1
  258. package/dist/runnables/types.d.ts.map +1 -1
  259. package/dist/singletons/async_local_storage/context.cjs.map +1 -1
  260. package/dist/singletons/async_local_storage/context.d.cts +0 -1
  261. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  262. package/dist/singletons/async_local_storage/context.d.ts +0 -1
  263. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  264. package/dist/singletons/async_local_storage/context.js.map +1 -1
  265. package/dist/singletons/callbacks.cjs.map +1 -1
  266. package/dist/singletons/callbacks.js.map +1 -1
  267. package/dist/tools/index.cjs.map +1 -1
  268. package/dist/tools/index.d.cts +3 -3
  269. package/dist/tools/index.d.cts.map +1 -1
  270. package/dist/tools/index.d.ts +3 -3
  271. package/dist/tools/index.d.ts.map +1 -1
  272. package/dist/tools/index.js.map +1 -1
  273. package/dist/tools/types.d.cts +6 -6
  274. package/dist/tools/types.d.cts.map +1 -1
  275. package/dist/tools/types.d.ts +6 -6
  276. package/dist/tools/types.d.ts.map +1 -1
  277. package/dist/tracers/base.cjs.map +1 -1
  278. package/dist/tracers/base.d.cts +1 -1
  279. package/dist/tracers/base.d.ts +1 -1
  280. package/dist/tracers/base.js.map +1 -1
  281. package/dist/tracers/console.cjs +1 -1
  282. package/dist/tracers/console.cjs.map +1 -1
  283. package/dist/tracers/console.js +1 -1
  284. package/dist/tracers/console.js.map +1 -1
  285. package/dist/tracers/event_stream.cjs +1 -1
  286. package/dist/tracers/event_stream.cjs.map +1 -1
  287. package/dist/tracers/event_stream.d.cts +0 -1
  288. package/dist/tracers/event_stream.d.cts.map +1 -1
  289. package/dist/tracers/event_stream.d.ts +0 -1
  290. package/dist/tracers/event_stream.d.ts.map +1 -1
  291. package/dist/tracers/event_stream.js +1 -1
  292. package/dist/tracers/event_stream.js.map +1 -1
  293. package/dist/tracers/log_stream.cjs.map +1 -1
  294. package/dist/tracers/log_stream.js.map +1 -1
  295. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  296. package/dist/tracers/tracer_langchain.js.map +1 -1
  297. package/dist/tracers/tracer_langchain_v1.d.cts +1 -1
  298. package/dist/tracers/tracer_langchain_v1.d.ts +1 -1
  299. package/dist/utils/chunk_array.cjs.map +1 -1
  300. package/dist/utils/chunk_array.js.map +1 -1
  301. package/dist/utils/env.cjs +1 -1
  302. package/dist/utils/env.cjs.map +1 -1
  303. package/dist/utils/env.js +1 -1
  304. package/dist/utils/env.js.map +1 -1
  305. package/dist/utils/event_source_parse.cjs.map +1 -1
  306. package/dist/utils/event_source_parse.d.cts.map +1 -1
  307. package/dist/utils/event_source_parse.d.ts.map +1 -1
  308. package/dist/utils/event_source_parse.js.map +1 -1
  309. package/dist/utils/hash.cjs +3 -8
  310. package/dist/utils/hash.cjs.map +1 -1
  311. package/dist/utils/hash.d.cts +1 -2
  312. package/dist/utils/hash.d.cts.map +1 -1
  313. package/dist/utils/hash.d.ts +1 -2
  314. package/dist/utils/hash.d.ts.map +1 -1
  315. package/dist/utils/hash.js +2 -6
  316. package/dist/utils/hash.js.map +1 -1
  317. package/dist/utils/js-sha256/hash.cjs +0 -9
  318. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  319. package/dist/utils/js-sha256/hash.js +1 -5
  320. package/dist/utils/js-sha256/hash.js.map +1 -1
  321. package/dist/utils/json.cjs +2 -2
  322. package/dist/utils/json.cjs.map +1 -1
  323. package/dist/utils/json.js +2 -2
  324. package/dist/utils/json.js.map +1 -1
  325. package/dist/utils/json_schema.cjs +3 -2
  326. package/dist/utils/json_schema.cjs.map +1 -1
  327. package/dist/utils/json_schema.d.cts +8 -4
  328. package/dist/utils/json_schema.d.cts.map +1 -1
  329. package/dist/utils/json_schema.d.ts +8 -4
  330. package/dist/utils/json_schema.d.ts.map +1 -1
  331. package/dist/utils/json_schema.js +2 -1
  332. package/dist/utils/json_schema.js.map +1 -1
  333. package/dist/utils/stream.cjs.map +1 -1
  334. package/dist/utils/stream.js.map +1 -1
  335. package/dist/utils/testing/index.cjs.map +1 -1
  336. package/dist/utils/testing/index.d.cts +8 -12
  337. package/dist/utils/testing/index.d.cts.map +1 -1
  338. package/dist/utils/testing/index.d.ts +8 -12
  339. package/dist/utils/testing/index.d.ts.map +1 -1
  340. package/dist/utils/testing/index.js.map +1 -1
  341. package/dist/utils/zod-to-json-schema/Options.cjs +40 -0
  342. package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -0
  343. package/dist/utils/zod-to-json-schema/Options.js +37 -0
  344. package/dist/utils/zod-to-json-schema/Options.js.map +1 -0
  345. package/dist/utils/zod-to-json-schema/Refs.cjs +30 -0
  346. package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -0
  347. package/dist/utils/zod-to-json-schema/Refs.js +30 -0
  348. package/dist/utils/zod-to-json-schema/Refs.js.map +1 -0
  349. package/dist/utils/zod-to-json-schema/errorMessages.cjs +18 -0
  350. package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -0
  351. package/dist/utils/zod-to-json-schema/errorMessages.d.cts +11 -0
  352. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -0
  353. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +11 -0
  354. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -0
  355. package/dist/utils/zod-to-json-schema/errorMessages.js +16 -0
  356. package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -0
  357. package/dist/utils/zod-to-json-schema/getRelativePath.cjs +11 -0
  358. package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -0
  359. package/dist/utils/zod-to-json-schema/getRelativePath.js +10 -0
  360. package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -0
  361. package/dist/utils/zod-to-json-schema/index.cjs +37 -0
  362. package/dist/utils/zod-to-json-schema/index.js +37 -0
  363. package/dist/utils/zod-to-json-schema/parseDef.cjs +57 -0
  364. package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -0
  365. package/dist/utils/zod-to-json-schema/parseDef.js +57 -0
  366. package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -0
  367. package/dist/utils/zod-to-json-schema/parseTypes.d.cts +38 -0
  368. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -0
  369. package/dist/utils/zod-to-json-schema/parseTypes.d.ts +38 -0
  370. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -0
  371. package/dist/utils/zod-to-json-schema/parsers/any.cjs +17 -0
  372. package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -0
  373. package/dist/utils/zod-to-json-schema/parsers/any.d.cts +7 -0
  374. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -0
  375. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +7 -0
  376. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -0
  377. package/dist/utils/zod-to-json-schema/parsers/any.js +17 -0
  378. package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -0
  379. package/dist/utils/zod-to-json-schema/parsers/array.cjs +24 -0
  380. package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -0
  381. package/dist/utils/zod-to-json-schema/parsers/array.d.cts +14 -0
  382. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -0
  383. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +15 -0
  384. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -0
  385. package/dist/utils/zod-to-json-schema/parsers/array.js +23 -0
  386. package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -0
  387. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +36 -0
  388. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -0
  389. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +16 -0
  390. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -0
  391. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +17 -0
  392. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -0
  393. package/dist/utils/zod-to-json-schema/parsers/bigint.js +36 -0
  394. package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -0
  395. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +9 -0
  396. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -0
  397. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts +7 -0
  398. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -0
  399. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts +7 -0
  400. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -0
  401. package/dist/utils/zod-to-json-schema/parsers/boolean.js +8 -0
  402. package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -0
  403. package/dist/utils/zod-to-json-schema/parsers/branded.cjs +10 -0
  404. package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -0
  405. package/dist/utils/zod-to-json-schema/parsers/branded.js +10 -0
  406. package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -0
  407. package/dist/utils/zod-to-json-schema/parsers/catch.cjs +10 -0
  408. package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -0
  409. package/dist/utils/zod-to-json-schema/parsers/catch.js +10 -0
  410. package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -0
  411. package/dist/utils/zod-to-json-schema/parsers/date.cjs +39 -0
  412. package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -0
  413. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +17 -0
  414. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -0
  415. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +17 -0
  416. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -0
  417. package/dist/utils/zod-to-json-schema/parsers/date.js +39 -0
  418. package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -0
  419. package/dist/utils/zod-to-json-schema/parsers/default.cjs +13 -0
  420. package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -0
  421. package/dist/utils/zod-to-json-schema/parsers/default.js +13 -0
  422. package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -0
  423. package/dist/utils/zod-to-json-schema/parsers/effects.cjs +11 -0
  424. package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -0
  425. package/dist/utils/zod-to-json-schema/parsers/effects.js +11 -0
  426. package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -0
  427. package/dist/utils/zod-to-json-schema/parsers/enum.cjs +12 -0
  428. package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -0
  429. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts +8 -0
  430. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -0
  431. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +10 -0
  432. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -0
  433. package/dist/utils/zod-to-json-schema/parsers/enum.js +11 -0
  434. package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -0
  435. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +47 -0
  436. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -0
  437. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +10 -0
  438. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -0
  439. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +11 -0
  440. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -0
  441. package/dist/utils/zod-to-json-schema/parsers/intersection.js +47 -0
  442. package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -0
  443. package/dist/utils/zod-to-json-schema/parsers/literal.cjs +18 -0
  444. package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -0
  445. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +11 -0
  446. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -0
  447. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +12 -0
  448. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -0
  449. package/dist/utils/zod-to-json-schema/parsers/literal.js +17 -0
  450. package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -0
  451. package/dist/utils/zod-to-json-schema/parsers/map.cjs +40 -0
  452. package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -0
  453. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +17 -0
  454. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -0
  455. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +17 -0
  456. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -0
  457. package/dist/utils/zod-to-json-schema/parsers/map.js +40 -0
  458. package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -0
  459. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +18 -0
  460. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -0
  461. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts +8 -0
  462. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -0
  463. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +10 -0
  464. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -0
  465. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +17 -0
  466. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -0
  467. package/dist/utils/zod-to-json-schema/parsers/never.cjs +13 -0
  468. package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -0
  469. package/dist/utils/zod-to-json-schema/parsers/never.d.cts +9 -0
  470. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -0
  471. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +9 -0
  472. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -0
  473. package/dist/utils/zod-to-json-schema/parsers/never.js +13 -0
  474. package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -0
  475. package/dist/utils/zod-to-json-schema/parsers/null.cjs +12 -0
  476. package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -0
  477. package/dist/utils/zod-to-json-schema/parsers/null.d.cts +7 -0
  478. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -0
  479. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +7 -0
  480. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -0
  481. package/dist/utils/zod-to-json-schema/parsers/null.js +11 -0
  482. package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -0
  483. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +46 -0
  484. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -0
  485. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +12 -0
  486. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -0
  487. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +13 -0
  488. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -0
  489. package/dist/utils/zod-to-json-schema/parsers/nullable.js +46 -0
  490. package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -0
  491. package/dist/utils/zod-to-json-schema/parsers/number.cjs +37 -0
  492. package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -0
  493. package/dist/utils/zod-to-json-schema/parsers/number.d.cts +15 -0
  494. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -0
  495. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +16 -0
  496. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -0
  497. package/dist/utils/zod-to-json-schema/parsers/number.js +37 -0
  498. package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -0
  499. package/dist/utils/zod-to-json-schema/parsers/object.cjs +64 -0
  500. package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -0
  501. package/dist/utils/zod-to-json-schema/parsers/object.d.cts +12 -0
  502. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -0
  503. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +13 -0
  504. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -0
  505. package/dist/utils/zod-to-json-schema/parsers/object.js +64 -0
  506. package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -0
  507. package/dist/utils/zod-to-json-schema/parsers/optional.cjs +20 -0
  508. package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -0
  509. package/dist/utils/zod-to-json-schema/parsers/optional.js +20 -0
  510. package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -0
  511. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +28 -0
  512. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -0
  513. package/dist/utils/zod-to-json-schema/parsers/pipeline.js +28 -0
  514. package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -0
  515. package/dist/utils/zod-to-json-schema/parsers/promise.cjs +10 -0
  516. package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -0
  517. package/dist/utils/zod-to-json-schema/parsers/promise.js +10 -0
  518. package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -0
  519. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +10 -0
  520. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -0
  521. package/dist/utils/zod-to-json-schema/parsers/readonly.js +10 -0
  522. package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -0
  523. package/dist/utils/zod-to-json-schema/parsers/record.cjs +57 -0
  524. package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -0
  525. package/dist/utils/zod-to-json-schema/parsers/record.d.cts +14 -0
  526. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -0
  527. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +15 -0
  528. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -0
  529. package/dist/utils/zod-to-json-schema/parsers/record.js +56 -0
  530. package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -0
  531. package/dist/utils/zod-to-json-schema/parsers/set.cjs +22 -0
  532. package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -0
  533. package/dist/utils/zod-to-json-schema/parsers/set.d.cts +15 -0
  534. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -0
  535. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +16 -0
  536. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -0
  537. package/dist/utils/zod-to-json-schema/parsers/set.js +22 -0
  538. package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -0
  539. package/dist/utils/zod-to-json-schema/parsers/string.cjs +255 -0
  540. package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -0
  541. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +28 -0
  542. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -0
  543. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +29 -0
  544. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -0
  545. package/dist/utils/zod-to-json-schema/parsers/string.js +254 -0
  546. package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -0
  547. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +38 -0
  548. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -0
  549. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +15 -0
  550. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -0
  551. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +16 -0
  552. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -0
  553. package/dist/utils/zod-to-json-schema/parsers/tuple.js +38 -0
  554. package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -0
  555. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +10 -0
  556. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -0
  557. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +9 -0
  558. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -0
  559. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +9 -0
  560. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -0
  561. package/dist/utils/zod-to-json-schema/parsers/undefined.js +10 -0
  562. package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -0
  563. package/dist/utils/zod-to-json-schema/parsers/union.cjs +67 -0
  564. package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -0
  565. package/dist/utils/zod-to-json-schema/parsers/union.d.cts +24 -0
  566. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -0
  567. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +25 -0
  568. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -0
  569. package/dist/utils/zod-to-json-schema/parsers/union.js +66 -0
  570. package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -0
  571. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +10 -0
  572. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -0
  573. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +7 -0
  574. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -0
  575. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +7 -0
  576. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -0
  577. package/dist/utils/zod-to-json-schema/parsers/unknown.js +10 -0
  578. package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -0
  579. package/dist/utils/zod-to-json-schema/selectParser.cjs +81 -0
  580. package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -0
  581. package/dist/utils/zod-to-json-schema/selectParser.js +80 -0
  582. package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -0
  583. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +70 -0
  584. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -0
  585. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +70 -0
  586. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -0
  587. package/package.json +7 -36
  588. package/dist/utils/js-sha1/hash.cjs +0 -291
  589. package/dist/utils/js-sha1/hash.cjs.map +0 -1
  590. package/dist/utils/js-sha1/hash.d.cts +0 -9
  591. package/dist/utils/js-sha1/hash.d.cts.map +0 -1
  592. package/dist/utils/js-sha1/hash.d.ts +0 -9
  593. package/dist/utils/js-sha1/hash.d.ts.map +0 -1
  594. package/dist/utils/js-sha1/hash.js +0 -284
  595. package/dist/utils/js-sha1/hash.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 🦜🍎️ @langchain/core
2
2
 
3
- [![CI](https://github.com/langchain-ai/langchainjs/actions/workflows/ci.yml/badge.svg)](https://github.com/langchain-ai/langchainjs/actions/workflows/ci.yml) ![npm](https://img.shields.io/npm/dm/@langchain/core) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
3
+ ![npm](https://img.shields.io/npm/dm/@langchain/core) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
4
4
 
5
5
  `@langchain/core` contains the core abstractions and schemas of LangChain.js, including base classes for language models,
6
6
  chat models, vectorstores, retrievers, and runnables.
@@ -8,7 +8,7 @@ chat models, vectorstores, retrievers, and runnables.
8
8
  ## 💾 Quick Install
9
9
 
10
10
  ```bash
11
- $ pnpm install @langchain/core
11
+ pnpm install @langchain/core
12
12
  ```
13
13
 
14
14
  ## 🤔 What is this?
@@ -21,7 +21,7 @@ The benefit of having these abstractions is that any provider can implement the
21
21
  For example, you can install other provider-specific packages like this:
22
22
 
23
23
  ```bash
24
- $ pnpm install @langchain/openai
24
+ pnpm install @langchain/openai
25
25
  ```
26
26
 
27
27
  And use them as follows:
@@ -72,22 +72,6 @@ leigh
72
72
  Note that for compatibility, all used LangChain packages (including the base LangChain package, which itself depends on core!) must share the same version of `@langchain/core`.
73
73
  This means that you may need to install/resolve a specific version of `@langchain/core` that matches the dependencies of your used packages.
74
74
 
75
- ## 🔗 What is LangChain Expression Language?
76
-
77
- LangChain Core also contains LangChain Expression Language, or LCEL, a runtime that allows users to compose arbitrary sequences together and get several benefits that are important when building LLM applications.
78
- We call these sequences “runnables”.
79
-
80
- All runnables expose the same interface with single-invocation, batch, streaming and async methods.
81
- This design is useful because it is not enough to have a single sync interface when building an LLM application.
82
- Batch is needed for efficient processing of many inputs.
83
- Streaming (and streaming of intermediate steps) is needed to show the user that progress is being made.
84
- Async interfaces are nice when moving into production.
85
- Rather than having to write multiple implementations for all of those, LCEL allows you to write a runnable once and invoke it in many different ways.
86
-
87
- For more check out the [LCEL docs](https://js.langchain.com/docs/concepts/lcel).
88
-
89
- ![LangChain Stack](../docs/core_docs/static/svg/langchain_stack_062024.svg)
90
-
91
75
  ## 📕 Releases & Versioning
92
76
 
93
77
  `@langchain/core` is currently on version `0.3.x`.
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","names":["AgentAction","Record","AgentFinish","AgentStep"],"sources":["../src/agents.d.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toolInput: string | Record<string, any>;\n log: string;\n};\nexport type AgentFinish = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n returnValues: Record<string, any>;\n log: string;\n};\nexport type AgentStep = {\n action: AgentAction;\n observation: string;\n};\n"],"mappings":";KAAYA,WAAAA;EAAAA,IAAAA,EAAAA,MAAAA;EAMAE;EAKAC,SAAAA,EAAAA,MAAS,GARGF,MASZD,CAAAA,MAAAA,EAAW,GAAA,CAAA;;;KANXE,WAAAA;;gBAEMD;;;KAGNE,SAAAA;UACAH"}
1
+ {"version":3,"file":"agents.d.ts","names":["AgentAction","Record","AgentFinish","AgentStep"],"sources":["../src/agents.d.ts"],"sourcesContent":["export type AgentAction = {\n tool: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toolInput: string | Record<string, any>;\n log: string;\n};\nexport type AgentFinish = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n returnValues: Record<string, any>;\n log: string;\n};\nexport type AgentStep = {\n action: AgentAction;\n observation: string;\n};\n"],"mappings":";KAAYA,WAAAA;EAAAA,IAAAA,EAAAA,MAAAA;EAMAE;EAKAC,SAAAA,EAAAA,MAAS,GARGF,MASZD,CAAAA,MAAW,EAAA,GAAA,CAAA;;;KANXE,WAAAA;;gBAEMD;;;KAGNE,SAAAA;UACAH"}
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_utils = require('../messages/utils.cjs');
3
- const require_utils_js_sha1_hash = require('../utils/js-sha1/hash.cjs');
3
+ const require_hash = require('../utils/js-sha256/hash.cjs');
4
4
  require('../utils/hash.cjs');
5
5
 
6
6
  //#region src/caches/base.ts
@@ -8,24 +8,11 @@ var base_exports = {};
8
8
  require_rolldown_runtime.__export(base_exports, {
9
9
  BaseCache: () => BaseCache,
10
10
  InMemoryCache: () => InMemoryCache,
11
+ defaultHashKeyEncoder: () => defaultHashKeyEncoder,
11
12
  deserializeStoredGeneration: () => deserializeStoredGeneration,
12
- getCacheKey: () => getCacheKey,
13
13
  serializeGeneration: () => serializeGeneration
14
14
  });
15
- /**
16
- * This cache key should be consistent across all versions of LangChain.
17
- * It is currently NOT consistent across versions of LangChain.
18
- *
19
- * A huge benefit of having a remote cache (like redis) is that you can
20
- * access the cache from different processes/machines. The allows you to
21
- * separate concerns and scale horizontally.
22
- *
23
- * TODO: Make cache key consistent across versions of LangChain.
24
- *
25
- * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
26
- * This function will be removed in a future version.
27
- */
28
- const getCacheKey = (...strings) => require_utils_js_sha1_hash.insecureHash(strings.join("_"));
15
+ const defaultHashKeyEncoder = (...strings) => require_hash.sha256(strings.join("_"));
29
16
  function deserializeStoredGeneration(storedGeneration) {
30
17
  if (storedGeneration.message !== void 0) return {
31
18
  text: storedGeneration.text,
@@ -42,7 +29,7 @@ function serializeGeneration(generation) {
42
29
  * Base class for all caches. All caches should extend this class.
43
30
  */
44
31
  var BaseCache = class {
45
- keyEncoder = getCacheKey;
32
+ keyEncoder = defaultHashKeyEncoder;
46
33
  /**
47
34
  * Sets a custom key encoder function for the cache.
48
35
  * This function should take a prompt and an LLM key and return a string
@@ -101,7 +88,7 @@ Object.defineProperty(exports, 'base_exports', {
101
88
  return base_exports;
102
89
  }
103
90
  });
91
+ exports.defaultHashKeyEncoder = defaultHashKeyEncoder;
104
92
  exports.deserializeStoredGeneration = deserializeStoredGeneration;
105
- exports.getCacheKey = getCacheKey;
106
93
  exports.serializeGeneration = serializeGeneration;
107
94
  //# sourceMappingURL=base.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.cjs","names":["getCacheKey: HashKeyEncoder","insecureHash","storedGeneration: StoredGeneration","mapStoredMessageToChatMessage","generation: Generation","serializedValue: StoredGeneration","keyEncoderFn: HashKeyEncoder","map?: Map<string, T>","prompt: string","llmKey: string","value: T"],"sources":["../../src/caches/base.ts"],"sourcesContent":["import { insecureHash, type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { mapStoredMessageToChatMessage } from \"../messages/utils.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n\n/**\n * This cache key should be consistent across all versions of LangChain.\n * It is currently NOT consistent across versions of LangChain.\n *\n * A huge benefit of having a remote cache (like redis) is that you can\n * access the cache from different processes/machines. The allows you to\n * separate concerns and scale horizontally.\n *\n * TODO: Make cache key consistent across versions of LangChain.\n *\n * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.\n * This function will be removed in a future version.\n */\nexport const getCacheKey: HashKeyEncoder = (...strings) =>\n insecureHash(strings.join(\"_\"));\n\nexport function deserializeStoredGeneration(\n storedGeneration: StoredGeneration\n) {\n if (storedGeneration.message !== undefined) {\n return {\n text: storedGeneration.text,\n message: mapStoredMessageToChatMessage(storedGeneration.message),\n };\n } else {\n return { text: storedGeneration.text };\n }\n}\n\nexport function serializeGeneration(generation: Generation) {\n const serializedValue: StoredGeneration = {\n text: generation.text,\n };\n if ((generation as ChatGeneration).message !== undefined) {\n serializedValue.message = (generation as ChatGeneration).message.toDict();\n }\n return serializedValue;\n}\n\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport abstract class BaseCache<T = Generation[]> {\n // For backwards compatibility, we use a default key encoder\n // that uses SHA-1 to hash the prompt and LLM key. This will also print a warning\n // about the security implications of using SHA-1 as a cache key.\n protected keyEncoder: HashKeyEncoder = getCacheKey;\n\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void {\n this.keyEncoder = keyEncoderFn;\n }\n\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n\nconst GLOBAL_MAP = new Map();\n\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache: Map<string, T>;\n\n constructor(map?: Map<string, T>) {\n super();\n this.cache = map ?? new Map();\n }\n\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null> {\n return Promise.resolve(\n this.cache.get(this.keyEncoder(prompt, llmKey)) ?? null\n );\n }\n\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n async update(prompt: string, llmKey: string, value: T): Promise<void> {\n this.cache.set(this.keyEncoder(prompt, llmKey), value);\n }\n\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache {\n return new InMemoryCache(GLOBAL_MAP);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAaA,cAA8B,CAAC,GAAG,YAC7CC,wCAAa,QAAQ,KAAK,IAAI,CAAC;AAEjC,SAAgB,4BACdC,kBACA;AACA,KAAI,iBAAiB,YAAY,OAC/B,QAAO;EACL,MAAM,iBAAiB;EACvB,SAASC,4CAA8B,iBAAiB,QAAQ;CACjE;KAED,QAAO,EAAE,MAAM,iBAAiB,KAAM;AAEzC;AAED,SAAgB,oBAAoBC,YAAwB;CAC1D,MAAMC,kBAAoC,EACxC,MAAM,WAAW,KAClB;AACD,KAAK,WAA8B,YAAY,QAC7C,gBAAgB,UAAW,WAA8B,QAAQ,QAAQ;AAE3E,QAAO;AACR;;;;AAKD,IAAsB,YAAtB,MAAkD;CAIhD,AAAU,aAA6B;;;;;;;CAQvC,sBAAsBC,cAAoC;EACxD,KAAK,aAAa;CACnB;AAKF;AAED,MAAM,6BAAa,IAAI;;;;AAKvB,IAAa,gBAAb,MAAa,sBAAwC,UAAa;CAChE,AAAQ;CAER,YAAYC,KAAsB;EAChC,OAAO;EACP,KAAK,QAAQ,uBAAO,IAAI;CACzB;;;;;;;;CASD,OAAOC,QAAgBC,QAAmC;AACxD,SAAO,QAAQ,QACb,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC,IAAI,KACpD;CACF;;;;;;;CAQD,MAAM,OAAOD,QAAgBC,QAAgBC,OAAyB;EACpE,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,EAAE,MAAM;CACvD;;;;;;CAOD,OAAO,SAAwB;AAC7B,SAAO,IAAI,cAAc;CAC1B;AACF"}
1
+ {"version":3,"file":"base.cjs","names":["defaultHashKeyEncoder: HashKeyEncoder","sha256","storedGeneration: StoredGeneration","mapStoredMessageToChatMessage","generation: Generation","serializedValue: StoredGeneration","keyEncoderFn: HashKeyEncoder","map?: Map<string, T>","prompt: string","llmKey: string","value: T"],"sources":["../../src/caches/base.ts"],"sourcesContent":["import { sha256, type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { mapStoredMessageToChatMessage } from \"../messages/utils.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n\nexport const defaultHashKeyEncoder: HashKeyEncoder = (...strings) =>\n sha256(strings.join(\"_\"));\n\nexport function deserializeStoredGeneration(\n storedGeneration: StoredGeneration\n) {\n if (storedGeneration.message !== undefined) {\n return {\n text: storedGeneration.text,\n message: mapStoredMessageToChatMessage(storedGeneration.message),\n };\n } else {\n return { text: storedGeneration.text };\n }\n}\n\nexport function serializeGeneration(generation: Generation) {\n const serializedValue: StoredGeneration = {\n text: generation.text,\n };\n if ((generation as ChatGeneration).message !== undefined) {\n serializedValue.message = (generation as ChatGeneration).message.toDict();\n }\n return serializedValue;\n}\n\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder = defaultHashKeyEncoder;\n\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void {\n this.keyEncoder = keyEncoderFn;\n }\n\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n\nconst GLOBAL_MAP = new Map();\n\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache: Map<string, T>;\n\n constructor(map?: Map<string, T>) {\n super();\n this.cache = map ?? new Map();\n }\n\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null> {\n return Promise.resolve(\n this.cache.get(this.keyEncoder(prompt, llmKey)) ?? null\n );\n }\n\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n async update(prompt: string, llmKey: string, value: T): Promise<void> {\n this.cache.set(this.keyEncoder(prompt, llmKey), value);\n }\n\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache {\n return new InMemoryCache(GLOBAL_MAP);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAaA,wBAAwC,CAAC,GAAG,YACvDC,oBAAO,QAAQ,KAAK,IAAI,CAAC;AAE3B,SAAgB,4BACdC,kBACA;AACA,KAAI,iBAAiB,YAAY,OAC/B,QAAO;EACL,MAAM,iBAAiB;EACvB,SAASC,4CAA8B,iBAAiB,QAAQ;CACjE;KAED,QAAO,EAAE,MAAM,iBAAiB,KAAM;AAEzC;AAED,SAAgB,oBAAoBC,YAAwB;CAC1D,MAAMC,kBAAoC,EACxC,MAAM,WAAW,KAClB;AACD,KAAK,WAA8B,YAAY,QAC7C,gBAAgB,UAAW,WAA8B,QAAQ,QAAQ;AAE3E,QAAO;AACR;;;;AAKD,IAAsB,YAAtB,MAAkD;CAChD,AAAU,aAA6B;;;;;;;CAQvC,sBAAsBC,cAAoC;EACxD,KAAK,aAAa;CACnB;AAKF;AAED,MAAM,6BAAa,IAAI;;;;AAKvB,IAAa,gBAAb,MAAa,sBAAwC,UAAa;CAChE,AAAQ;CAER,YAAYC,KAAsB;EAChC,OAAO;EACP,KAAK,QAAQ,uBAAO,IAAI;CACzB;;;;;;;;CASD,OAAOC,QAAgBC,QAAmC;AACxD,SAAO,QAAQ,QACb,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC,IAAI,KACpD;CACF;;;;;;;CAQD,MAAM,OAAOD,QAAgBC,QAAgBC,OAAyB;EACpE,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,EAAE,MAAM;CACvD;;;;;;CAOD,OAAO,SAAwB;AAC7B,SAAO,IAAI,cAAc;CAC1B;AACF"}
@@ -5,28 +5,15 @@ import { ChatMessage } from "../messages/chat.cjs";
5
5
  import { FunctionMessage } from "../messages/function.cjs";
6
6
  import { HumanMessage } from "../messages/human.cjs";
7
7
  import { SystemMessage } from "../messages/system.cjs";
8
+ import { MessageStructure } from "../messages/message.cjs";
8
9
  import { HashKeyEncoder } from "../utils/hash.cjs";
9
10
  import { Generation } from "../outputs.cjs";
10
11
 
11
12
  //#region src/caches/base.d.ts
12
-
13
- /**
14
- * This cache key should be consistent across all versions of LangChain.
15
- * It is currently NOT consistent across versions of LangChain.
16
- *
17
- * A huge benefit of having a remote cache (like redis) is that you can
18
- * access the cache from different processes/machines. The allows you to
19
- * separate concerns and scale horizontally.
20
- *
21
- * TODO: Make cache key consistent across versions of LangChain.
22
- *
23
- * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
24
- * This function will be removed in a future version.
25
- */
26
- declare const getCacheKey: HashKeyEncoder;
13
+ declare const defaultHashKeyEncoder: HashKeyEncoder;
27
14
  declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {
28
15
  text: string;
29
- message: AIMessage | ChatMessage | FunctionMessage | HumanMessage | SystemMessage | ToolMessage;
16
+ message: AIMessage<MessageStructure> | ChatMessage<MessageStructure> | FunctionMessage<MessageStructure> | HumanMessage<MessageStructure> | SystemMessage<MessageStructure> | ToolMessage<MessageStructure>;
30
17
  } | {
31
18
  message?: undefined;
32
19
  text: string;
@@ -36,9 +23,6 @@ declare function serializeGeneration(generation: Generation): StoredGeneration;
36
23
  * Base class for all caches. All caches should extend this class.
37
24
  */
38
25
  declare abstract class BaseCache<T = Generation[]> {
39
- // For backwards compatibility, we use a default key encoder
40
- // that uses SHA-1 to hash the prompt and LLM key. This will also print a warning
41
- // about the security implications of using SHA-1 as a cache key.
42
26
  protected keyEncoder: HashKeyEncoder;
43
27
  /**
44
28
  * Sets a custom key encoder function for the cache.
@@ -79,5 +63,5 @@ declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {
79
63
  static global(): InMemoryCache;
80
64
  }
81
65
  //#endregion
82
- export { BaseCache, InMemoryCache, deserializeStoredGeneration, getCacheKey, serializeGeneration };
66
+ export { BaseCache, InMemoryCache, defaultHashKeyEncoder, deserializeStoredGeneration, serializeGeneration };
83
67
  //# sourceMappingURL=base.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.cts","names":["___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","getCacheKey","deserializeStoredGeneration","___messages_ai_js0","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n/**\n * This cache key should be consistent across all versions of LangChain.\n * It is currently NOT consistent across versions of LangChain.\n *\n * A huge benefit of having a remote cache (like redis) is that you can\n * access the cache from different processes/machines. The allows you to\n * separate concerns and scale horizontally.\n *\n * TODO: Make cache key consistent across versions of LangChain.\n *\n * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.\n * This function will be removed in a future version.\n */\nexport declare const getCacheKey: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage | import(\"../messages/chat.js\").ChatMessage | import(\"../messages/function.js\").FunctionMessage | import(\"../messages/human.js\").HumanMessage | import(\"../messages/system.js\").SystemMessage | import(\"../messages/tool.js\").ToolMessage;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n // For backwards compatibility, we use a default key encoder\n // that uses SHA-1 to hash the prompt and LLM key. This will also print a warning\n // about the security implications of using SHA-1 as a cache key.\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBA;AACA;;;;AAEkD,cAH7BQ,WAG6B,EAHhBH,cAGgB;AAA4C,iBAFtEI,2BAAAA,CAEsE,gBAAA,EAFxBF,gBAEwB,CAAA,EAAA;EAAoD,IAAA,EAAA,MAAA;EAA8C,OAAA,EAF1G,SAAA,GAEpC,WAAA,GAA4C,eAAA,GAAoD,YAAA,GAA8C,aAAA,GAAgD,WAAhD;CAAgD,GAAA;EAA4C,OAAA,CAAA,EAAA,SAAA;EAKpQU,IAAAA,EAAAA,MAAAA;CAAmB;AAAaX,iBAAhCW,mBAAAA,CAAgCX,UAAAA,EAAAA,UAAAA,CAAAA,EAAaC,gBAAbD;;AAA6B;AAIrF;AAAuC,uBAATY,SAAS,CAAA,IAAKZ,UAAL,EAAA,CAAA,CAAA;EAAA;EAAe;EAId;EAOc,UACOa,UAAAA,EARnCd,cAQmCc;EAAC;;;AACQ;AAKtE;;EAAkC,qBAAKb,CAAAA,YAAAA,EAPCD,cAODC,CAAAA,EAAAA,IAAAA;EAAU,SAAsBa,MAAAA,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EANlBC,OAMkBD,CANVA,CAMUA,GAAAA,IAAAA,CAAAA;EAAC,SAEtCA,MAAAA,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAPyBA,CAOzBA,CAAAA,EAP6BC,OAO7BD,CAAAA,IAAAA,CAAAA;;;;;AAeoBC,cAjBjCC,aAiBiCD,CAAAA,IAjBfd,UAiBec,EAAAA,CAAAA,SAjBOF,SAiBPE,CAjBiBD,CAiBjBC,CAAAA,CAAAA;EAAO,QAMxCC,KAAAA;EAAa,WAvB2BH,CAAAA,GAAAA,CAAAA,EAEvCI,GAFuCJ,CAAAA,MAAAA,EAE3BC,CAF2BD,CAAAA;EAAS;;;;;;;0CAU1BE,QAAQD;;;;;;;gDAOFA,IAAIC;;;;;;mBAMjCC"}
1
+ {"version":3,"file":"base.d.cts","names":["___messages_ai_js0","___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","defaultHashKeyEncoder","deserializeStoredGeneration","___messages_message_js0","MessageStructure","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\nexport declare const defaultHashKeyEncoder: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/chat.js\").ChatMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/function.js\").FunctionMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/human.js\").HumanMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/system.js\").SystemMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/tool.js\").ToolMessage<import(\"../messages/message.js\").MessageStructure>;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n"],"mappings":";;;;;;;;;;;;cAGqBS,uBAAuBH;iBACpBI,2BAAAA,mBAA8CF;;WAE8B,UAFd,gBAAA,IAE6G,YAAjJ,gBAAA,IAAwP,gBAAzJ,gBAAA,IAA0P,aAAnJ,gBAAA,IAAsP,cAArJ,gBAAA,IAAoP,YAAjJ,gBAAA;;;;;iBAKpaW,mBAAAA,aAAgCZ,aAAaC;AARrE;AACA;;AAAsEA,uBAWxCY,SAXwCZ,CAAAA,IAW1BD,UAX0BC,EAAAA,CAAAA,CAAAA;EAAgB,UAAA,UAAA,EAY5DF,cAZ4D;EAEc;;;;;;EAAuS,qBAAA,CAAA,YAAA,EAiBnWA,cAjBmW,CAAA,EAAA,IAAA;EAAlD,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAkBpSgB,OAlBoS,CAkB5RD,CAlB4R,GAAA,IAAA,CAAA;EAAqJ,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAmBnbA,CAnBmb,CAAA,EAmB/aC,OAnB+a,CAAA,IAAA,CAAA;;;AAA6C;AAK3hB;AAA2C,cAmBtBC,aAnBsB,CAAA,IAmBJhB,UAnBI,EAAA,CAAA,SAmBkBa,SAnBlB,CAmB4BC,CAnB5B,CAAA,CAAA;EAAA,QAAad,KAAAA;EAAU,WAAGC,CAAAA,GAAAA,CAAAA,EAqB/CgB,GArB+ChB,CAAAA,MAAAA,EAqBnCa,CArBmCb,CAAAA;EAAgB;AAIrF;;;;;;EAS8D,MAATc,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAgBTA,OAhBSA,CAgBDD,CAhBCC,GAAAA,IAAAA,CAAAA;EAAO;;AACU;AAKtE;;;EAAiD,MAAsBD,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAiBrBA,CAjBqBA,CAAAA,EAiBjBC,OAjBiBD,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAiBrB,OAAGC,MAAAA,CAAAA,CAAAA,EAMjCC,aANiCD"}
@@ -5,28 +5,15 @@ import { ChatMessage } from "../messages/chat.js";
5
5
  import { FunctionMessage } from "../messages/function.js";
6
6
  import { HumanMessage } from "../messages/human.js";
7
7
  import { SystemMessage } from "../messages/system.js";
8
+ import { MessageStructure } from "../messages/message.js";
8
9
  import { HashKeyEncoder } from "../utils/hash.js";
9
10
  import { Generation } from "../outputs.js";
10
11
 
11
12
  //#region src/caches/base.d.ts
12
-
13
- /**
14
- * This cache key should be consistent across all versions of LangChain.
15
- * It is currently NOT consistent across versions of LangChain.
16
- *
17
- * A huge benefit of having a remote cache (like redis) is that you can
18
- * access the cache from different processes/machines. The allows you to
19
- * separate concerns and scale horizontally.
20
- *
21
- * TODO: Make cache key consistent across versions of LangChain.
22
- *
23
- * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
24
- * This function will be removed in a future version.
25
- */
26
- declare const getCacheKey: HashKeyEncoder;
13
+ declare const defaultHashKeyEncoder: HashKeyEncoder;
27
14
  declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {
28
15
  text: string;
29
- message: AIMessage | ChatMessage | FunctionMessage | HumanMessage | SystemMessage | ToolMessage;
16
+ message: AIMessage<MessageStructure> | ChatMessage<MessageStructure> | FunctionMessage<MessageStructure> | HumanMessage<MessageStructure> | SystemMessage<MessageStructure> | ToolMessage<MessageStructure>;
30
17
  } | {
31
18
  message?: undefined;
32
19
  text: string;
@@ -36,9 +23,6 @@ declare function serializeGeneration(generation: Generation): StoredGeneration;
36
23
  * Base class for all caches. All caches should extend this class.
37
24
  */
38
25
  declare abstract class BaseCache<T = Generation[]> {
39
- // For backwards compatibility, we use a default key encoder
40
- // that uses SHA-1 to hash the prompt and LLM key. This will also print a warning
41
- // about the security implications of using SHA-1 as a cache key.
42
26
  protected keyEncoder: HashKeyEncoder;
43
27
  /**
44
28
  * Sets a custom key encoder function for the cache.
@@ -79,5 +63,5 @@ declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {
79
63
  static global(): InMemoryCache;
80
64
  }
81
65
  //#endregion
82
- export { BaseCache, InMemoryCache, deserializeStoredGeneration, getCacheKey, serializeGeneration };
66
+ export { BaseCache, InMemoryCache, defaultHashKeyEncoder, deserializeStoredGeneration, serializeGeneration };
83
67
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","names":["___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","getCacheKey","deserializeStoredGeneration","___messages_ai_js0","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n/**\n * This cache key should be consistent across all versions of LangChain.\n * It is currently NOT consistent across versions of LangChain.\n *\n * A huge benefit of having a remote cache (like redis) is that you can\n * access the cache from different processes/machines. The allows you to\n * separate concerns and scale horizontally.\n *\n * TODO: Make cache key consistent across versions of LangChain.\n *\n * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.\n * This function will be removed in a future version.\n */\nexport declare const getCacheKey: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage | import(\"../messages/chat.js\").ChatMessage | import(\"../messages/function.js\").FunctionMessage | import(\"../messages/human.js\").HumanMessage | import(\"../messages/system.js\").SystemMessage | import(\"../messages/tool.js\").ToolMessage;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n // For backwards compatibility, we use a default key encoder\n // that uses SHA-1 to hash the prompt and LLM key. This will also print a warning\n // about the security implications of using SHA-1 as a cache key.\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBA;AACA;;;;AAEkD,cAH7BQ,WAG6B,EAHhBH,cAGgB;AAA4C,iBAFtEI,2BAAAA,CAEsE,gBAAA,EAFxBF,gBAEwB,CAAA,EAAA;EAAoD,IAAA,EAAA,MAAA;EAA8C,OAAA,EAF1G,SAAA,GAEpC,WAAA,GAA4C,eAAA,GAAoD,YAAA,GAA8C,aAAA,GAAgD,WAAhD;CAAgD,GAAA;EAA4C,OAAA,CAAA,EAAA,SAAA;EAKpQU,IAAAA,EAAAA,MAAAA;CAAmB;AAAaX,iBAAhCW,mBAAAA,CAAgCX,UAAAA,EAAAA,UAAAA,CAAAA,EAAaC,gBAAbD;;AAA6B;AAIrF;AAAuC,uBAATY,SAAS,CAAA,IAAKZ,UAAL,EAAA,CAAA,CAAA;EAAA;EAAe;EAId;EAOc,UACOa,UAAAA,EARnCd,cAQmCc;EAAC;;;AACQ;AAKtE;;EAAkC,qBAAKb,CAAAA,YAAAA,EAPCD,cAODC,CAAAA,EAAAA,IAAAA;EAAU,SAAsBa,MAAAA,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EANlBC,OAMkBD,CANVA,CAMUA,GAAAA,IAAAA,CAAAA;EAAC,SAEtCA,MAAAA,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAPyBA,CAOzBA,CAAAA,EAP6BC,OAO7BD,CAAAA,IAAAA,CAAAA;;;;;AAeoBC,cAjBjCC,aAiBiCD,CAAAA,IAjBfd,UAiBec,EAAAA,CAAAA,SAjBOF,SAiBPE,CAjBiBD,CAiBjBC,CAAAA,CAAAA;EAAO,QAMxCC,KAAAA;EAAa,WAvB2BH,CAAAA,GAAAA,CAAAA,EAEvCI,GAFuCJ,CAAAA,MAAAA,EAE3BC,CAF2BD,CAAAA;EAAS;;;;;;;0CAU1BE,QAAQD;;;;;;;gDAOFA,IAAIC;;;;;;mBAMjCC"}
1
+ {"version":3,"file":"base.d.ts","names":["___messages_ai_js0","___messages_chat_js0","___messages_function_js0","___messages_human_js0","___messages_system_js0","___messages_tool_js0","HashKeyEncoder","Generation","StoredGeneration","defaultHashKeyEncoder","deserializeStoredGeneration","___messages_message_js0","MessageStructure","AIMessage","ChatMessage","FunctionMessage","HumanMessage","SystemMessage","ToolMessage","serializeGeneration","BaseCache","T","Promise","InMemoryCache","Map"],"sources":["../../src/caches/base.d.ts"],"sourcesContent":["import { type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation } from \"../outputs.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\nexport declare const defaultHashKeyEncoder: HashKeyEncoder;\nexport declare function deserializeStoredGeneration(storedGeneration: StoredGeneration): {\n text: string;\n message: import(\"../messages/ai.js\").AIMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/chat.js\").ChatMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/function.js\").FunctionMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/human.js\").HumanMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/system.js\").SystemMessage<import(\"../messages/message.js\").MessageStructure> | import(\"../messages/tool.js\").ToolMessage<import(\"../messages/message.js\").MessageStructure>;\n} | {\n message?: undefined;\n text: string;\n};\nexport declare function serializeGeneration(generation: Generation): StoredGeneration;\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport declare abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder;\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void;\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport declare class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache;\n constructor(map?: Map<string, T>);\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null>;\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n update(prompt: string, llmKey: string, value: T): Promise<void>;\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache;\n}\n"],"mappings":";;;;;;;;;;;;cAGqBS,uBAAuBH;iBACpBI,2BAAAA,mBAA8CF;;WAE8B,UAFd,gBAAA,IAE6G,YAAjJ,gBAAA,IAAwP,gBAAzJ,gBAAA,IAA0P,aAAnJ,gBAAA,IAAsP,cAArJ,gBAAA,IAAoP,YAAjJ,gBAAA;;;;;iBAKpaW,mBAAAA,aAAgCZ,aAAaC;AARrE;AACA;;AAAsEA,uBAWxCY,SAXwCZ,CAAAA,IAW1BD,UAX0BC,EAAAA,CAAAA,CAAAA;EAAgB,UAAA,UAAA,EAY5DF,cAZ4D;EAEc;;;;;;EAAuS,qBAAA,CAAA,YAAA,EAiBnWA,cAjBmW,CAAA,EAAA,IAAA;EAAlD,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAkBpSgB,OAlBoS,CAkB5RD,CAlB4R,GAAA,IAAA,CAAA;EAAqJ,SAAA,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,KAAA,EAmBnbA,CAnBmb,CAAA,EAmB/aC,OAnB+a,CAAA,IAAA,CAAA;;;AAA6C;AAK3hB;AAA2C,cAmBtBC,aAnBsB,CAAA,IAmBJhB,UAnBI,EAAA,CAAA,SAmBkBa,SAnBlB,CAmB4BC,CAnB5B,CAAA,CAAA;EAAA,QAAad,KAAAA;EAAU,WAAGC,CAAAA,GAAAA,CAAAA,EAqB/CgB,GArB+ChB,CAAAA,MAAAA,EAqBnCa,CArBmCb,CAAAA;EAAgB;AAIrF;;;;;;EAS8D,MAATc,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAgBTA,OAhBSA,CAgBDD,CAhBCC,GAAAA,IAAAA,CAAAA;EAAO;;AACU;AAKtE;;;EAAiD,MAAsBD,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,KAAAA,EAiBrBA,CAjBqBA,CAAAA,EAiBjBC,OAjBiBD,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAiBrB,OAAGC,MAAAA,CAAAA,CAAAA,EAMjCC,aANiCD"}
@@ -1,6 +1,6 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.js";
2
2
  import { mapStoredMessageToChatMessage } from "../messages/utils.js";
3
- import { insecureHash } from "../utils/js-sha1/hash.js";
3
+ import { sha256 } from "../utils/js-sha256/hash.js";
4
4
  import "../utils/hash.js";
5
5
 
6
6
  //#region src/caches/base.ts
@@ -8,24 +8,11 @@ var base_exports = {};
8
8
  __export(base_exports, {
9
9
  BaseCache: () => BaseCache,
10
10
  InMemoryCache: () => InMemoryCache,
11
+ defaultHashKeyEncoder: () => defaultHashKeyEncoder,
11
12
  deserializeStoredGeneration: () => deserializeStoredGeneration,
12
- getCacheKey: () => getCacheKey,
13
13
  serializeGeneration: () => serializeGeneration
14
14
  });
15
- /**
16
- * This cache key should be consistent across all versions of LangChain.
17
- * It is currently NOT consistent across versions of LangChain.
18
- *
19
- * A huge benefit of having a remote cache (like redis) is that you can
20
- * access the cache from different processes/machines. The allows you to
21
- * separate concerns and scale horizontally.
22
- *
23
- * TODO: Make cache key consistent across versions of LangChain.
24
- *
25
- * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
26
- * This function will be removed in a future version.
27
- */
28
- const getCacheKey = (...strings) => insecureHash(strings.join("_"));
15
+ const defaultHashKeyEncoder = (...strings) => sha256(strings.join("_"));
29
16
  function deserializeStoredGeneration(storedGeneration) {
30
17
  if (storedGeneration.message !== void 0) return {
31
18
  text: storedGeneration.text,
@@ -42,7 +29,7 @@ function serializeGeneration(generation) {
42
29
  * Base class for all caches. All caches should extend this class.
43
30
  */
44
31
  var BaseCache = class {
45
- keyEncoder = getCacheKey;
32
+ keyEncoder = defaultHashKeyEncoder;
46
33
  /**
47
34
  * Sets a custom key encoder function for the cache.
48
35
  * This function should take a prompt and an LLM key and return a string
@@ -93,5 +80,5 @@ var InMemoryCache = class InMemoryCache extends BaseCache {
93
80
  };
94
81
 
95
82
  //#endregion
96
- export { BaseCache, InMemoryCache, base_exports, deserializeStoredGeneration, getCacheKey, serializeGeneration };
83
+ export { BaseCache, InMemoryCache, base_exports, defaultHashKeyEncoder, deserializeStoredGeneration, serializeGeneration };
97
84
  //# sourceMappingURL=base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["getCacheKey: HashKeyEncoder","storedGeneration: StoredGeneration","generation: Generation","serializedValue: StoredGeneration","keyEncoderFn: HashKeyEncoder","map?: Map<string, T>","prompt: string","llmKey: string","value: T"],"sources":["../../src/caches/base.ts"],"sourcesContent":["import { insecureHash, type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { mapStoredMessageToChatMessage } from \"../messages/utils.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n\n/**\n * This cache key should be consistent across all versions of LangChain.\n * It is currently NOT consistent across versions of LangChain.\n *\n * A huge benefit of having a remote cache (like redis) is that you can\n * access the cache from different processes/machines. The allows you to\n * separate concerns and scale horizontally.\n *\n * TODO: Make cache key consistent across versions of LangChain.\n *\n * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.\n * This function will be removed in a future version.\n */\nexport const getCacheKey: HashKeyEncoder = (...strings) =>\n insecureHash(strings.join(\"_\"));\n\nexport function deserializeStoredGeneration(\n storedGeneration: StoredGeneration\n) {\n if (storedGeneration.message !== undefined) {\n return {\n text: storedGeneration.text,\n message: mapStoredMessageToChatMessage(storedGeneration.message),\n };\n } else {\n return { text: storedGeneration.text };\n }\n}\n\nexport function serializeGeneration(generation: Generation) {\n const serializedValue: StoredGeneration = {\n text: generation.text,\n };\n if ((generation as ChatGeneration).message !== undefined) {\n serializedValue.message = (generation as ChatGeneration).message.toDict();\n }\n return serializedValue;\n}\n\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport abstract class BaseCache<T = Generation[]> {\n // For backwards compatibility, we use a default key encoder\n // that uses SHA-1 to hash the prompt and LLM key. This will also print a warning\n // about the security implications of using SHA-1 as a cache key.\n protected keyEncoder: HashKeyEncoder = getCacheKey;\n\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void {\n this.keyEncoder = keyEncoderFn;\n }\n\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n\nconst GLOBAL_MAP = new Map();\n\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache: Map<string, T>;\n\n constructor(map?: Map<string, T>) {\n super();\n this.cache = map ?? new Map();\n }\n\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null> {\n return Promise.resolve(\n this.cache.get(this.keyEncoder(prompt, llmKey)) ?? null\n );\n }\n\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n async update(prompt: string, llmKey: string, value: T): Promise<void> {\n this.cache.set(this.keyEncoder(prompt, llmKey), value);\n }\n\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache {\n return new InMemoryCache(GLOBAL_MAP);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAaA,cAA8B,CAAC,GAAG,YAC7C,aAAa,QAAQ,KAAK,IAAI,CAAC;AAEjC,SAAgB,4BACdC,kBACA;AACA,KAAI,iBAAiB,YAAY,OAC/B,QAAO;EACL,MAAM,iBAAiB;EACvB,SAAS,8BAA8B,iBAAiB,QAAQ;CACjE;KAED,QAAO,EAAE,MAAM,iBAAiB,KAAM;AAEzC;AAED,SAAgB,oBAAoBC,YAAwB;CAC1D,MAAMC,kBAAoC,EACxC,MAAM,WAAW,KAClB;AACD,KAAK,WAA8B,YAAY,QAC7C,gBAAgB,UAAW,WAA8B,QAAQ,QAAQ;AAE3E,QAAO;AACR;;;;AAKD,IAAsB,YAAtB,MAAkD;CAIhD,AAAU,aAA6B;;;;;;;CAQvC,sBAAsBC,cAAoC;EACxD,KAAK,aAAa;CACnB;AAKF;AAED,MAAM,6BAAa,IAAI;;;;AAKvB,IAAa,gBAAb,MAAa,sBAAwC,UAAa;CAChE,AAAQ;CAER,YAAYC,KAAsB;EAChC,OAAO;EACP,KAAK,QAAQ,uBAAO,IAAI;CACzB;;;;;;;;CASD,OAAOC,QAAgBC,QAAmC;AACxD,SAAO,QAAQ,QACb,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC,IAAI,KACpD;CACF;;;;;;;CAQD,MAAM,OAAOD,QAAgBC,QAAgBC,OAAyB;EACpE,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,EAAE,MAAM;CACvD;;;;;;CAOD,OAAO,SAAwB;AAC7B,SAAO,IAAI,cAAc;CAC1B;AACF"}
1
+ {"version":3,"file":"base.js","names":["defaultHashKeyEncoder: HashKeyEncoder","storedGeneration: StoredGeneration","generation: Generation","serializedValue: StoredGeneration","keyEncoderFn: HashKeyEncoder","map?: Map<string, T>","prompt: string","llmKey: string","value: T"],"sources":["../../src/caches/base.ts"],"sourcesContent":["import { sha256, type HashKeyEncoder } from \"../utils/hash.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { mapStoredMessageToChatMessage } from \"../messages/utils.js\";\nimport { type StoredGeneration } from \"../messages/base.js\";\n\nexport const defaultHashKeyEncoder: HashKeyEncoder = (...strings) =>\n sha256(strings.join(\"_\"));\n\nexport function deserializeStoredGeneration(\n storedGeneration: StoredGeneration\n) {\n if (storedGeneration.message !== undefined) {\n return {\n text: storedGeneration.text,\n message: mapStoredMessageToChatMessage(storedGeneration.message),\n };\n } else {\n return { text: storedGeneration.text };\n }\n}\n\nexport function serializeGeneration(generation: Generation) {\n const serializedValue: StoredGeneration = {\n text: generation.text,\n };\n if ((generation as ChatGeneration).message !== undefined) {\n serializedValue.message = (generation as ChatGeneration).message.toDict();\n }\n return serializedValue;\n}\n\n/**\n * Base class for all caches. All caches should extend this class.\n */\nexport abstract class BaseCache<T = Generation[]> {\n protected keyEncoder: HashKeyEncoder = defaultHashKeyEncoder;\n\n /**\n * Sets a custom key encoder function for the cache.\n * This function should take a prompt and an LLM key and return a string\n * that will be used as the cache key.\n * @param keyEncoderFn The custom key encoder function.\n */\n makeDefaultKeyEncoder(keyEncoderFn: HashKeyEncoder): void {\n this.keyEncoder = keyEncoderFn;\n }\n\n abstract lookup(prompt: string, llmKey: string): Promise<T | null>;\n\n abstract update(prompt: string, llmKey: string, value: T): Promise<void>;\n}\n\nconst GLOBAL_MAP = new Map();\n\n/**\n * A cache for storing LLM generations that stores data in memory.\n */\nexport class InMemoryCache<T = Generation[]> extends BaseCache<T> {\n private cache: Map<string, T>;\n\n constructor(map?: Map<string, T>) {\n super();\n this.cache = map ?? new Map();\n }\n\n /**\n * Retrieves data from the cache using a prompt and an LLM key. If the\n * data is not found, it returns null.\n * @param prompt The prompt used to find the data.\n * @param llmKey The LLM key used to find the data.\n * @returns The data corresponding to the prompt and LLM key, or null if not found.\n */\n lookup(prompt: string, llmKey: string): Promise<T | null> {\n return Promise.resolve(\n this.cache.get(this.keyEncoder(prompt, llmKey)) ?? null\n );\n }\n\n /**\n * Updates the cache with new data using a prompt and an LLM key.\n * @param prompt The prompt used to store the data.\n * @param llmKey The LLM key used to store the data.\n * @param value The data to be stored.\n */\n async update(prompt: string, llmKey: string, value: T): Promise<void> {\n this.cache.set(this.keyEncoder(prompt, llmKey), value);\n }\n\n /**\n * Returns a global instance of InMemoryCache using a predefined global\n * map as the initial cache.\n * @returns A global instance of InMemoryCache.\n */\n static global(): InMemoryCache {\n return new InMemoryCache(GLOBAL_MAP);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAaA,wBAAwC,CAAC,GAAG,YACvD,OAAO,QAAQ,KAAK,IAAI,CAAC;AAE3B,SAAgB,4BACdC,kBACA;AACA,KAAI,iBAAiB,YAAY,OAC/B,QAAO;EACL,MAAM,iBAAiB;EACvB,SAAS,8BAA8B,iBAAiB,QAAQ;CACjE;KAED,QAAO,EAAE,MAAM,iBAAiB,KAAM;AAEzC;AAED,SAAgB,oBAAoBC,YAAwB;CAC1D,MAAMC,kBAAoC,EACxC,MAAM,WAAW,KAClB;AACD,KAAK,WAA8B,YAAY,QAC7C,gBAAgB,UAAW,WAA8B,QAAQ,QAAQ;AAE3E,QAAO;AACR;;;;AAKD,IAAsB,YAAtB,MAAkD;CAChD,AAAU,aAA6B;;;;;;;CAQvC,sBAAsBC,cAAoC;EACxD,KAAK,aAAa;CACnB;AAKF;AAED,MAAM,6BAAa,IAAI;;;;AAKvB,IAAa,gBAAb,MAAa,sBAAwC,UAAa;CAChE,AAAQ;CAER,YAAYC,KAAsB;EAChC,OAAO;EACP,KAAK,QAAQ,uBAAO,IAAI;CACzB;;;;;;;;CASD,OAAOC,QAAgBC,QAAmC;AACxD,SAAO,QAAQ,QACb,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC,IAAI,KACpD;CACF;;;;;;;CAQD,MAAM,OAAOD,QAAgBC,QAAgBC,OAAyB;EACpE,KAAK,MAAM,IAAI,KAAK,WAAW,QAAQ,OAAO,EAAE,MAAM;CACvD;;;;;;CAOD,OAAO,SAAwB;AAC7B,SAAO,IAAI,cAAc;CAC1B;AACF"}
@@ -1,9 +1,10 @@
1
1
  import { AgentAction, AgentFinish } from "../agents.cjs";
2
2
  import { SerializedFields } from "../load/map_keys.cjs";
3
3
  import { Serializable, Serialized, SerializedNotImplemented } from "../load/serializable.cjs";
4
- import { ChainValues } from "../utils/types/index.cjs";
5
4
  import { BaseMessage } from "../messages/base.cjs";
5
+ import { MessageStructure, MessageType } from "../messages/message.cjs";
6
6
  import { ChatGenerationChunk, GenerationChunk, LLMResult } from "../outputs.cjs";
7
+ import { ChainValues } from "../utils/types/index.cjs";
7
8
  import { DocumentInterface } from "../documents/document.cjs";
8
9
 
9
10
  //#region src/callbacks/base.d.ts
@@ -236,7 +237,7 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
236
237
  * Called at the start of a Chat Model run, with the prompt(s)
237
238
  * and the run ID.
238
239
  */
239
- handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
240
+ handleChatModelStart?(llm: Serialized, messages: BaseMessage<MessageStructure, MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
240
241
  /**
241
242
  * Called at the start of a Chain run, with the chain name and inputs
242
243
  * and the run ID.
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.cts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleCustomEvent?(eventName: string, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any, runId: string, tags?: string[], \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runType?: string | undefined, runName?: string | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n readonly lc_namespace: [\"langchain_core\", \"callbacks\", string];\n readonly lc_secrets: {\n [key: string]: string;\n } | undefined;\n readonly lc_attributes: {\n [key: string]: string;\n } | undefined;\n readonly lc_aliases: {\n [key: string]: string;\n } | undefined;\n readonly lc_serializable_keys: string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n readonly lc_id: string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n name: string;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n"],"mappings":";;;;;;;;;;KAQKY,KAAAA;AAF6D;AAQlE;AAaA;AAKA;;AACYP,UAnBKQ,wBAAAA,CAmBLR;EAAe,SAAGD,CAAAA,EAAAA,OAAAA;EAAmB,WAAA,CAAA,EAAA,OAAA;EAO1BY,WAAAA,CAAAA,EAAAA,OAAAA;EAA+B,eAAA,CAAA,EAAA,OAAA;EAAA,iBAK7BR,CAAAA,EAAAA,OAAAA;EAAU,aAAwES,CAAAA,EAAAA,OAAAA;EAAM,UAA+CA,CAAAA,EAAAA,OAAAA;;;;;;AAiB5DA,UAnCnFH,eAAAA,CAmCmFG;EAAM,MACtGC,EAAAA,MAAAA;EAAO,UAIeZ,EAAAA,MA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;;4BAKtGf,mGAAmGe;qCAC1FV,oHAAoHS;mCACtHN,kBAAkBM;;4GAEuDA;;;;;;;;;;;;;;;;;eAiB7FP;;;;;;;;YAQHY;cACEd;4BACcC;;;;cAIXc"}
1
+ {"version":3,"file":"base.d.cts","names":["ChainValues","BaseMessage","AgentAction","AgentFinish","ChatGenerationChunk","GenerationChunk","LLMResult","Serializable","Serialized","SerializedNotImplemented","SerializedFields","DocumentInterface","Error","BaseCallbackHandlerInput","NewTokenIndices","HandleLLMNewTokenCallbackFields","BaseCallbackHandlerMethodsClass","Record","Promise","CallbackHandlerMethods","CallbackHandlerPrefersStreaming","callbackHandlerPrefersStreaming","BaseCallbackHandler","___messages_message_js5","MessageStructure","MessageType","isBaseCallbackHandler"],"sources":["../../src/callbacks/base.d.ts"],"sourcesContent":["import type { ChainValues } from \"../utils/types/index.js\";\nimport type { BaseMessage } from \"../messages/base.js\";\nimport type { AgentAction, AgentFinish } from \"../agents.js\";\nimport type { ChatGenerationChunk, GenerationChunk, LLMResult } from \"../outputs.js\";\nimport { Serializable, Serialized, SerializedNotImplemented } from \"../load/serializable.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport type { DocumentInterface } from \"../documents/document.js\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Error = any;\n/**\n * Interface for the input parameters of the BaseCallbackHandler class. It\n * allows to specify which types of events should be ignored by the\n * callback handler.\n */\nexport interface BaseCallbackHandlerInput {\n ignoreLLM?: boolean;\n ignoreChain?: boolean;\n ignoreAgent?: boolean;\n ignoreRetriever?: boolean;\n ignoreCustomEvent?: boolean;\n _awaitHandler?: boolean;\n raiseError?: boolean;\n}\n/**\n * Interface for the indices of a new token produced by an LLM or Chat\n * Model in streaming mode.\n */\nexport interface NewTokenIndices {\n prompt: number;\n completion: number;\n}\n// TODO: Add all additional callback fields here\nexport type HandleLLMNewTokenCallbackFields = {\n chunk?: GenerationChunk | ChatGenerationChunk;\n};\n/**\n * Abstract class that provides a set of optional methods that can be\n * overridden in derived classes to handle various events during the\n * execution of a LangChain application.\n */\ndeclare abstract class BaseCallbackHandlerMethodsClass {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, \n /**\n * idx.prompt is the index of the prompt that produced the token\n * (if there are multiple prompts)\n * idx.completion is the index of the completion that produced the token\n * (if multiple completions per prompt are requested)\n */\n idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[], fields?: HandleLLMNewTokenCallbackFields): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], extraParams?: Record<string, unknown>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], kwargs?: {\n inputs?: Record<string, unknown>;\n }): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n output: any, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverEnd?(documents: DocumentInterface[], runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleRetrieverError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n handleCustomEvent?(eventName: string, \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any, runId: string, tags?: string[], \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Promise<any> | any;\n}\n/**\n * Base interface for callbacks. All methods are optional. If a method is not\n * implemented, it will be ignored. If a method is implemented, it will be\n * called at the appropriate time. All methods are called with the run ID of\n * the LLM/ChatModel/Chain that is running, which is generated by the\n * CallbackManager.\n *\n * @interface\n */\nexport type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;\n/**\n * Interface for handlers that can indicate a preference for streaming responses.\n * When implemented, this allows the handler to signal whether it prefers to receive\n * streaming responses from language models rather than complete responses.\n */\nexport interface CallbackHandlerPrefersStreaming {\n readonly lc_prefer_streaming: boolean;\n}\nexport declare function callbackHandlerPrefersStreaming(x: BaseCallbackHandler): unknown;\n/**\n * Abstract base class for creating callback handlers in the LangChain\n * framework. It provides a set of optional methods that can be overridden\n * in derived classes to handle various events during the execution of a\n * LangChain application.\n */\nexport declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput, Serializable {\n lc_serializable: boolean;\n get lc_namespace(): [\"langchain_core\", \"callbacks\", string];\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n get lc_attributes(): {\n [key: string]: string;\n } | undefined;\n get lc_aliases(): {\n [key: string]: string;\n } | undefined;\n get lc_serializable_keys(): string[] | undefined;\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string;\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[];\n lc_kwargs: SerializedFields;\n abstract name: string;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n constructor(input?: BaseCallbackHandlerInput);\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n static fromMethods(methods: CallbackHandlerMethods): {\n /**\n * Called at the start of an LLM or Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called when an LLM/ChatModel in `streaming` mode produces a new token\n */\n handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, fields?: HandleLLMNewTokenCallbackFields | undefined): any;\n /**\n * Called if an LLM/ChatModel run encounters an error\n */\n handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the end of an LLM/ChatModel run, with the output and the run ID.\n */\n handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, extraParams?: Record<string, unknown> | undefined): any;\n /**\n * Called at the start of a Chat Model run, with the prompt(s)\n * and the run ID.\n */\n handleChatModelStart?(llm: Serialized, messages: BaseMessage<import(\"../messages/message.js\").MessageStructure, import(\"../messages/message.js\").MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called at the start of a Chain run, with the chain name and inputs\n * and the run ID.\n */\n handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runType?: string | undefined, runName?: string | undefined): any;\n /**\n * Called if a Chain run encounters an error\n */\n handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the end of a Chain run, with the outputs and the run ID.\n */\n handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, kwargs?: {\n inputs?: Record<string, unknown> | undefined;\n } | undefined): any;\n /**\n * Called at the start of a Tool run, with the tool name and input\n * and the run ID.\n */\n handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;\n /**\n * Called if a Tool run encounters an error\n */\n handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n /**\n * Called at the end of a Tool run, with the tool output and the run ID.\n */\n handleToolEnd?(output: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent is about to execute an action,\n * with the action and the run ID.\n */\n handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n /**\n * Called when an agent finishes execution, before it exits.\n * with the final output and the run ID.\n */\n handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;\n handleRetrieverStart?(retriever: Serialized, query: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, name?: string | undefined): any;\n handleRetrieverEnd?(documents: DocumentInterface<Record<string, any>>[], runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleRetrieverError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): any;\n handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[] | undefined, metadata?: Record<string, any> | undefined): any;\n lc_serializable: boolean;\n readonly lc_namespace: [\"langchain_core\", \"callbacks\", string];\n readonly lc_secrets: {\n [key: string]: string;\n } | undefined;\n readonly lc_attributes: {\n [key: string]: string;\n } | undefined;\n readonly lc_aliases: {\n [key: string]: string;\n } | undefined;\n readonly lc_serializable_keys: string[] | undefined;\n /**\n * The final serialized identifier for the module.\n */\n readonly lc_id: string[];\n lc_kwargs: SerializedFields;\n ignoreLLM: boolean;\n ignoreChain: boolean;\n ignoreAgent: boolean;\n ignoreRetriever: boolean;\n ignoreCustomEvent: boolean;\n raiseError: boolean;\n awaitHandlers: boolean;\n copy(): BaseCallbackHandler;\n toJSON(): Serialized;\n toJSONNotImplemented(): SerializedNotImplemented;\n name: string;\n };\n}\nexport declare const isBaseCallbackHandler: (x: unknown) => boolean;\nexport {};\n"],"mappings":";;;;;;;;;;;KAQKY,KAAAA;;AAF6D;AAQlE;AAaA;AAKA;AAA2C,UAlB1BC,wBAAAA,CAkB0B;EAAA,SAC/BR,CAAAA,EAAAA,OAAAA;EAAe,WAAGD,CAAAA,EAAAA,OAAAA;EAAmB,WAAA,CAAA,EAAA,OAAA;EAO1BY,eAAAA,CAAAA,EAAAA,OAAAA;EAA+B,iBAAA,CAAA,EAAA,OAAA;EAAA,aAK7BR,CAAAA,EAAAA,OAAAA;EAAU,UAAwES,CAAAA,EAAAA,OAAAA;;;;;;AAiBlFL,UAnCRE,eAAAA,CAmCQF;EAAK,MAAsEK,EAAAA,MAAAA;EAAM,UACtGC,EAAAA,MAAAA;;;AAKAA,KApCQH,+BAAAA,GAoCRG;EAAO,KAKoBV,CAAAA,EAxCnBH,eAwCmBG,GAxCDJ,mBAwCCI;CAAU;;;;;;uBAjClBQ,+BAAAA,CAuCwGC;EAAM;;;;EAQ1H,cAIkBjB,CAAAA,CAAAA,GAAAA,EA9CJQ,UA8CIR,EAAAA,OAAAA,EAAAA,MAAAA,EAAAA,EAAAA,KAAAA,EAAAA,MAAAA,EAAAA,WAAAA,CAAAA,EAAAA,MAAAA,EAAAA,WAAAA,CAAAA,EA9C8EiB,MA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BACcC;;;;cAIXiB"}
@@ -1,9 +1,10 @@
1
1
  import { AgentAction, AgentFinish } from "../agents.js";
2
2
  import { SerializedFields } from "../load/map_keys.js";
3
3
  import { Serializable, Serialized, SerializedNotImplemented } from "../load/serializable.js";
4
- import { ChainValues } from "../utils/types/index.js";
5
4
  import { BaseMessage } from "../messages/base.js";
5
+ import { MessageStructure, MessageType } from "../messages/message.js";
6
6
  import { ChatGenerationChunk, GenerationChunk, LLMResult } from "../outputs.js";
7
+ import { ChainValues } from "../utils/types/index.js";
7
8
  import { DocumentInterface } from "../documents/document.js";
8
9
 
9
10
  //#region src/callbacks/base.d.ts
@@ -236,7 +237,7 @@ declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsCla
236
237
  * Called at the start of a Chat Model run, with the prompt(s)
237
238
  * and the run ID.
238
239
  */
239
- handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
240
+ handleChatModelStart?(llm: Serialized, messages: BaseMessage<MessageStructure, MessageType>[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined, runName?: string | undefined): any;
240
241
  /**
241
242
  * Called at the start of a Chain run, with the chain name and inputs
242
243
  * and the run ID.