@langchain/core 1.1.24 → 1.1.25

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 (1103) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +43 -0
  3. package/dist/_virtual/_rolldown/runtime.js +18 -0
  4. package/dist/agents.cjs +3 -1
  5. package/dist/agents.d.cts.map +1 -1
  6. package/dist/agents.d.ts.map +1 -1
  7. package/dist/agents.js +3 -1
  8. package/dist/caches/index.cjs +4 -4
  9. package/dist/caches/index.cjs.map +1 -1
  10. package/dist/caches/index.d.cts.map +1 -1
  11. package/dist/caches/index.d.ts.map +1 -1
  12. package/dist/caches/index.js +3 -4
  13. package/dist/caches/index.js.map +1 -1
  14. package/dist/callbacks/base.cjs +9 -16
  15. package/dist/callbacks/base.cjs.map +1 -1
  16. package/dist/callbacks/base.d.cts +1 -0
  17. package/dist/callbacks/base.d.cts.map +1 -1
  18. package/dist/callbacks/base.d.ts +1 -0
  19. package/dist/callbacks/base.d.ts.map +1 -1
  20. package/dist/callbacks/base.js +6 -15
  21. package/dist/callbacks/base.js.map +1 -1
  22. package/dist/callbacks/dispatch/index.cjs +6 -6
  23. package/dist/callbacks/dispatch/index.cjs.map +1 -1
  24. package/dist/callbacks/dispatch/index.d.cts +0 -1
  25. package/dist/callbacks/dispatch/index.d.cts.map +1 -1
  26. package/dist/callbacks/dispatch/index.d.ts +0 -1
  27. package/dist/callbacks/dispatch/index.d.ts.map +1 -1
  28. package/dist/callbacks/dispatch/index.js +4 -5
  29. package/dist/callbacks/dispatch/index.js.map +1 -1
  30. package/dist/callbacks/dispatch/web.cjs +1 -0
  31. package/dist/callbacks/dispatch/web.cjs.map +1 -1
  32. package/dist/callbacks/dispatch/web.d.cts +0 -1
  33. package/dist/callbacks/dispatch/web.d.cts.map +1 -1
  34. package/dist/callbacks/dispatch/web.d.ts +0 -1
  35. package/dist/callbacks/dispatch/web.d.ts.map +1 -1
  36. package/dist/callbacks/dispatch/web.js.map +1 -1
  37. package/dist/callbacks/manager.cjs +30 -50
  38. package/dist/callbacks/manager.cjs.map +1 -1
  39. package/dist/callbacks/manager.d.cts.map +1 -1
  40. package/dist/callbacks/manager.d.ts.map +1 -1
  41. package/dist/callbacks/manager.js +28 -49
  42. package/dist/callbacks/manager.js.map +1 -1
  43. package/dist/callbacks/promises.cjs +3 -3
  44. package/dist/callbacks/promises.js +2 -3
  45. package/dist/chat_history.cjs +4 -4
  46. package/dist/chat_history.cjs.map +1 -1
  47. package/dist/chat_history.d.cts +0 -1
  48. package/dist/chat_history.d.cts.map +1 -1
  49. package/dist/chat_history.d.ts +0 -1
  50. package/dist/chat_history.d.ts.map +1 -1
  51. package/dist/chat_history.js +3 -4
  52. package/dist/chat_history.js.map +1 -1
  53. package/dist/context.cjs +10 -2
  54. package/dist/context.cjs.map +1 -1
  55. package/dist/context.d.cts.map +1 -1
  56. package/dist/context.d.ts.map +1 -1
  57. package/dist/context.js +7 -0
  58. package/dist/context.js.map +1 -1
  59. package/dist/document_loaders/base.cjs +3 -3
  60. package/dist/document_loaders/base.cjs.map +1 -1
  61. package/dist/document_loaders/base.d.cts +0 -1
  62. package/dist/document_loaders/base.d.cts.map +1 -1
  63. package/dist/document_loaders/base.d.ts +0 -1
  64. package/dist/document_loaders/base.d.ts.map +1 -1
  65. package/dist/document_loaders/base.js +2 -3
  66. package/dist/document_loaders/base.js.map +1 -1
  67. package/dist/document_loaders/langsmith.cjs +4 -4
  68. package/dist/document_loaders/langsmith.cjs.map +1 -1
  69. package/dist/document_loaders/langsmith.d.cts.map +1 -1
  70. package/dist/document_loaders/langsmith.d.ts.map +1 -1
  71. package/dist/document_loaders/langsmith.js +2 -3
  72. package/dist/document_loaders/langsmith.js.map +1 -1
  73. package/dist/documents/document.cjs.map +1 -1
  74. package/dist/documents/document.d.cts.map +1 -1
  75. package/dist/documents/document.d.ts.map +1 -1
  76. package/dist/documents/document.js.map +1 -1
  77. package/dist/documents/index.cjs +3 -3
  78. package/dist/documents/index.js +2 -3
  79. package/dist/documents/transformers.cjs.map +1 -1
  80. package/dist/documents/transformers.d.cts +0 -1
  81. package/dist/documents/transformers.d.cts.map +1 -1
  82. package/dist/documents/transformers.d.ts +0 -1
  83. package/dist/documents/transformers.d.ts.map +1 -1
  84. package/dist/documents/transformers.js.map +1 -1
  85. package/dist/embeddings.cjs +3 -3
  86. package/dist/embeddings.cjs.map +1 -1
  87. package/dist/embeddings.d.cts +0 -1
  88. package/dist/embeddings.d.cts.map +1 -1
  89. package/dist/embeddings.d.ts +0 -1
  90. package/dist/embeddings.d.ts.map +1 -1
  91. package/dist/embeddings.js +2 -3
  92. package/dist/embeddings.js.map +1 -1
  93. package/dist/errors/index.cjs +141 -15
  94. package/dist/errors/index.cjs.map +1 -1
  95. package/dist/errors/index.d.cts +134 -11
  96. package/dist/errors/index.d.cts.map +1 -1
  97. package/dist/errors/index.d.ts +134 -11
  98. package/dist/errors/index.d.ts.map +1 -1
  99. package/dist/errors/index.js +138 -16
  100. package/dist/errors/index.js.map +1 -1
  101. package/dist/example_selectors/base.cjs.map +1 -1
  102. package/dist/example_selectors/base.d.cts +0 -1
  103. package/dist/example_selectors/base.d.cts.map +1 -1
  104. package/dist/example_selectors/base.d.ts +0 -1
  105. package/dist/example_selectors/base.d.ts.map +1 -1
  106. package/dist/example_selectors/base.js.map +1 -1
  107. package/dist/example_selectors/conditional.cjs +1 -2
  108. package/dist/example_selectors/conditional.cjs.map +1 -1
  109. package/dist/example_selectors/conditional.d.cts.map +1 -1
  110. package/dist/example_selectors/conditional.d.ts.map +1 -1
  111. package/dist/example_selectors/conditional.js +1 -2
  112. package/dist/example_selectors/conditional.js.map +1 -1
  113. package/dist/example_selectors/index.cjs +3 -3
  114. package/dist/example_selectors/index.js +2 -3
  115. package/dist/example_selectors/length_based.cjs +1 -2
  116. package/dist/example_selectors/length_based.cjs.map +1 -1
  117. package/dist/example_selectors/length_based.d.cts +0 -1
  118. package/dist/example_selectors/length_based.d.cts.map +1 -1
  119. package/dist/example_selectors/length_based.d.ts +0 -1
  120. package/dist/example_selectors/length_based.d.ts.map +1 -1
  121. package/dist/example_selectors/length_based.js +1 -2
  122. package/dist/example_selectors/length_based.js.map +1 -1
  123. package/dist/example_selectors/semantic_similarity.cjs +4 -8
  124. package/dist/example_selectors/semantic_similarity.cjs.map +1 -1
  125. package/dist/example_selectors/semantic_similarity.d.cts +0 -1
  126. package/dist/example_selectors/semantic_similarity.d.cts.map +1 -1
  127. package/dist/example_selectors/semantic_similarity.d.ts +0 -1
  128. package/dist/example_selectors/semantic_similarity.d.ts.map +1 -1
  129. package/dist/example_selectors/semantic_similarity.js +4 -8
  130. package/dist/example_selectors/semantic_similarity.js.map +1 -1
  131. package/dist/index.cjs +3 -1
  132. package/dist/index.js +3 -1
  133. package/dist/indexing/base.cjs +7 -11
  134. package/dist/indexing/base.cjs.map +1 -1
  135. package/dist/indexing/base.d.cts.map +1 -1
  136. package/dist/indexing/base.d.ts.map +1 -1
  137. package/dist/indexing/base.js +5 -9
  138. package/dist/indexing/base.js.map +1 -1
  139. package/dist/indexing/index.cjs +3 -3
  140. package/dist/indexing/index.js +2 -3
  141. package/dist/indexing/record_manager.cjs.map +1 -1
  142. package/dist/indexing/record_manager.d.cts.map +1 -1
  143. package/dist/indexing/record_manager.d.ts.map +1 -1
  144. package/dist/indexing/record_manager.js.map +1 -1
  145. package/dist/language_models/base.cjs +10 -14
  146. package/dist/language_models/base.cjs.map +1 -1
  147. package/dist/language_models/base.d.cts +2 -4
  148. package/dist/language_models/base.d.cts.map +1 -1
  149. package/dist/language_models/base.d.ts +2 -4
  150. package/dist/language_models/base.d.ts.map +1 -1
  151. package/dist/language_models/base.js +9 -14
  152. package/dist/language_models/base.js.map +1 -1
  153. package/dist/language_models/chat_models.cjs +19 -25
  154. package/dist/language_models/chat_models.cjs.map +1 -1
  155. package/dist/language_models/chat_models.d.cts.map +1 -1
  156. package/dist/language_models/chat_models.d.ts.map +1 -1
  157. package/dist/language_models/chat_models.js +18 -25
  158. package/dist/language_models/chat_models.js.map +1 -1
  159. package/dist/language_models/llms.cjs +12 -15
  160. package/dist/language_models/llms.cjs.map +1 -1
  161. package/dist/language_models/llms.d.cts.map +1 -1
  162. package/dist/language_models/llms.d.ts.map +1 -1
  163. package/dist/language_models/llms.js +11 -15
  164. package/dist/language_models/llms.js.map +1 -1
  165. package/dist/language_models/profile.cjs +3 -1
  166. package/dist/language_models/profile.d.cts.map +1 -1
  167. package/dist/language_models/profile.d.ts.map +1 -1
  168. package/dist/language_models/profile.js +3 -1
  169. package/dist/language_models/utils.cjs.map +1 -1
  170. package/dist/language_models/utils.js.map +1 -1
  171. package/dist/load/import_constants.cjs.map +1 -1
  172. package/dist/load/import_constants.js.map +1 -1
  173. package/dist/load/import_map.cjs +13 -14
  174. package/dist/load/import_map.js +13 -14
  175. package/dist/load/import_type.d.cts.map +1 -1
  176. package/dist/load/import_type.d.ts.map +1 -1
  177. package/dist/load/index.cjs +74 -13
  178. package/dist/load/index.cjs.map +1 -1
  179. package/dist/load/index.d.cts +13 -4
  180. package/dist/load/index.d.cts.map +1 -1
  181. package/dist/load/index.d.ts +13 -4
  182. package/dist/load/index.d.ts.map +1 -1
  183. package/dist/load/index.js +68 -8
  184. package/dist/load/index.js.map +1 -1
  185. package/dist/load/map_keys.cjs +5 -3
  186. package/dist/load/map_keys.cjs.map +1 -1
  187. package/dist/load/map_keys.d.cts.map +1 -1
  188. package/dist/load/map_keys.d.ts.map +1 -1
  189. package/dist/load/map_keys.js.map +1 -1
  190. package/dist/load/serializable.cjs +9 -19
  191. package/dist/load/serializable.cjs.map +1 -1
  192. package/dist/load/serializable.d.cts.map +1 -1
  193. package/dist/load/serializable.d.ts.map +1 -1
  194. package/dist/load/serializable.js +8 -19
  195. package/dist/load/serializable.js.map +1 -1
  196. package/dist/load/validation.cjs.map +1 -1
  197. package/dist/load/validation.js.map +1 -1
  198. package/dist/memory.cjs +3 -3
  199. package/dist/memory.cjs.map +1 -1
  200. package/dist/memory.d.cts.map +1 -1
  201. package/dist/memory.d.ts.map +1 -1
  202. package/dist/memory.js +2 -3
  203. package/dist/memory.js.map +1 -1
  204. package/dist/messages/ai.cjs.map +1 -1
  205. package/dist/messages/ai.d.cts.map +1 -1
  206. package/dist/messages/ai.d.ts.map +1 -1
  207. package/dist/messages/ai.js.map +1 -1
  208. package/dist/messages/base.cjs +10 -12
  209. package/dist/messages/base.cjs.map +1 -1
  210. package/dist/messages/base.d.cts +6 -3
  211. package/dist/messages/base.d.cts.map +1 -1
  212. package/dist/messages/base.d.ts +6 -3
  213. package/dist/messages/base.d.ts.map +1 -1
  214. package/dist/messages/base.js +10 -12
  215. package/dist/messages/base.js.map +1 -1
  216. package/dist/messages/block_translators/anthropic.cjs +30 -35
  217. package/dist/messages/block_translators/anthropic.cjs.map +1 -1
  218. package/dist/messages/block_translators/anthropic.js +30 -35
  219. package/dist/messages/block_translators/anthropic.js.map +1 -1
  220. package/dist/messages/block_translators/bedrock_converse.cjs +38 -46
  221. package/dist/messages/block_translators/bedrock_converse.cjs.map +1 -1
  222. package/dist/messages/block_translators/bedrock_converse.js +38 -46
  223. package/dist/messages/block_translators/bedrock_converse.js.map +1 -1
  224. package/dist/messages/block_translators/data.cjs.map +1 -1
  225. package/dist/messages/block_translators/data.js.map +1 -1
  226. package/dist/messages/block_translators/deepseek.cjs.map +1 -1
  227. package/dist/messages/block_translators/deepseek.js.map +1 -1
  228. package/dist/messages/block_translators/google.cjs +6 -9
  229. package/dist/messages/block_translators/google.cjs.map +1 -1
  230. package/dist/messages/block_translators/google.js +6 -9
  231. package/dist/messages/block_translators/google.js.map +1 -1
  232. package/dist/messages/block_translators/google_genai.cjs.map +1 -1
  233. package/dist/messages/block_translators/google_genai.js.map +1 -1
  234. package/dist/messages/block_translators/google_vertexai.cjs +1 -3
  235. package/dist/messages/block_translators/google_vertexai.cjs.map +1 -1
  236. package/dist/messages/block_translators/google_vertexai.js +1 -3
  237. package/dist/messages/block_translators/google_vertexai.js.map +1 -1
  238. package/dist/messages/block_translators/groq.cjs.map +1 -1
  239. package/dist/messages/block_translators/groq.js.map +1 -1
  240. package/dist/messages/block_translators/index.cjs.map +1 -1
  241. package/dist/messages/block_translators/index.js.map +1 -1
  242. package/dist/messages/block_translators/ollama.cjs.map +1 -1
  243. package/dist/messages/block_translators/ollama.js.map +1 -1
  244. package/dist/messages/block_translators/openai.cjs +6 -10
  245. package/dist/messages/block_translators/openai.cjs.map +1 -1
  246. package/dist/messages/block_translators/openai.js +6 -10
  247. package/dist/messages/block_translators/openai.js.map +1 -1
  248. package/dist/messages/block_translators/utils.cjs +1 -1
  249. package/dist/messages/block_translators/utils.cjs.map +1 -1
  250. package/dist/messages/block_translators/utils.js +1 -1
  251. package/dist/messages/block_translators/utils.js.map +1 -1
  252. package/dist/messages/block_translators/xai.cjs.map +1 -1
  253. package/dist/messages/block_translators/xai.js.map +1 -1
  254. package/dist/messages/chat.cjs.map +1 -1
  255. package/dist/messages/chat.d.cts.map +1 -1
  256. package/dist/messages/chat.d.ts.map +1 -1
  257. package/dist/messages/chat.js.map +1 -1
  258. package/dist/messages/content/base.d.cts.map +1 -1
  259. package/dist/messages/content/base.d.ts.map +1 -1
  260. package/dist/messages/content/data.cjs +1 -3
  261. package/dist/messages/content/data.cjs.map +1 -1
  262. package/dist/messages/content/data.d.cts +0 -1
  263. package/dist/messages/content/data.d.cts.map +1 -1
  264. package/dist/messages/content/data.d.ts +0 -1
  265. package/dist/messages/content/data.d.ts.map +1 -1
  266. package/dist/messages/content/data.js +1 -3
  267. package/dist/messages/content/data.js.map +1 -1
  268. package/dist/messages/content/index.cjs +2 -2
  269. package/dist/messages/content/index.cjs.map +1 -1
  270. package/dist/messages/content/index.d.cts.map +1 -1
  271. package/dist/messages/content/index.d.ts.map +1 -1
  272. package/dist/messages/content/index.js +6 -6
  273. package/dist/messages/content/index.js.map +1 -1
  274. package/dist/messages/content/multimodal.cjs.map +1 -1
  275. package/dist/messages/content/multimodal.d.cts +4 -8
  276. package/dist/messages/content/multimodal.d.cts.map +1 -1
  277. package/dist/messages/content/multimodal.d.ts +4 -8
  278. package/dist/messages/content/multimodal.d.ts.map +1 -1
  279. package/dist/messages/content/multimodal.js.map +1 -1
  280. package/dist/messages/content/tools.cjs.map +1 -1
  281. package/dist/messages/content/tools.d.cts.map +1 -1
  282. package/dist/messages/content/tools.d.ts.map +1 -1
  283. package/dist/messages/content/tools.js.map +1 -1
  284. package/dist/messages/format.cjs.map +1 -1
  285. package/dist/messages/format.d.cts.map +1 -1
  286. package/dist/messages/format.d.ts.map +1 -1
  287. package/dist/messages/format.js.map +1 -1
  288. package/dist/messages/function.cjs.map +1 -1
  289. package/dist/messages/function.d.cts.map +1 -1
  290. package/dist/messages/function.d.ts.map +1 -1
  291. package/dist/messages/function.js.map +1 -1
  292. package/dist/messages/human.cjs.map +1 -1
  293. package/dist/messages/human.d.cts.map +1 -1
  294. package/dist/messages/human.d.ts.map +1 -1
  295. package/dist/messages/human.js.map +1 -1
  296. package/dist/messages/index.cjs +4 -4
  297. package/dist/messages/index.js +3 -4
  298. package/dist/messages/message.cjs.map +1 -1
  299. package/dist/messages/message.d.cts +13 -24
  300. package/dist/messages/message.d.cts.map +1 -1
  301. package/dist/messages/message.d.ts +13 -24
  302. package/dist/messages/message.d.ts.map +1 -1
  303. package/dist/messages/message.js.map +1 -1
  304. package/dist/messages/metadata.cjs +1 -2
  305. package/dist/messages/metadata.cjs.map +1 -1
  306. package/dist/messages/metadata.d.cts.map +1 -1
  307. package/dist/messages/metadata.d.ts.map +1 -1
  308. package/dist/messages/metadata.js +1 -2
  309. package/dist/messages/metadata.js.map +1 -1
  310. package/dist/messages/modifier.cjs.map +1 -1
  311. package/dist/messages/modifier.d.cts.map +1 -1
  312. package/dist/messages/modifier.d.ts.map +1 -1
  313. package/dist/messages/modifier.js.map +1 -1
  314. package/dist/messages/system.cjs.map +1 -1
  315. package/dist/messages/system.d.cts.map +1 -1
  316. package/dist/messages/system.d.ts.map +1 -1
  317. package/dist/messages/system.js.map +1 -1
  318. package/dist/messages/tool.cjs +3 -3
  319. package/dist/messages/tool.cjs.map +1 -1
  320. package/dist/messages/tool.d.cts.map +1 -1
  321. package/dist/messages/tool.d.ts.map +1 -1
  322. package/dist/messages/tool.js +2 -3
  323. package/dist/messages/tool.js.map +1 -1
  324. package/dist/messages/transformers.cjs +8 -14
  325. package/dist/messages/transformers.cjs.map +1 -1
  326. package/dist/messages/transformers.d.cts.map +1 -1
  327. package/dist/messages/transformers.d.ts.map +1 -1
  328. package/dist/messages/transformers.js +8 -14
  329. package/dist/messages/transformers.js.map +1 -1
  330. package/dist/messages/utils.cjs +11 -14
  331. package/dist/messages/utils.cjs.map +1 -1
  332. package/dist/messages/utils.d.cts +7 -7
  333. package/dist/messages/utils.d.cts.map +1 -1
  334. package/dist/messages/utils.d.ts +7 -7
  335. package/dist/messages/utils.d.ts.map +1 -1
  336. package/dist/messages/utils.js +11 -14
  337. package/dist/messages/utils.js.map +1 -1
  338. package/dist/output_parsers/base.cjs +5 -5
  339. package/dist/output_parsers/base.cjs.map +1 -1
  340. package/dist/output_parsers/base.d.cts.map +1 -1
  341. package/dist/output_parsers/base.d.ts.map +1 -1
  342. package/dist/output_parsers/base.js +5 -5
  343. package/dist/output_parsers/base.js.map +1 -1
  344. package/dist/output_parsers/bytes.cjs.map +1 -1
  345. package/dist/output_parsers/bytes.d.cts +0 -1
  346. package/dist/output_parsers/bytes.d.cts.map +1 -1
  347. package/dist/output_parsers/bytes.d.ts +0 -1
  348. package/dist/output_parsers/bytes.d.ts.map +1 -1
  349. package/dist/output_parsers/bytes.js.map +1 -1
  350. package/dist/output_parsers/index.cjs +3 -3
  351. package/dist/output_parsers/index.js +2 -3
  352. package/dist/output_parsers/json.cjs +1 -1
  353. package/dist/output_parsers/json.cjs.map +1 -1
  354. package/dist/output_parsers/json.d.cts +0 -1
  355. package/dist/output_parsers/json.d.cts.map +1 -1
  356. package/dist/output_parsers/json.d.ts.map +1 -1
  357. package/dist/output_parsers/json.js +1 -1
  358. package/dist/output_parsers/json.js.map +1 -1
  359. package/dist/output_parsers/list.cjs.map +1 -1
  360. package/dist/output_parsers/list.d.cts +0 -1
  361. package/dist/output_parsers/list.d.cts.map +1 -1
  362. package/dist/output_parsers/list.d.ts +0 -1
  363. package/dist/output_parsers/list.d.ts.map +1 -1
  364. package/dist/output_parsers/list.js.map +1 -1
  365. package/dist/output_parsers/openai_functions/index.cjs +3 -3
  366. package/dist/output_parsers/openai_functions/index.js +2 -3
  367. package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs +6 -9
  368. package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs.map +1 -1
  369. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +0 -1
  370. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -1
  371. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -1
  372. package/dist/output_parsers/openai_functions/json_output_functions_parsers.js +6 -9
  373. package/dist/output_parsers/openai_functions/json_output_functions_parsers.js.map +1 -1
  374. package/dist/output_parsers/openai_tools/index.cjs +3 -3
  375. package/dist/output_parsers/openai_tools/index.js +2 -3
  376. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +14 -21
  377. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  378. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +1 -2
  379. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -1
  380. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +1 -2
  381. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -1
  382. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +14 -21
  383. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  384. package/dist/output_parsers/string.cjs +3 -0
  385. package/dist/output_parsers/string.cjs.map +1 -1
  386. package/dist/output_parsers/string.d.cts +0 -1
  387. package/dist/output_parsers/string.d.cts.map +1 -1
  388. package/dist/output_parsers/string.d.ts +0 -1
  389. package/dist/output_parsers/string.d.ts.map +1 -1
  390. package/dist/output_parsers/string.js +3 -0
  391. package/dist/output_parsers/string.js.map +1 -1
  392. package/dist/output_parsers/structured.cjs +10 -13
  393. package/dist/output_parsers/structured.cjs.map +1 -1
  394. package/dist/output_parsers/structured.d.cts.map +1 -1
  395. package/dist/output_parsers/structured.d.ts.map +1 -1
  396. package/dist/output_parsers/structured.js +8 -11
  397. package/dist/output_parsers/structured.js.map +1 -1
  398. package/dist/output_parsers/transform.cjs +3 -3
  399. package/dist/output_parsers/transform.cjs.map +1 -1
  400. package/dist/output_parsers/transform.d.cts +0 -1
  401. package/dist/output_parsers/transform.d.cts.map +1 -1
  402. package/dist/output_parsers/transform.d.ts +0 -1
  403. package/dist/output_parsers/transform.d.ts.map +1 -1
  404. package/dist/output_parsers/transform.js.map +1 -1
  405. package/dist/output_parsers/xml.cjs +4 -7
  406. package/dist/output_parsers/xml.cjs.map +1 -1
  407. package/dist/output_parsers/xml.d.cts.map +1 -1
  408. package/dist/output_parsers/xml.d.ts.map +1 -1
  409. package/dist/output_parsers/xml.js +4 -7
  410. package/dist/output_parsers/xml.js.map +1 -1
  411. package/dist/outputs.cjs +3 -3
  412. package/dist/outputs.cjs.map +1 -1
  413. package/dist/outputs.d.cts.map +1 -1
  414. package/dist/outputs.d.ts.map +1 -1
  415. package/dist/outputs.js +2 -3
  416. package/dist/outputs.js.map +1 -1
  417. package/dist/prompt_values.cjs +3 -3
  418. package/dist/prompt_values.cjs.map +1 -1
  419. package/dist/prompt_values.d.cts +1 -3
  420. package/dist/prompt_values.d.cts.map +1 -1
  421. package/dist/prompt_values.d.ts +1 -3
  422. package/dist/prompt_values.d.ts.map +1 -1
  423. package/dist/prompt_values.js +2 -3
  424. package/dist/prompt_values.js.map +1 -1
  425. package/dist/prompts/base.cjs +2 -3
  426. package/dist/prompts/base.cjs.map +1 -1
  427. package/dist/prompts/base.d.cts.map +1 -1
  428. package/dist/prompts/base.d.ts.map +1 -1
  429. package/dist/prompts/base.js +2 -3
  430. package/dist/prompts/base.js.map +1 -1
  431. package/dist/prompts/chat.cjs +22 -37
  432. package/dist/prompts/chat.cjs.map +1 -1
  433. package/dist/prompts/chat.d.cts +1 -0
  434. package/dist/prompts/chat.d.cts.map +1 -1
  435. package/dist/prompts/chat.d.ts +1 -0
  436. package/dist/prompts/chat.d.ts.map +1 -1
  437. package/dist/prompts/chat.js +22 -37
  438. package/dist/prompts/chat.js.map +1 -1
  439. package/dist/prompts/dict.cjs.map +1 -1
  440. package/dist/prompts/dict.d.cts.map +1 -1
  441. package/dist/prompts/dict.d.ts.map +1 -1
  442. package/dist/prompts/dict.js.map +1 -1
  443. package/dist/prompts/few_shot.cjs +9 -14
  444. package/dist/prompts/few_shot.cjs.map +1 -1
  445. package/dist/prompts/few_shot.d.cts.map +1 -1
  446. package/dist/prompts/few_shot.d.ts.map +1 -1
  447. package/dist/prompts/few_shot.js +9 -14
  448. package/dist/prompts/few_shot.js.map +1 -1
  449. package/dist/prompts/image.cjs +3 -5
  450. package/dist/prompts/image.cjs.map +1 -1
  451. package/dist/prompts/image.d.cts +0 -1
  452. package/dist/prompts/image.d.cts.map +1 -1
  453. package/dist/prompts/image.d.ts +0 -1
  454. package/dist/prompts/image.d.ts.map +1 -1
  455. package/dist/prompts/image.js +3 -5
  456. package/dist/prompts/image.js.map +1 -1
  457. package/dist/prompts/index.cjs +3 -3
  458. package/dist/prompts/index.js +2 -3
  459. package/dist/prompts/pipeline.cjs.map +1 -1
  460. package/dist/prompts/pipeline.d.cts +0 -1
  461. package/dist/prompts/pipeline.d.cts.map +1 -1
  462. package/dist/prompts/pipeline.d.ts +0 -1
  463. package/dist/prompts/pipeline.d.ts.map +1 -1
  464. package/dist/prompts/pipeline.js.map +1 -1
  465. package/dist/prompts/prompt.cjs +9 -12
  466. package/dist/prompts/prompt.cjs.map +1 -1
  467. package/dist/prompts/prompt.d.cts +0 -1
  468. package/dist/prompts/prompt.d.cts.map +1 -1
  469. package/dist/prompts/prompt.d.ts.map +1 -1
  470. package/dist/prompts/prompt.js +9 -12
  471. package/dist/prompts/prompt.js.map +1 -1
  472. package/dist/prompts/serde.d.cts +0 -1
  473. package/dist/prompts/serde.d.cts.map +1 -1
  474. package/dist/prompts/serde.d.ts +0 -1
  475. package/dist/prompts/serde.d.ts.map +1 -1
  476. package/dist/prompts/string.cjs +1 -2
  477. package/dist/prompts/string.cjs.map +1 -1
  478. package/dist/prompts/string.d.cts +0 -1
  479. package/dist/prompts/string.d.cts.map +1 -1
  480. package/dist/prompts/string.d.ts +0 -1
  481. package/dist/prompts/string.d.ts.map +1 -1
  482. package/dist/prompts/string.js +1 -2
  483. package/dist/prompts/string.js.map +1 -1
  484. package/dist/prompts/structured.cjs.map +1 -1
  485. package/dist/prompts/structured.d.cts +0 -1
  486. package/dist/prompts/structured.d.cts.map +1 -1
  487. package/dist/prompts/structured.d.ts.map +1 -1
  488. package/dist/prompts/structured.js.map +1 -1
  489. package/dist/prompts/template.cjs +7 -11
  490. package/dist/prompts/template.cjs.map +1 -1
  491. package/dist/prompts/template.d.cts +0 -1
  492. package/dist/prompts/template.d.cts.map +1 -1
  493. package/dist/prompts/template.d.ts.map +1 -1
  494. package/dist/prompts/template.js +4 -9
  495. package/dist/prompts/template.js.map +1 -1
  496. package/dist/retrievers/document_compressors/index.cjs +3 -3
  497. package/dist/retrievers/document_compressors/index.cjs.map +1 -1
  498. package/dist/retrievers/document_compressors/index.d.cts +0 -1
  499. package/dist/retrievers/document_compressors/index.d.cts.map +1 -1
  500. package/dist/retrievers/document_compressors/index.d.ts +0 -1
  501. package/dist/retrievers/document_compressors/index.d.ts.map +1 -1
  502. package/dist/retrievers/document_compressors/index.js +2 -3
  503. package/dist/retrievers/document_compressors/index.js.map +1 -1
  504. package/dist/retrievers/index.cjs +4 -5
  505. package/dist/retrievers/index.cjs.map +1 -1
  506. package/dist/retrievers/index.d.cts +0 -1
  507. package/dist/retrievers/index.d.cts.map +1 -1
  508. package/dist/retrievers/index.d.ts +0 -1
  509. package/dist/retrievers/index.d.ts.map +1 -1
  510. package/dist/retrievers/index.js +3 -5
  511. package/dist/retrievers/index.js.map +1 -1
  512. package/dist/runnables/base.cjs +44 -67
  513. package/dist/runnables/base.cjs.map +1 -1
  514. package/dist/runnables/base.d.cts +1 -2
  515. package/dist/runnables/base.d.cts.map +1 -1
  516. package/dist/runnables/base.d.ts +1 -2
  517. package/dist/runnables/base.d.ts.map +1 -1
  518. package/dist/runnables/base.js +40 -63
  519. package/dist/runnables/base.js.map +1 -1
  520. package/dist/runnables/branch.cjs +4 -8
  521. package/dist/runnables/branch.cjs.map +1 -1
  522. package/dist/runnables/branch.d.cts +0 -1
  523. package/dist/runnables/branch.d.cts.map +1 -1
  524. package/dist/runnables/branch.d.ts +0 -1
  525. package/dist/runnables/branch.d.ts.map +1 -1
  526. package/dist/runnables/branch.js +4 -8
  527. package/dist/runnables/branch.js.map +1 -1
  528. package/dist/runnables/config.cjs +1 -1
  529. package/dist/runnables/config.cjs.map +1 -1
  530. package/dist/runnables/config.d.cts.map +1 -1
  531. package/dist/runnables/config.d.ts.map +1 -1
  532. package/dist/runnables/config.js +1 -1
  533. package/dist/runnables/config.js.map +1 -1
  534. package/dist/runnables/graph.cjs +6 -8
  535. package/dist/runnables/graph.cjs.map +1 -1
  536. package/dist/runnables/graph.d.cts.map +1 -1
  537. package/dist/runnables/graph.d.ts.map +1 -1
  538. package/dist/runnables/graph.js +4 -7
  539. package/dist/runnables/graph.js.map +1 -1
  540. package/dist/runnables/graph_mermaid.cjs +6 -9
  541. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  542. package/dist/runnables/graph_mermaid.js +6 -9
  543. package/dist/runnables/graph_mermaid.js.map +1 -1
  544. package/dist/runnables/history.cjs +4 -6
  545. package/dist/runnables/history.cjs.map +1 -1
  546. package/dist/runnables/history.d.cts.map +1 -1
  547. package/dist/runnables/history.d.ts.map +1 -1
  548. package/dist/runnables/history.js +4 -6
  549. package/dist/runnables/history.js.map +1 -1
  550. package/dist/runnables/index.cjs +3 -3
  551. package/dist/runnables/index.js +2 -3
  552. package/dist/runnables/iter.cjs.map +1 -1
  553. package/dist/runnables/iter.js.map +1 -1
  554. package/dist/runnables/passthrough.cjs +1 -1
  555. package/dist/runnables/passthrough.cjs.map +1 -1
  556. package/dist/runnables/passthrough.d.cts.map +1 -1
  557. package/dist/runnables/passthrough.d.ts.map +1 -1
  558. package/dist/runnables/passthrough.js +1 -1
  559. package/dist/runnables/passthrough.js.map +1 -1
  560. package/dist/runnables/router.cjs +2 -3
  561. package/dist/runnables/router.cjs.map +1 -1
  562. package/dist/runnables/router.d.cts.map +1 -1
  563. package/dist/runnables/router.d.ts.map +1 -1
  564. package/dist/runnables/router.js +2 -3
  565. package/dist/runnables/router.js.map +1 -1
  566. package/dist/runnables/types.d.cts +1 -2
  567. package/dist/runnables/types.d.cts.map +1 -1
  568. package/dist/runnables/types.d.ts +1 -2
  569. package/dist/runnables/types.d.ts.map +1 -1
  570. package/dist/runnables/utils.cjs +1 -2
  571. package/dist/runnables/utils.cjs.map +1 -1
  572. package/dist/runnables/utils.js +1 -2
  573. package/dist/runnables/utils.js.map +1 -1
  574. package/dist/runnables/wrappers.cjs.map +1 -1
  575. package/dist/runnables/wrappers.js.map +1 -1
  576. package/dist/singletons/async_local_storage/context.cjs +4 -5
  577. package/dist/singletons/async_local_storage/context.cjs.map +1 -1
  578. package/dist/singletons/async_local_storage/context.d.cts +0 -1
  579. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  580. package/dist/singletons/async_local_storage/context.d.ts +0 -1
  581. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  582. package/dist/singletons/async_local_storage/context.js +2 -3
  583. package/dist/singletons/async_local_storage/context.js.map +1 -1
  584. package/dist/singletons/async_local_storage/globals.cjs.map +1 -1
  585. package/dist/singletons/async_local_storage/globals.d.cts.map +1 -1
  586. package/dist/singletons/async_local_storage/globals.d.ts.map +1 -1
  587. package/dist/singletons/async_local_storage/globals.js.map +1 -1
  588. package/dist/singletons/async_local_storage/index.cjs +5 -10
  589. package/dist/singletons/async_local_storage/index.cjs.map +1 -1
  590. package/dist/singletons/async_local_storage/index.d.cts.map +1 -1
  591. package/dist/singletons/async_local_storage/index.d.ts.map +1 -1
  592. package/dist/singletons/async_local_storage/index.js +3 -8
  593. package/dist/singletons/async_local_storage/index.js.map +1 -1
  594. package/dist/singletons/callbacks.cjs +4 -4
  595. package/dist/singletons/callbacks.cjs.map +1 -1
  596. package/dist/singletons/callbacks.d.cts +0 -1
  597. package/dist/singletons/callbacks.d.cts.map +1 -1
  598. package/dist/singletons/callbacks.d.ts +0 -1
  599. package/dist/singletons/callbacks.d.ts.map +1 -1
  600. package/dist/singletons/callbacks.js +1 -2
  601. package/dist/singletons/callbacks.js.map +1 -1
  602. package/dist/singletons/index.cjs +3 -3
  603. package/dist/singletons/index.js +2 -3
  604. package/dist/singletons/tracer.cjs +3 -6
  605. package/dist/singletons/tracer.cjs.map +1 -1
  606. package/dist/singletons/tracer.js +1 -4
  607. package/dist/singletons/tracer.js.map +1 -1
  608. package/dist/stores.cjs +3 -3
  609. package/dist/stores.cjs.map +1 -1
  610. package/dist/stores.d.cts +0 -1
  611. package/dist/stores.d.cts.map +1 -1
  612. package/dist/stores.d.ts +0 -1
  613. package/dist/stores.d.ts.map +1 -1
  614. package/dist/stores.js +2 -3
  615. package/dist/stores.js.map +1 -1
  616. package/dist/structured_query/base.cjs +3 -3
  617. package/dist/structured_query/base.cjs.map +1 -1
  618. package/dist/structured_query/base.d.cts +0 -1
  619. package/dist/structured_query/base.d.cts.map +1 -1
  620. package/dist/structured_query/base.d.ts +0 -1
  621. package/dist/structured_query/base.d.ts.map +1 -1
  622. package/dist/structured_query/base.js +3 -3
  623. package/dist/structured_query/base.js.map +1 -1
  624. package/dist/structured_query/functional.cjs +3 -3
  625. package/dist/structured_query/functional.cjs.map +1 -1
  626. package/dist/structured_query/functional.d.cts +0 -1
  627. package/dist/structured_query/functional.d.cts.map +1 -1
  628. package/dist/structured_query/functional.d.ts +0 -1
  629. package/dist/structured_query/functional.d.ts.map +1 -1
  630. package/dist/structured_query/functional.js +3 -3
  631. package/dist/structured_query/functional.js.map +1 -1
  632. package/dist/structured_query/index.cjs +3 -3
  633. package/dist/structured_query/index.js +2 -3
  634. package/dist/structured_query/ir.cjs.map +1 -1
  635. package/dist/structured_query/ir.d.cts +0 -1
  636. package/dist/structured_query/ir.d.cts.map +1 -1
  637. package/dist/structured_query/ir.d.ts +0 -1
  638. package/dist/structured_query/ir.d.ts.map +1 -1
  639. package/dist/structured_query/ir.js.map +1 -1
  640. package/dist/structured_query/utils.cjs.map +1 -1
  641. package/dist/structured_query/utils.d.cts.map +1 -1
  642. package/dist/structured_query/utils.d.ts.map +1 -1
  643. package/dist/structured_query/utils.js.map +1 -1
  644. package/dist/tools/index.cjs +11 -12
  645. package/dist/tools/index.cjs.map +1 -1
  646. package/dist/tools/index.d.cts +2 -1
  647. package/dist/tools/index.d.cts.map +1 -1
  648. package/dist/tools/index.d.ts +2 -1
  649. package/dist/tools/index.d.ts.map +1 -1
  650. package/dist/tools/index.js +7 -9
  651. package/dist/tools/index.js.map +1 -1
  652. package/dist/tools/types.cjs.map +1 -1
  653. package/dist/tools/types.d.cts +1 -0
  654. package/dist/tools/types.d.cts.map +1 -1
  655. package/dist/tools/types.d.ts +1 -0
  656. package/dist/tools/types.d.ts.map +1 -1
  657. package/dist/tools/types.js.map +1 -1
  658. package/dist/tools/utils.cjs.map +1 -1
  659. package/dist/tools/utils.d.cts +0 -1
  660. package/dist/tools/utils.d.cts.map +1 -1
  661. package/dist/tools/utils.d.ts +0 -1
  662. package/dist/tools/utils.d.ts.map +1 -1
  663. package/dist/tools/utils.js.map +1 -1
  664. package/dist/tracers/base.cjs +7 -7
  665. package/dist/tracers/base.cjs.map +1 -1
  666. package/dist/tracers/base.d.cts +6 -12
  667. package/dist/tracers/base.d.cts.map +1 -1
  668. package/dist/tracers/base.d.ts +6 -12
  669. package/dist/tracers/base.d.ts.map +1 -1
  670. package/dist/tracers/base.js +5 -6
  671. package/dist/tracers/base.js.map +1 -1
  672. package/dist/tracers/console.cjs +9 -9
  673. package/dist/tracers/console.cjs.map +1 -1
  674. package/dist/tracers/console.d.cts +0 -1
  675. package/dist/tracers/console.d.cts.map +1 -1
  676. package/dist/tracers/console.d.ts +0 -1
  677. package/dist/tracers/console.d.ts.map +1 -1
  678. package/dist/tracers/console.js +6 -8
  679. package/dist/tracers/console.js.map +1 -1
  680. package/dist/tracers/event_stream.cjs +2 -4
  681. package/dist/tracers/event_stream.cjs.map +1 -1
  682. package/dist/tracers/event_stream.d.cts +2 -5
  683. package/dist/tracers/event_stream.d.cts.map +1 -1
  684. package/dist/tracers/event_stream.d.ts +2 -5
  685. package/dist/tracers/event_stream.d.ts.map +1 -1
  686. package/dist/tracers/event_stream.js +2 -4
  687. package/dist/tracers/event_stream.js.map +1 -1
  688. package/dist/tracers/log_stream.cjs +5 -5
  689. package/dist/tracers/log_stream.cjs.map +1 -1
  690. package/dist/tracers/log_stream.d.cts +14 -31
  691. package/dist/tracers/log_stream.d.cts.map +1 -1
  692. package/dist/tracers/log_stream.d.ts +14 -31
  693. package/dist/tracers/log_stream.d.ts.map +1 -1
  694. package/dist/tracers/log_stream.js +4 -5
  695. package/dist/tracers/log_stream.js.map +1 -1
  696. package/dist/tracers/root_listener.cjs.map +1 -1
  697. package/dist/tracers/root_listener.js.map +1 -1
  698. package/dist/tracers/run_collector.cjs +3 -3
  699. package/dist/tracers/run_collector.cjs.map +1 -1
  700. package/dist/tracers/run_collector.d.cts +0 -1
  701. package/dist/tracers/run_collector.d.cts.map +1 -1
  702. package/dist/tracers/run_collector.d.ts +0 -1
  703. package/dist/tracers/run_collector.d.ts.map +1 -1
  704. package/dist/tracers/run_collector.js +2 -3
  705. package/dist/tracers/run_collector.js.map +1 -1
  706. package/dist/tracers/tracer_langchain.cjs +8 -11
  707. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  708. package/dist/tracers/tracer_langchain.d.cts +8 -8
  709. package/dist/tracers/tracer_langchain.d.cts.map +1 -1
  710. package/dist/tracers/tracer_langchain.d.ts +8 -8
  711. package/dist/tracers/tracer_langchain.d.ts.map +1 -1
  712. package/dist/tracers/tracer_langchain.js +5 -9
  713. package/dist/tracers/tracer_langchain.js.map +1 -1
  714. package/dist/types/_internal.d.cts.map +1 -1
  715. package/dist/types/_internal.d.ts.map +1 -1
  716. package/dist/types/stream.cjs +3 -1
  717. package/dist/types/stream.js +3 -1
  718. package/dist/types/type-utils.d.cts.map +1 -1
  719. package/dist/types/type-utils.d.ts.map +1 -1
  720. package/dist/utils/async_caller.cjs +8 -9
  721. package/dist/utils/async_caller.cjs.map +1 -1
  722. package/dist/utils/async_caller.d.cts.map +1 -1
  723. package/dist/utils/async_caller.d.ts.map +1 -1
  724. package/dist/utils/async_caller.js +5 -8
  725. package/dist/utils/async_caller.js.map +1 -1
  726. package/dist/utils/callbacks.cjs +2 -3
  727. package/dist/utils/callbacks.cjs.map +1 -1
  728. package/dist/utils/callbacks.js +2 -3
  729. package/dist/utils/callbacks.js.map +1 -1
  730. package/dist/utils/chunk_array.cjs +4 -5
  731. package/dist/utils/chunk_array.cjs.map +1 -1
  732. package/dist/utils/chunk_array.d.cts.map +1 -1
  733. package/dist/utils/chunk_array.d.ts.map +1 -1
  734. package/dist/utils/chunk_array.js +3 -5
  735. package/dist/utils/chunk_array.js.map +1 -1
  736. package/dist/utils/context.cjs +4 -5
  737. package/dist/utils/context.cjs.map +1 -1
  738. package/dist/utils/context.d.cts.map +1 -1
  739. package/dist/utils/context.d.ts.map +1 -1
  740. package/dist/utils/context.js +3 -5
  741. package/dist/utils/context.js.map +1 -1
  742. package/dist/utils/env.cjs +9 -12
  743. package/dist/utils/env.cjs.map +1 -1
  744. package/dist/utils/env.d.cts.map +1 -1
  745. package/dist/utils/env.d.ts.map +1 -1
  746. package/dist/utils/env.js +8 -12
  747. package/dist/utils/env.js.map +1 -1
  748. package/dist/utils/event_source_parse.cjs +9 -9
  749. package/dist/utils/event_source_parse.cjs.map +1 -1
  750. package/dist/utils/event_source_parse.d.cts.map +1 -1
  751. package/dist/utils/event_source_parse.d.ts.map +1 -1
  752. package/dist/utils/event_source_parse.js +8 -9
  753. package/dist/utils/event_source_parse.js.map +1 -1
  754. package/dist/utils/fast-json-patch/index.cjs +3 -0
  755. package/dist/utils/fast-json-patch/index.cjs.map +1 -1
  756. package/dist/utils/fast-json-patch/index.js +4 -0
  757. package/dist/utils/fast-json-patch/index.js.map +1 -1
  758. package/dist/utils/fast-json-patch/src/core.cjs +6 -10
  759. package/dist/utils/fast-json-patch/src/core.cjs.map +1 -1
  760. package/dist/utils/fast-json-patch/src/core.d.cts +0 -1
  761. package/dist/utils/fast-json-patch/src/core.d.cts.map +1 -1
  762. package/dist/utils/fast-json-patch/src/core.d.ts +0 -1
  763. package/dist/utils/fast-json-patch/src/core.d.ts.map +1 -1
  764. package/dist/utils/fast-json-patch/src/core.js +6 -10
  765. package/dist/utils/fast-json-patch/src/core.js.map +1 -1
  766. package/dist/utils/fast-json-patch/src/duplex.cjs +5 -3
  767. package/dist/utils/fast-json-patch/src/duplex.cjs.map +1 -1
  768. package/dist/utils/fast-json-patch/src/duplex.d.cts +0 -1
  769. package/dist/utils/fast-json-patch/src/duplex.d.cts.map +1 -1
  770. package/dist/utils/fast-json-patch/src/duplex.d.ts +0 -1
  771. package/dist/utils/fast-json-patch/src/duplex.d.ts.map +1 -1
  772. package/dist/utils/fast-json-patch/src/duplex.js +5 -3
  773. package/dist/utils/fast-json-patch/src/duplex.js.map +1 -1
  774. package/dist/utils/fast-json-patch/src/helpers.cjs +4 -4
  775. package/dist/utils/fast-json-patch/src/helpers.cjs.map +1 -1
  776. package/dist/utils/fast-json-patch/src/helpers.js +4 -4
  777. package/dist/utils/fast-json-patch/src/helpers.js.map +1 -1
  778. package/dist/utils/format.cjs +3 -1
  779. package/dist/utils/format.d.cts.map +1 -1
  780. package/dist/utils/format.d.ts.map +1 -1
  781. package/dist/utils/format.js +3 -1
  782. package/dist/utils/function_calling.cjs +3 -3
  783. package/dist/utils/function_calling.cjs.map +1 -1
  784. package/dist/utils/function_calling.d.cts +0 -1
  785. package/dist/utils/function_calling.d.cts.map +1 -1
  786. package/dist/utils/function_calling.d.ts +0 -1
  787. package/dist/utils/function_calling.d.ts.map +1 -1
  788. package/dist/utils/function_calling.js +2 -3
  789. package/dist/utils/function_calling.js.map +1 -1
  790. package/dist/utils/hash.cjs +3 -3
  791. package/dist/utils/hash.d.cts +0 -1
  792. package/dist/utils/hash.d.cts.map +1 -1
  793. package/dist/utils/hash.d.ts +0 -1
  794. package/dist/utils/hash.d.ts.map +1 -1
  795. package/dist/utils/hash.js +2 -3
  796. package/dist/utils/is-network-error/index.cjs +2 -3
  797. package/dist/utils/is-network-error/index.cjs.map +1 -1
  798. package/dist/utils/is-network-error/index.js +2 -3
  799. package/dist/utils/is-network-error/index.js.map +1 -1
  800. package/dist/utils/js-sha256/hash.cjs +41 -34
  801. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  802. package/dist/utils/js-sha256/hash.d.cts.map +1 -1
  803. package/dist/utils/js-sha256/hash.d.ts.map +1 -1
  804. package/dist/utils/js-sha256/hash.js +41 -35
  805. package/dist/utils/js-sha256/hash.js.map +1 -1
  806. package/dist/utils/json.cjs.map +1 -1
  807. package/dist/utils/json.d.cts.map +1 -1
  808. package/dist/utils/json.d.ts.map +1 -1
  809. package/dist/utils/json.js.map +1 -1
  810. package/dist/utils/json_patch.cjs +3 -3
  811. package/dist/utils/json_patch.js +2 -3
  812. package/dist/utils/json_schema.cjs +12 -14
  813. package/dist/utils/json_schema.cjs.map +1 -1
  814. package/dist/utils/json_schema.d.cts.map +1 -1
  815. package/dist/utils/json_schema.d.ts.map +1 -1
  816. package/dist/utils/json_schema.js +4 -7
  817. package/dist/utils/json_schema.js.map +1 -1
  818. package/dist/utils/math.cjs +7 -8
  819. package/dist/utils/math.cjs.map +1 -1
  820. package/dist/utils/math.d.cts.map +1 -1
  821. package/dist/utils/math.d.ts.map +1 -1
  822. package/dist/utils/math.js +8 -10
  823. package/dist/utils/math.js.map +1 -1
  824. package/dist/utils/ml-distance/distances.cjs.map +1 -1
  825. package/dist/utils/ml-distance/distances.js.map +1 -1
  826. package/dist/utils/ml-distance/similarities.cjs.map +1 -1
  827. package/dist/utils/ml-distance/similarities.d.cts.map +1 -1
  828. package/dist/utils/ml-distance/similarities.d.ts.map +1 -1
  829. package/dist/utils/ml-distance/similarities.js.map +1 -1
  830. package/dist/utils/ml-distance-euclidean/euclidean.cjs.map +1 -1
  831. package/dist/utils/ml-distance-euclidean/euclidean.js.map +1 -1
  832. package/dist/utils/namespace.cjs +63 -0
  833. package/dist/utils/namespace.cjs.map +1 -0
  834. package/dist/utils/namespace.d.cts +73 -0
  835. package/dist/utils/namespace.d.cts.map +1 -0
  836. package/dist/utils/namespace.d.ts +73 -0
  837. package/dist/utils/namespace.d.ts.map +1 -0
  838. package/dist/utils/namespace.js +62 -0
  839. package/dist/utils/namespace.js.map +1 -0
  840. package/dist/utils/p-retry/index.cjs +2 -2
  841. package/dist/utils/p-retry/index.cjs.map +1 -1
  842. package/dist/utils/p-retry/index.js +2 -2
  843. package/dist/utils/p-retry/index.js.map +1 -1
  844. package/dist/utils/sax-js/sax.cjs +28 -34
  845. package/dist/utils/sax-js/sax.cjs.map +1 -1
  846. package/dist/utils/sax-js/sax.js +28 -34
  847. package/dist/utils/sax-js/sax.js.map +1 -1
  848. package/dist/utils/signal.cjs +1 -1
  849. package/dist/utils/signal.cjs.map +1 -1
  850. package/dist/utils/signal.d.cts.map +1 -1
  851. package/dist/utils/signal.d.ts.map +1 -1
  852. package/dist/utils/signal.js +1 -1
  853. package/dist/utils/signal.js.map +1 -1
  854. package/dist/utils/ssrf.cjs +8 -10
  855. package/dist/utils/ssrf.cjs.map +1 -1
  856. package/dist/utils/ssrf.d.cts.map +1 -1
  857. package/dist/utils/ssrf.d.ts.map +1 -1
  858. package/dist/utils/ssrf.js +7 -10
  859. package/dist/utils/ssrf.js.map +1 -1
  860. package/dist/utils/stream.cjs +4 -4
  861. package/dist/utils/stream.cjs.map +1 -1
  862. package/dist/utils/stream.d.cts.map +1 -1
  863. package/dist/utils/stream.d.ts.map +1 -1
  864. package/dist/utils/stream.js +3 -4
  865. package/dist/utils/stream.js.map +1 -1
  866. package/dist/utils/testing/chat_models.cjs +3 -5
  867. package/dist/utils/testing/chat_models.cjs.map +1 -1
  868. package/dist/utils/testing/chat_models.d.cts.map +1 -1
  869. package/dist/utils/testing/chat_models.d.ts.map +1 -1
  870. package/dist/utils/testing/chat_models.js +3 -5
  871. package/dist/utils/testing/chat_models.js.map +1 -1
  872. package/dist/utils/testing/embeddings.cjs +2 -4
  873. package/dist/utils/testing/embeddings.cjs.map +1 -1
  874. package/dist/utils/testing/embeddings.d.cts +0 -1
  875. package/dist/utils/testing/embeddings.d.cts.map +1 -1
  876. package/dist/utils/testing/embeddings.d.ts +0 -1
  877. package/dist/utils/testing/embeddings.d.ts.map +1 -1
  878. package/dist/utils/testing/embeddings.js +2 -4
  879. package/dist/utils/testing/embeddings.js.map +1 -1
  880. package/dist/utils/testing/index.cjs +3 -3
  881. package/dist/utils/testing/index.js +2 -3
  882. package/dist/utils/testing/llms.cjs.map +1 -1
  883. package/dist/utils/testing/llms.d.cts.map +1 -1
  884. package/dist/utils/testing/llms.d.ts.map +1 -1
  885. package/dist/utils/testing/llms.js.map +1 -1
  886. package/dist/utils/testing/message_history.cjs +1 -1
  887. package/dist/utils/testing/message_history.cjs.map +1 -1
  888. package/dist/utils/testing/message_history.d.cts.map +1 -1
  889. package/dist/utils/testing/message_history.d.ts.map +1 -1
  890. package/dist/utils/testing/message_history.js +1 -1
  891. package/dist/utils/testing/message_history.js.map +1 -1
  892. package/dist/utils/testing/output_parsers.cjs.map +1 -1
  893. package/dist/utils/testing/output_parsers.d.cts +0 -1
  894. package/dist/utils/testing/output_parsers.d.cts.map +1 -1
  895. package/dist/utils/testing/output_parsers.d.ts +0 -1
  896. package/dist/utils/testing/output_parsers.d.ts.map +1 -1
  897. package/dist/utils/testing/output_parsers.js.map +1 -1
  898. package/dist/utils/testing/retrievers.cjs +1 -1
  899. package/dist/utils/testing/retrievers.cjs.map +1 -1
  900. package/dist/utils/testing/retrievers.d.cts.map +1 -1
  901. package/dist/utils/testing/retrievers.d.ts.map +1 -1
  902. package/dist/utils/testing/retrievers.js +1 -1
  903. package/dist/utils/testing/retrievers.js.map +1 -1
  904. package/dist/utils/testing/runnables.cjs.map +1 -1
  905. package/dist/utils/testing/runnables.d.cts.map +1 -1
  906. package/dist/utils/testing/runnables.d.ts.map +1 -1
  907. package/dist/utils/testing/runnables.js.map +1 -1
  908. package/dist/utils/testing/tools.cjs.map +1 -1
  909. package/dist/utils/testing/tools.d.cts.map +1 -1
  910. package/dist/utils/testing/tools.d.ts.map +1 -1
  911. package/dist/utils/testing/tools.js.map +1 -1
  912. package/dist/utils/testing/tracers.cjs.map +1 -1
  913. package/dist/utils/testing/tracers.d.cts.map +1 -1
  914. package/dist/utils/testing/tracers.d.ts.map +1 -1
  915. package/dist/utils/testing/tracers.js.map +1 -1
  916. package/dist/utils/testing/vectorstores.cjs +7 -11
  917. package/dist/utils/testing/vectorstores.cjs.map +1 -1
  918. package/dist/utils/testing/vectorstores.d.cts +0 -1
  919. package/dist/utils/testing/vectorstores.d.cts.map +1 -1
  920. package/dist/utils/testing/vectorstores.d.ts +0 -1
  921. package/dist/utils/testing/vectorstores.d.ts.map +1 -1
  922. package/dist/utils/testing/vectorstores.js +7 -11
  923. package/dist/utils/testing/vectorstores.js.map +1 -1
  924. package/dist/utils/tiktoken.cjs +4 -4
  925. package/dist/utils/tiktoken.cjs.map +1 -1
  926. package/dist/utils/tiktoken.d.cts.map +1 -1
  927. package/dist/utils/tiktoken.d.ts.map +1 -1
  928. package/dist/utils/tiktoken.js +2 -3
  929. package/dist/utils/tiktoken.js.map +1 -1
  930. package/dist/utils/types/index.cjs +3 -3
  931. package/dist/utils/types/index.d.cts +0 -1
  932. package/dist/utils/types/index.d.cts.map +1 -1
  933. package/dist/utils/types/index.d.ts +0 -1
  934. package/dist/utils/types/index.d.ts.map +1 -1
  935. package/dist/utils/types/index.js +2 -3
  936. package/dist/utils/types/zod.cjs +17 -32
  937. package/dist/utils/types/zod.cjs.map +1 -1
  938. package/dist/utils/types/zod.d.cts +1 -1
  939. package/dist/utils/types/zod.d.cts.map +1 -1
  940. package/dist/utils/types/zod.d.ts +1 -1
  941. package/dist/utils/types/zod.d.ts.map +1 -1
  942. package/dist/utils/types/zod.js +15 -30
  943. package/dist/utils/types/zod.js.map +1 -1
  944. package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -1
  945. package/dist/utils/zod-to-json-schema/Options.js.map +1 -1
  946. package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -1
  947. package/dist/utils/zod-to-json-schema/Refs.js.map +1 -1
  948. package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -1
  949. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -1
  950. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -1
  951. package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -1
  952. package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -1
  953. package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -1
  954. package/dist/utils/zod-to-json-schema/index.js +2 -0
  955. package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -1
  956. package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -1
  957. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -1
  958. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -1
  959. package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -1
  960. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -1
  961. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -1
  962. package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -1
  963. package/dist/utils/zod-to-json-schema/parsers/array.cjs +2 -2
  964. package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -1
  965. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -1
  966. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -1
  967. package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -1
  968. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -1
  969. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -1
  970. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -1
  971. package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -1
  972. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -1
  973. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -1
  974. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -1
  975. package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -1
  976. package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -1
  977. package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -1
  978. package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -1
  979. package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -1
  980. package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -1
  981. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +0 -1
  982. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -1
  983. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -1
  984. package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -1
  985. package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -1
  986. package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -1
  987. package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -1
  988. package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -1
  989. package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -1
  990. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -1
  991. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -1
  992. package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -1
  993. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +1 -1
  994. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -1
  995. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -1
  996. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -1
  997. package/dist/utils/zod-to-json-schema/parsers/intersection.js +1 -1
  998. package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -1
  999. package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -1
  1000. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +0 -1
  1001. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -1
  1002. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -1
  1003. package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -1
  1004. package/dist/utils/zod-to-json-schema/parsers/map.cjs +17 -19
  1005. package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -1
  1006. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +0 -1
  1007. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -1
  1008. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -1
  1009. package/dist/utils/zod-to-json-schema/parsers/map.js +17 -19
  1010. package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -1
  1011. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +2 -3
  1012. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -1
  1013. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -1
  1014. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -1
  1015. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +2 -3
  1016. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -1
  1017. package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -1
  1018. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -1
  1019. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -1
  1020. package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -1
  1021. package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -1
  1022. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -1
  1023. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -1
  1024. package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -1
  1025. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +5 -5
  1026. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -1
  1027. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -1
  1028. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -1
  1029. package/dist/utils/zod-to-json-schema/parsers/nullable.js +5 -5
  1030. package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -1
  1031. package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -1
  1032. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -1
  1033. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -1
  1034. package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -1
  1035. package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -1
  1036. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -1
  1037. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -1
  1038. package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -1
  1039. package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -1
  1040. package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -1
  1041. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +2 -3
  1042. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -1
  1043. package/dist/utils/zod-to-json-schema/parsers/pipeline.js +2 -3
  1044. package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -1
  1045. package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -1
  1046. package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -1
  1047. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -1
  1048. package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -1
  1049. package/dist/utils/zod-to-json-schema/parsers/record.cjs +4 -4
  1050. package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -1
  1051. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -1
  1052. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -1
  1053. package/dist/utils/zod-to-json-schema/parsers/record.js +2 -2
  1054. package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -1
  1055. package/dist/utils/zod-to-json-schema/parsers/set.cjs +4 -5
  1056. package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -1
  1057. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -1
  1058. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -1
  1059. package/dist/utils/zod-to-json-schema/parsers/set.js +4 -5
  1060. package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -1
  1061. package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -1
  1062. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +0 -1
  1063. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -1
  1064. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +0 -1
  1065. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -1
  1066. package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -1
  1067. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -1
  1068. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -1
  1069. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -1
  1070. package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -1
  1071. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -1
  1072. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -1
  1073. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -1
  1074. package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -1
  1075. package/dist/utils/zod-to-json-schema/parsers/union.cjs +3 -6
  1076. package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -1
  1077. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -1
  1078. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -1
  1079. package/dist/utils/zod-to-json-schema/parsers/union.js +3 -6
  1080. package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -1
  1081. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -1
  1082. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -1
  1083. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -1
  1084. package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -1
  1085. package/dist/utils/zod-to-json-schema/selectParser.cjs +3 -3
  1086. package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -1
  1087. package/dist/utils/zod-to-json-schema/selectParser.js +1 -1
  1088. package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -1
  1089. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +3 -3
  1090. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -1
  1091. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +3 -3
  1092. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -1
  1093. package/dist/vectorstores.cjs +4 -5
  1094. package/dist/vectorstores.cjs.map +1 -1
  1095. package/dist/vectorstores.d.cts +0 -1
  1096. package/dist/vectorstores.d.cts.map +1 -1
  1097. package/dist/vectorstores.d.ts +0 -1
  1098. package/dist/vectorstores.d.ts.map +1 -1
  1099. package/dist/vectorstores.js +3 -5
  1100. package/dist/vectorstores.js.map +1 -1
  1101. package/package.json +2 -2
  1102. package/dist/_virtual/rolldown_runtime.cjs +0 -32
  1103. package/dist/_virtual/rolldown_runtime.js +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":["AIMessage","AIMessageChunk","BaseMessageLike","BaseMessage","StoredMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","SystemMessage","SystemMessageChunk","InvalidToolCall","ToolCall","ToolCallChunk","ToolMessage","$Expand","T","U","K","$KnownKeys","$HasIndexSignature","$OnlyIndexSignatures","$MergeObjects","Record","$MergeDiscriminatedUnion","A","B","Key","PropertyKey","Extract","Constructor","iife","coerceMessageLikeToMessage","getBufferString","mapStoredMessageToChatMessage","__message_js0","MessageToolSet","MessageStructure","mapStoredMessagesToChatMessages","mapChatMessagesToStoredMessages","convertToChunk","collapseToolCallChunks"],"sources":["../../src/messages/utils.d.ts"],"sourcesContent":["import { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessageLike, BaseMessage, StoredMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage } from \"./tool.js\";\nexport type $Expand<T> = T extends infer U ? {\n [K in keyof U]: U[K];\n} : never;\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : symbol extends K ? never : K;\n}[keyof T];\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T ? true : number extends keyof T ? true : symbol extends keyof T ? true : false;\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> = $HasIndexSignature<T> extends true ? [$KnownKeys<T>] extends [never] ? true : false : false;\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> = $OnlyIndexSignatures<U> extends true ? U : $OnlyIndexSignatures<T> extends true ? U : {\n [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends Record<string, unknown> ? U[K] extends Record<string, unknown> ? $MergeObjects<T[K], U[K]> : U[K] : U[K] : T[K] : K extends keyof U ? U[K] : never;\n};\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = \"type\"> = {\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [\n Extract<A, Record<Key, T>>\n ] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n}[A[Key] | B[Key]];\nexport type Constructor<T> = new (...args: unknown[]) => T;\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseMessage;\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n *\n * Produces compact output like:\n * ```\n * Human: What's the weather?\n * AI: Let me check...[tool_calls]\n * Tool: 72°F and sunny\n * ```\n *\n * This avoids token inflation from metadata when stringifying message objects directly.\n */\nexport declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;\nexport declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ChatMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | FunctionMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | HumanMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | SystemMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ToolMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>>;\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): BaseMessage[];\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];\nexport declare function convertToChunk(message: BaseMessage): AIMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ChatMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | FunctionMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | HumanMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | SystemMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>>;\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport declare function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n};\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;KAOYiB,eAAaC,oCACTC,IAAIA,EAAEC;AADtB;;;;;AACuB;AACb,KAOLC,UAAAA,CAAAA,GAAU,CAAA,GAAA,QACCH,MAAAA,GAAAA,GAAAA,MAAAA,SAAmBE,CAAnBF,GAAAA,KAAAA,GAAAA,MAAAA,SAA8CE,CAA9CF,GAAAA,KAAAA,GAAAA,MAAAA,SAAyEE,CAAzEF,GAAAA,KAAAA,GAAqFE,CAArFF,EAAmBE,CAAAA,MAC3BF,GAD2BE,CAAAA;;;;;AAC1B;AAAA;KAOJE,kBAA6CJ,CAAAA,GAAAA,CAAAA,GAAAA,MAAAA,SAAAA,MAAAA,GAAAA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgCA,GAAhCA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgEA,GAAhEA,GAAAA,IAAAA,GAAAA,KAAAA;;;AAAiE;AAAA;;;KAO9GK,oBAA2EL,CAAAA,GAAAA,CAAAA,GAAjDI,kBAAiDJ,CAA9BA,GAA8BA,CAAAA,SAAAA,IAAAA,GAAAA,CAAXG,UAAWH,CAAAA,GAAAA,CAAAA,CAAAA,SAAAA,CAAAA,KAAAA,CAAAA,GAAAA,IAAAA,GAAAA,KAAAA,GAAAA,KAAAA;;AAAD;AAkC/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACqNC,KADzMK,aACyML,CAAAA,GAAAA,EAAAA,GAAAA,CAAAA,GADnLI,oBACmLJ,CAD9JA,GAC8JA,CAAAA,SAAAA,IAAAA,GAD5IA,GAC4IA,GADxII,oBACwIJ,CADnHD,GACmHC,CAAAA,SAAAA,IAAAA,GADjGA,GACiGA,GAAAA,QA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A,CAAA,gBAAA,CAAA,cAAA;;;;;;;;;iBAsCpD,+BAAA,CACd,QAAA,EAAU,aAAA,KACT,WAAA;;;;;;;iBAUa,+BAAA,CACd,QAAA,EAAU,WAAA,KACT,aAAA;AAAA,iBAIa,cAAA,CAAe,OAAA,EAAS,WAAA,GAAW,cAAA,CAAA,gBAAA,CAAA,cAAA,KAAA,gBAAA,CAAA,gBAAA,CAAA,cAAA,KAAA,oBAAA,CAAA,gBAAA,CAAA,cAAA,KAAA,iBAAA,CAAA,gBAAA,CAAA,cAAA,KAAA,kBAAA,CAAA,gBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyDnC,sBAAA,CAAuB,MAAA,EAAQ,aAAA;EAC7C,gBAAA,EAAkB,aAAA;EAClB,UAAA,EAAY,QAAA;EACZ,kBAAA,EAAoB,eAAA;AAAA"}
@@ -1,14 +1,14 @@
1
- import { _isMessageFieldWithRole, isBaseMessage } from "./base.js";
2
- import { ToolMessage } from "./tool.js";
3
1
  import { addLangChainErrorFields } from "../errors/index.js";
4
2
  import { _isToolCall } from "../tools/utils.js";
5
3
  import { parsePartialJson } from "../utils/json.js";
4
+ import { _isMessageFieldWithRole, isBaseMessage } from "./base.js";
5
+ import { ToolMessage } from "./tool.js";
6
+ import { AIMessage, AIMessageChunk } from "./ai.js";
6
7
  import { ChatMessage, ChatMessageChunk } from "./chat.js";
7
8
  import { FunctionMessage, FunctionMessageChunk } from "./function.js";
8
9
  import { HumanMessage, HumanMessageChunk } from "./human.js";
9
10
  import { RemoveMessage } from "./modifier.js";
10
11
  import { SystemMessage, SystemMessageChunk } from "./system.js";
11
- import { AIMessage, AIMessageChunk } from "./ai.js";
12
12
 
13
13
  //#region src/messages/utils.ts
14
14
  /**
@@ -44,13 +44,13 @@ function _constructMessageFromParams(params) {
44
44
  else type = "unknown";
45
45
  rest = params.kwargs;
46
46
  } else {
47
- const { type: extractedType,...otherParams } = params;
47
+ const { type: extractedType, ...otherParams } = params;
48
48
  type = extractedType;
49
49
  rest = otherParams;
50
50
  }
51
51
  if (type === "human" || type === "user") return new HumanMessage(rest);
52
52
  else if (type === "ai" || type === "assistant") {
53
- const { tool_calls: rawToolCalls,...other } = rest;
53
+ const { tool_calls: rawToolCalls, ...other } = rest;
54
54
  if (!Array.isArray(rawToolCalls)) return new AIMessage(rest);
55
55
  const tool_calls = rawToolCalls.map(_coerceToolCall);
56
56
  return new AIMessage({
@@ -75,10 +75,7 @@ function _constructMessageFromParams(params) {
75
75
  ...rest,
76
76
  id: rest.id
77
77
  });
78
- else {
79
- const error = addLangChainErrorFields(/* @__PURE__ */ new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.\n\nReceived: ${JSON.stringify(params, null, 2)}`), "MESSAGE_COERCION_FAILURE");
80
- throw error;
81
- }
78
+ else throw addLangChainErrorFields(/* @__PURE__ */ new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.\n\nReceived: ${JSON.stringify(params, null, 2)}`), "MESSAGE_COERCION_FAILURE");
82
79
  }
83
80
  function coerceMessageLikeToMessage(messageLike) {
84
81
  if (typeof messageLike === "string") return new HumanMessage(messageLike);
@@ -90,7 +87,7 @@ function coerceMessageLikeToMessage(messageLike) {
90
87
  content
91
88
  });
92
89
  } else if (_isMessageFieldWithRole(messageLike)) {
93
- const { role: type,...rest } = messageLike;
90
+ const { role: type, ...rest } = messageLike;
94
91
  return _constructMessageFromParams({
95
92
  ...rest,
96
93
  type
@@ -252,12 +249,12 @@ function collapseToolCallChunks(chunks) {
252
249
  }, []);
253
250
  const toolCalls = [];
254
251
  const invalidToolCalls = [];
255
- for (const chunks$1 of groupedToolCallChunks) {
252
+ for (const chunks of groupedToolCallChunks) {
256
253
  let parsedArgs = null;
257
- const name = chunks$1[0]?.name ?? "";
258
- const joinedArgs = chunks$1.map((c) => c.args || "").join("").trim();
254
+ const name = chunks[0]?.name ?? "";
255
+ const joinedArgs = chunks.map((c) => c.args || "").join("").trim();
259
256
  const argsStr = joinedArgs.length ? joinedArgs : "{}";
260
- const id = chunks$1[0]?.id;
257
+ const id = chunks[0]?.id;
261
258
  try {
262
259
  parsedArgs = parsePartialJson(argsStr);
263
260
  if (!id || parsedArgs === null || typeof parsedArgs !== "object" || Array.isArray(parsedArgs)) throw new Error("Malformed tool call chunk args.");
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["fn: () => T","toolCall: ToolCall | Record<string, unknown>","x: unknown","params:\n | (BaseMessageFields & { type: string } & Record<string, unknown>)\n | SerializedConstructor","type: string","rest: BaseMessageFields & Record<string, unknown>","messageLike: BaseMessageLike","messages: BaseMessage[]","string_messages: string[]","role: string","message: StoredMessage | StoredMessageV1","message: StoredMessage","messages: StoredMessage[]","message: BaseMessage","aiChunkFields: AIMessageChunkFields","chunks: ToolCallChunk[]","toolCalls: ToolCall[]","invalidToolCalls: InvalidToolCall[]","chunks","parsedArgs: Record<string, unknown> | null"],"sources":["../../src/messages/utils.ts"],"sourcesContent":["import { addLangChainErrorFields } from \"../errors/index.js\";\nimport { SerializedConstructor } from \"../load/serializable.js\";\nimport { _isToolCall } from \"../tools/utils.js\";\nimport { parsePartialJson } from \"../utils/json.js\";\nimport { AIMessage, AIMessageChunk, AIMessageChunkFields } from \"./ai.js\";\nimport {\n BaseMessageLike,\n BaseMessage,\n isBaseMessage,\n StoredMessage,\n StoredMessageV1,\n BaseMessageFields,\n _isMessageFieldWithRole,\n} from \"./base.js\";\nimport { ChatMessage, ChatMessageFields, ChatMessageChunk } from \"./chat.js\";\nimport {\n FunctionMessage,\n FunctionMessageChunk,\n FunctionMessageFields,\n} from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { RemoveMessage } from \"./modifier.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport {\n InvalidToolCall,\n ToolCall,\n ToolCallChunk,\n ToolMessage,\n ToolMessageFields,\n} from \"./tool.js\";\n\nexport type $Expand<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\n\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K\n ? never\n : number extends K\n ? never\n : symbol extends K\n ? never\n : K;\n}[keyof T];\n\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T\n ? true\n : number extends keyof T\n ? true\n : symbol extends keyof T\n ? true\n : false;\n\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> =\n $HasIndexSignature<T> extends true\n ? [$KnownKeys<T>] extends [never]\n ? true\n : false\n : false;\n\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> =\n // If U is purely index-signature based, prefer U as a whole\n $OnlyIndexSignatures<U> extends true\n ? U\n : // If T is purely index-signature based, prefer U as a whole (prevents leaking broad index signatures)\n $OnlyIndexSignatures<T> extends true\n ? U\n : {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? T[K] extends Record<string, unknown>\n ? U[K] extends Record<string, unknown>\n ? $MergeObjects<T[K], U[K]>\n : U[K]\n : U[K]\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n };\n\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<\n A extends Record<Key, PropertyKey>,\n B extends Record<Key, PropertyKey>,\n Key extends PropertyKey = \"type\",\n> = {\n // Create a mapped type over all possible discriminator values from both A and B\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] // Check if B has a member with this discriminator value\n ? // If B doesn't have this discriminator value, use A's member\n Extract<A, Record<Key, T>>\n : // If B does have this discriminator value, merge A's and B's members (B takes precedence)\n [Extract<A, Record<Key, T>>] extends [never]\n ? Extract<B, Record<Key, T>>\n : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n // Index into the mapped type with all possible discriminator values\n // This converts the mapped type back into a union\n}[A[Key] | B[Key]];\n\nexport type Constructor<T> = new (...args: unknown[]) => T;\n\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport const iife = <T>(fn: () => T) => fn();\n\nfunction _coerceToolCall(\n toolCall: ToolCall | Record<string, unknown>\n): ToolCall {\n if (_isToolCall(toolCall)) {\n return toolCall;\n } else if (\n typeof toolCall.id === \"string\" &&\n toolCall.type === \"function\" &&\n typeof toolCall.function === \"object\" &&\n toolCall.function !== null &&\n \"arguments\" in toolCall.function &&\n typeof toolCall.function.arguments === \"string\" &&\n \"name\" in toolCall.function &&\n typeof toolCall.function.name === \"string\"\n ) {\n // Handle OpenAI tool call format\n return {\n id: toolCall.id,\n args: JSON.parse(toolCall.function.arguments),\n name: toolCall.function.name,\n type: \"tool_call\",\n };\n } else {\n // TODO: Throw an error?\n return toolCall as unknown as ToolCall;\n }\n}\n\nfunction isSerializedConstructor(x: unknown): x is SerializedConstructor {\n return (\n typeof x === \"object\" &&\n x != null &&\n (x as SerializedConstructor).lc === 1 &&\n Array.isArray((x as SerializedConstructor).id) &&\n (x as SerializedConstructor).kwargs != null &&\n typeof (x as SerializedConstructor).kwargs === \"object\"\n );\n}\n\nfunction _constructMessageFromParams(\n params:\n | (BaseMessageFields & { type: string } & Record<string, unknown>)\n | SerializedConstructor\n) {\n let type: string;\n let rest: BaseMessageFields & Record<string, unknown>;\n // Support serialized messages\n if (isSerializedConstructor(params)) {\n const className = params.id.at(-1);\n if (className === \"HumanMessage\" || className === \"HumanMessageChunk\") {\n type = \"user\";\n } else if (className === \"AIMessage\" || className === \"AIMessageChunk\") {\n type = \"assistant\";\n } else if (\n className === \"SystemMessage\" ||\n className === \"SystemMessageChunk\"\n ) {\n type = \"system\";\n } else if (\n className === \"FunctionMessage\" ||\n className === \"FunctionMessageChunk\"\n ) {\n type = \"function\";\n } else if (\n className === \"ToolMessage\" ||\n className === \"ToolMessageChunk\"\n ) {\n type = \"tool\";\n } else {\n type = \"unknown\";\n }\n rest = params.kwargs as BaseMessageFields;\n } else {\n const { type: extractedType, ...otherParams } = params;\n type = extractedType;\n rest = otherParams;\n }\n if (type === \"human\" || type === \"user\") {\n return new HumanMessage(rest);\n } else if (type === \"ai\" || type === \"assistant\") {\n const { tool_calls: rawToolCalls, ...other } = rest;\n if (!Array.isArray(rawToolCalls)) {\n return new AIMessage(rest);\n }\n const tool_calls = rawToolCalls.map(_coerceToolCall);\n return new AIMessage({ ...other, tool_calls });\n } else if (type === \"system\") {\n return new SystemMessage(rest);\n } else if (type === \"developer\") {\n return new SystemMessage({\n ...rest,\n additional_kwargs: {\n ...rest.additional_kwargs,\n __openai_role__: \"developer\",\n },\n });\n } else if (type === \"tool\" && \"tool_call_id\" in rest) {\n return new ToolMessage({\n ...rest,\n content: rest.content,\n tool_call_id: rest.tool_call_id as string,\n name: rest.name,\n });\n } else if (type === \"remove\" && \"id\" in rest && typeof rest.id === \"string\") {\n return new RemoveMessage({ ...rest, id: rest.id });\n } else {\n const error = addLangChainErrorFields(\n new Error(\n `Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.\\n\\nReceived: ${JSON.stringify(\n params,\n null,\n 2\n )}`\n ),\n \"MESSAGE_COERCION_FAILURE\"\n );\n throw error;\n }\n}\n\nexport function coerceMessageLikeToMessage(\n messageLike: BaseMessageLike\n): BaseMessage {\n if (typeof messageLike === \"string\") {\n return new HumanMessage(messageLike);\n } else if (isBaseMessage(messageLike)) {\n return messageLike;\n }\n if (Array.isArray(messageLike)) {\n const [type, content] = messageLike;\n return _constructMessageFromParams({ type, content });\n } else if (_isMessageFieldWithRole(messageLike)) {\n const { role: type, ...rest } = messageLike;\n return _constructMessageFromParams({ ...rest, type });\n } else {\n return _constructMessageFromParams(messageLike);\n }\n}\n\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n *\n * Produces compact output like:\n * ```\n * Human: What's the weather?\n * AI: Let me check...[tool_calls]\n * Tool: 72°F and sunny\n * ```\n *\n * This avoids token inflation from metadata when stringifying message objects directly.\n */\nexport function getBufferString(\n messages: BaseMessage[],\n humanPrefix = \"Human\",\n aiPrefix = \"AI\"\n): string {\n const string_messages: string[] = [];\n for (const m of messages) {\n let role: string;\n if (m.type === \"human\") {\n role = humanPrefix;\n } else if (m.type === \"ai\") {\n role = aiPrefix;\n } else if (m.type === \"system\") {\n role = \"System\";\n } else if (m.type === \"tool\") {\n role = \"Tool\";\n } else if (m.type === \"generic\") {\n role = (m as ChatMessage).role;\n } else {\n throw new Error(`Got unsupported message type: ${m.type}`);\n }\n const nameStr = m.name ? `${m.name}, ` : \"\";\n\n // Use m.text property which extracts only text content, avoiding metadata\n // For non-string content (e.g., content blocks), m.text extracts only text blocks\n const readableContent = m.text;\n\n let message = `${role}: ${nameStr}${readableContent}`;\n\n // Include tool calls for AI messages (matching Python's get_buffer_string behavior)\n if (m.type === \"ai\") {\n const aiMessage = m as AIMessage;\n if (aiMessage.tool_calls && aiMessage.tool_calls.length > 0) {\n message += JSON.stringify(aiMessage.tool_calls);\n } else if (\n aiMessage.additional_kwargs &&\n \"function_call\" in aiMessage.additional_kwargs\n ) {\n // Legacy behavior assumes only one function call per message\n message += JSON.stringify(aiMessage.additional_kwargs.function_call);\n }\n }\n\n string_messages.push(message);\n }\n return string_messages.join(\"\\n\");\n}\n\n/**\n * Maps messages from an older format (V1) to the current `StoredMessage`\n * format. If the message is already in the `StoredMessage` format, it is\n * returned as is. Otherwise, it transforms the V1 message into a\n * `StoredMessage`. This function is important for maintaining\n * compatibility with older message formats.\n */\nfunction mapV1MessageToStoredMessage(\n message: StoredMessage | StoredMessageV1\n): StoredMessage {\n // TODO: Remove this mapper when we deprecate the old message format.\n if ((message as StoredMessage).data !== undefined) {\n return message as StoredMessage;\n } else {\n const v1Message = message as StoredMessageV1;\n return {\n type: v1Message.type,\n data: {\n content: v1Message.text,\n role: v1Message.role,\n name: undefined,\n tool_call_id: undefined,\n },\n };\n }\n}\n\nexport function mapStoredMessageToChatMessage(message: StoredMessage) {\n const storedMessage = mapV1MessageToStoredMessage(message);\n switch (storedMessage.type) {\n case \"human\":\n return new HumanMessage(storedMessage.data);\n case \"ai\":\n return new AIMessage(storedMessage.data);\n case \"system\":\n return new SystemMessage(storedMessage.data);\n case \"function\":\n if (storedMessage.data.name === undefined) {\n throw new Error(\"Name must be defined for function messages\");\n }\n return new FunctionMessage(storedMessage.data as FunctionMessageFields);\n case \"tool\":\n if (storedMessage.data.tool_call_id === undefined) {\n throw new Error(\"Tool call ID must be defined for tool messages\");\n }\n return new ToolMessage(storedMessage.data as ToolMessageFields);\n case \"generic\": {\n if (storedMessage.data.role === undefined) {\n throw new Error(\"Role must be defined for chat messages\");\n }\n return new ChatMessage(storedMessage.data as ChatMessageFields);\n }\n default:\n throw new Error(`Got unexpected type: ${storedMessage.type}`);\n }\n}\n\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport function mapStoredMessagesToChatMessages(\n messages: StoredMessage[]\n): BaseMessage[] {\n return messages.map(mapStoredMessageToChatMessage);\n}\n\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport function mapChatMessagesToStoredMessages(\n messages: BaseMessage[]\n): StoredMessage[] {\n return messages.map((message) => message.toDict());\n}\n\nexport function convertToChunk(message: BaseMessage) {\n const type = message._getType();\n if (type === \"human\") {\n return new HumanMessageChunk({ ...message });\n } else if (type === \"ai\") {\n let aiChunkFields: AIMessageChunkFields = {\n ...message,\n };\n if (\"tool_calls\" in aiChunkFields) {\n aiChunkFields = {\n ...aiChunkFields,\n tool_call_chunks: aiChunkFields.tool_calls?.map((tc) => ({\n ...tc,\n type: \"tool_call_chunk\",\n index: undefined,\n args: JSON.stringify(tc.args),\n })),\n };\n }\n return new AIMessageChunk({ ...aiChunkFields });\n } else if (type === \"system\") {\n return new SystemMessageChunk({ ...message });\n } else if (type === \"function\") {\n return new FunctionMessageChunk({ ...message });\n } else if (ChatMessage.isInstance(message)) {\n return new ChatMessageChunk({ ...message });\n } else {\n throw new Error(\"Unknown message type.\");\n }\n}\n\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n} {\n const groupedToolCallChunks = chunks.reduce((acc, chunk) => {\n const matchedChunkIndex = acc.findIndex(([match]) => {\n // If chunk has an id and index, match if both are present\n if (\n \"id\" in chunk &&\n chunk.id &&\n \"index\" in chunk &&\n chunk.index !== undefined\n ) {\n return chunk.id === match.id && chunk.index === match.index;\n }\n // If chunk has an id, we match on id\n if (\"id\" in chunk && chunk.id) {\n return chunk.id === match.id;\n }\n // If chunk has an index, we match on index\n if (\"index\" in chunk && chunk.index !== undefined) {\n return chunk.index === match.index;\n }\n return false;\n });\n if (matchedChunkIndex !== -1) {\n acc[matchedChunkIndex].push(chunk);\n } else {\n acc.push([chunk]);\n }\n return acc;\n }, [] as ToolCallChunk[][]);\n\n const toolCalls: ToolCall[] = [];\n const invalidToolCalls: InvalidToolCall[] = [];\n for (const chunks of groupedToolCallChunks) {\n let parsedArgs: Record<string, unknown> | null = null;\n const name = chunks[0]?.name ?? \"\";\n const joinedArgs = chunks\n .map((c) => c.args || \"\")\n .join(\"\")\n .trim();\n const argsStr = joinedArgs.length ? joinedArgs : \"{}\";\n const id = chunks[0]?.id;\n try {\n parsedArgs = parsePartialJson(argsStr);\n if (\n !id ||\n parsedArgs === null ||\n typeof parsedArgs !== \"object\" ||\n Array.isArray(parsedArgs)\n ) {\n throw new Error(\"Malformed tool call chunk args.\");\n }\n toolCalls.push({\n name,\n args: parsedArgs,\n id,\n type: \"tool_call\",\n });\n } catch {\n invalidToolCalls.push({\n name,\n args: argsStr,\n id,\n error: \"Malformed args.\",\n type: \"invalid_tool_call\",\n });\n }\n }\n return {\n tool_call_chunks: chunks,\n tool_calls: toolCalls,\n invalid_tool_calls: invalidToolCalls,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsKA,MAAa,OAAO,CAAIA,OAAgB,IAAI;AAE5C,SAAS,gBACPC,UACU;AACV,KAAI,YAAY,SAAS,CACvB,QAAO;UAEP,OAAO,SAAS,OAAO,YACvB,SAAS,SAAS,cAClB,OAAO,SAAS,aAAa,YAC7B,SAAS,aAAa,QACtB,eAAe,SAAS,YACxB,OAAO,SAAS,SAAS,cAAc,YACvC,UAAU,SAAS,YACnB,OAAO,SAAS,SAAS,SAAS,SAGlC,QAAO;EACL,IAAI,SAAS;EACb,MAAM,KAAK,MAAM,SAAS,SAAS,UAAU;EAC7C,MAAM,SAAS,SAAS;EACxB,MAAM;CACP;KAGD,QAAO;AAEV;AAED,SAAS,wBAAwBC,GAAwC;AACvE,QACE,OAAO,MAAM,YACb,KAAK,QACJ,EAA4B,OAAO,KACpC,MAAM,QAAS,EAA4B,GAAG,IAC7C,EAA4B,UAAU,QACvC,OAAQ,EAA4B,WAAW;AAElD;AAED,SAAS,4BACPC,QAGA;CACA,IAAIC;CACJ,IAAIC;AAEJ,KAAI,wBAAwB,OAAO,EAAE;EACnC,MAAM,YAAY,OAAO,GAAG,GAAG,GAAG;AAClC,MAAI,cAAc,kBAAkB,cAAc,qBAChD,OAAO;WACE,cAAc,eAAe,cAAc,kBACpD,OAAO;WAEP,cAAc,mBACd,cAAc,sBAEd,OAAO;WAEP,cAAc,qBACd,cAAc,wBAEd,OAAO;WAEP,cAAc,iBACd,c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names":[],"sources":["../../src/messages/utils.ts"],"sourcesContent":["import { addLangChainErrorFields } from \"../errors/index.js\";\nimport { SerializedConstructor } from \"../load/serializable.js\";\nimport { _isToolCall } from \"../tools/utils.js\";\nimport { parsePartialJson } from \"../utils/json.js\";\nimport { AIMessage, AIMessageChunk, AIMessageChunkFields } from \"./ai.js\";\nimport {\n BaseMessageLike,\n BaseMessage,\n isBaseMessage,\n StoredMessage,\n StoredMessageV1,\n BaseMessageFields,\n _isMessageFieldWithRole,\n} from \"./base.js\";\nimport { ChatMessage, ChatMessageFields, ChatMessageChunk } from \"./chat.js\";\nimport {\n FunctionMessage,\n FunctionMessageChunk,\n FunctionMessageFields,\n} from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { RemoveMessage } from \"./modifier.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport {\n InvalidToolCall,\n ToolCall,\n ToolCallChunk,\n ToolMessage,\n ToolMessageFields,\n} from \"./tool.js\";\n\nexport type $Expand<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\n\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K\n ? never\n : number extends K\n ? never\n : symbol extends K\n ? never\n : K;\n}[keyof T];\n\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T\n ? true\n : number extends keyof T\n ? true\n : symbol extends keyof T\n ? true\n : false;\n\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> =\n $HasIndexSignature<T> extends true\n ? [$KnownKeys<T>] extends [never]\n ? true\n : false\n : false;\n\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> =\n // If U is purely index-signature based, prefer U as a whole\n $OnlyIndexSignatures<U> extends true\n ? U\n : // If T is purely index-signature based, prefer U as a whole (prevents leaking broad index signatures)\n $OnlyIndexSignatures<T> extends true\n ? U\n : {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? T[K] extends Record<string, unknown>\n ? U[K] extends Record<string, unknown>\n ? $MergeObjects<T[K], U[K]>\n : U[K]\n : U[K]\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n };\n\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<\n A extends Record<Key, PropertyKey>,\n B extends Record<Key, PropertyKey>,\n Key extends PropertyKey = \"type\",\n> = {\n // Create a mapped type over all possible discriminator values from both A and B\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] // Check if B has a member with this discriminator value\n ? // If B doesn't have this discriminator value, use A's member\n Extract<A, Record<Key, T>>\n : // If B does have this discriminator value, merge A's and B's members (B takes precedence)\n [Extract<A, Record<Key, T>>] extends [never]\n ? Extract<B, Record<Key, T>>\n : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n // Index into the mapped type with all possible discriminator values\n // This converts the mapped type back into a union\n}[A[Key] | B[Key]];\n\nexport type Constructor<T> = new (...args: unknown[]) => T;\n\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport const iife = <T>(fn: () => T) => fn();\n\nfunction _coerceToolCall(\n toolCall: ToolCall | Record<string, unknown>\n): ToolCall {\n if (_isToolCall(toolCall)) {\n return toolCall;\n } else if (\n typeof toolCall.id === \"string\" &&\n toolCall.type === \"function\" &&\n typeof toolCall.function === \"object\" &&\n toolCall.function !== null &&\n \"arguments\" in toolCall.function &&\n typeof toolCall.function.arguments === \"string\" &&\n \"name\" in toolCall.function &&\n typeof toolCall.function.name === \"string\"\n ) {\n // Handle OpenAI tool call format\n return {\n id: toolCall.id,\n args: JSON.parse(toolCall.function.arguments),\n name: toolCall.function.name,\n type: \"tool_call\",\n };\n } else {\n // TODO: Throw an error?\n return toolCall as unknown as ToolCall;\n }\n}\n\nfunction isSerializedConstructor(x: unknown): x is SerializedConstructor {\n return (\n typeof x === \"object\" &&\n x != null &&\n (x as SerializedConstructor).lc === 1 &&\n Array.isArray((x as SerializedConstructor).id) &&\n (x as SerializedConstructor).kwargs != null &&\n typeof (x as SerializedConstructor).kwargs === \"object\"\n );\n}\n\nfunction _constructMessageFromParams(\n params:\n | (BaseMessageFields & { type: string } & Record<string, unknown>)\n | SerializedConstructor\n) {\n let type: string;\n let rest: BaseMessageFields & Record<string, unknown>;\n // Support serialized messages\n if (isSerializedConstructor(params)) {\n const className = params.id.at(-1);\n if (className === \"HumanMessage\" || className === \"HumanMessageChunk\") {\n type = \"user\";\n } else if (className === \"AIMessage\" || className === \"AIMessageChunk\") {\n type = \"assistant\";\n } else if (\n className === \"SystemMessage\" ||\n className === \"SystemMessageChunk\"\n ) {\n type = \"system\";\n } else if (\n className === \"FunctionMessage\" ||\n className === \"FunctionMessageChunk\"\n ) {\n type = \"function\";\n } else if (\n className === \"ToolMessage\" ||\n className === \"ToolMessageChunk\"\n ) {\n type = \"tool\";\n } else {\n type = \"unknown\";\n }\n rest = params.kwargs as BaseMessageFields;\n } else {\n const { type: extractedType, ...otherParams } = params;\n type = extractedType;\n rest = otherParams;\n }\n if (type === \"human\" || type === \"user\") {\n return new HumanMessage(rest);\n } else if (type === \"ai\" || type === \"assistant\") {\n const { tool_calls: rawToolCalls, ...other } = rest;\n if (!Array.isArray(rawToolCalls)) {\n return new AIMessage(rest);\n }\n const tool_calls = rawToolCalls.map(_coerceToolCall);\n return new AIMessage({ ...other, tool_calls });\n } else if (type === \"system\") {\n return new SystemMessage(rest);\n } else if (type === \"developer\") {\n return new SystemMessage({\n ...rest,\n additional_kwargs: {\n ...rest.additional_kwargs,\n __openai_role__: \"developer\",\n },\n });\n } else if (type === \"tool\" && \"tool_call_id\" in rest) {\n return new ToolMessage({\n ...rest,\n content: rest.content,\n tool_call_id: rest.tool_call_id as string,\n name: rest.name,\n });\n } else if (type === \"remove\" && \"id\" in rest && typeof rest.id === \"string\") {\n return new RemoveMessage({ ...rest, id: rest.id });\n } else {\n const error = addLangChainErrorFields(\n new Error(\n `Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.\\n\\nReceived: ${JSON.stringify(\n params,\n null,\n 2\n )}`\n ),\n \"MESSAGE_COERCION_FAILURE\"\n );\n throw error;\n }\n}\n\nexport function coerceMessageLikeToMessage(\n messageLike: BaseMessageLike\n): BaseMessage {\n if (typeof messageLike === \"string\") {\n return new HumanMessage(messageLike);\n } else if (isBaseMessage(messageLike)) {\n return messageLike;\n }\n if (Array.isArray(messageLike)) {\n const [type, content] = messageLike;\n return _constructMessageFromParams({ type, content });\n } else if (_isMessageFieldWithRole(messageLike)) {\n const { role: type, ...rest } = messageLike;\n return _constructMessageFromParams({ ...rest, type });\n } else {\n return _constructMessageFromParams(messageLike);\n }\n}\n\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n *\n * Produces compact output like:\n * ```\n * Human: What's the weather?\n * AI: Let me check...[tool_calls]\n * Tool: 72°F and sunny\n * ```\n *\n * This avoids token inflation from metadata when stringifying message objects directly.\n */\nexport function getBufferString(\n messages: BaseMessage[],\n humanPrefix = \"Human\",\n aiPrefix = \"AI\"\n): string {\n const string_messages: string[] = [];\n for (const m of messages) {\n let role: string;\n if (m.type === \"human\") {\n role = humanPrefix;\n } else if (m.type === \"ai\") {\n role = aiPrefix;\n } else if (m.type === \"system\") {\n role = \"System\";\n } else if (m.type === \"tool\") {\n role = \"Tool\";\n } else if (m.type === \"generic\") {\n role = (m as ChatMessage).role;\n } else {\n throw new Error(`Got unsupported message type: ${m.type}`);\n }\n const nameStr = m.name ? `${m.name}, ` : \"\";\n\n // Use m.text property which extracts only text content, avoiding metadata\n // For non-string content (e.g., content blocks), m.text extracts only text blocks\n const readableContent = m.text;\n\n let message = `${role}: ${nameStr}${readableContent}`;\n\n // Include tool calls for AI messages (matching Python's get_buffer_string behavior)\n if (m.type === \"ai\") {\n const aiMessage = m as AIMessage;\n if (aiMessage.tool_calls && aiMessage.tool_calls.length > 0) {\n message += JSON.stringify(aiMessage.tool_calls);\n } else if (\n aiMessage.additional_kwargs &&\n \"function_call\" in aiMessage.additional_kwargs\n ) {\n // Legacy behavior assumes only one function call per message\n message += JSON.stringify(aiMessage.additional_kwargs.function_call);\n }\n }\n\n string_messages.push(message);\n }\n return string_messages.join(\"\\n\");\n}\n\n/**\n * Maps messages from an older format (V1) to the current `StoredMessage`\n * format. If the message is already in the `StoredMessage` format, it is\n * returned as is. Otherwise, it transforms the V1 message into a\n * `StoredMessage`. This function is important for maintaining\n * compatibility with older message formats.\n */\nfunction mapV1MessageToStoredMessage(\n message: StoredMessage | StoredMessageV1\n): StoredMessage {\n // TODO: Remove this mapper when we deprecate the old message format.\n if ((message as StoredMessage).data !== undefined) {\n return message as StoredMessage;\n } else {\n const v1Message = message as StoredMessageV1;\n return {\n type: v1Message.type,\n data: {\n content: v1Message.text,\n role: v1Message.role,\n name: undefined,\n tool_call_id: undefined,\n },\n };\n }\n}\n\nexport function mapStoredMessageToChatMessage(message: StoredMessage) {\n const storedMessage = mapV1MessageToStoredMessage(message);\n switch (storedMessage.type) {\n case \"human\":\n return new HumanMessage(storedMessage.data);\n case \"ai\":\n return new AIMessage(storedMessage.data);\n case \"system\":\n return new SystemMessage(storedMessage.data);\n case \"function\":\n if (storedMessage.data.name === undefined) {\n throw new Error(\"Name must be defined for function messages\");\n }\n return new FunctionMessage(storedMessage.data as FunctionMessageFields);\n case \"tool\":\n if (storedMessage.data.tool_call_id === undefined) {\n throw new Error(\"Tool call ID must be defined for tool messages\");\n }\n return new ToolMessage(storedMessage.data as ToolMessageFields);\n case \"generic\": {\n if (storedMessage.data.role === undefined) {\n throw new Error(\"Role must be defined for chat messages\");\n }\n return new ChatMessage(storedMessage.data as ChatMessageFields);\n }\n default:\n throw new Error(`Got unexpected type: ${storedMessage.type}`);\n }\n}\n\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport function mapStoredMessagesToChatMessages(\n messages: StoredMessage[]\n): BaseMessage[] {\n return messages.map(mapStoredMessageToChatMessage);\n}\n\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport function mapChatMessagesToStoredMessages(\n messages: BaseMessage[]\n): StoredMessage[] {\n return messages.map((message) => message.toDict());\n}\n\nexport function convertToChunk(message: BaseMessage) {\n const type = message._getType();\n if (type === \"human\") {\n return new HumanMessageChunk({ ...message });\n } else if (type === \"ai\") {\n let aiChunkFields: AIMessageChunkFields = {\n ...message,\n };\n if (\"tool_calls\" in aiChunkFields) {\n aiChunkFields = {\n ...aiChunkFields,\n tool_call_chunks: aiChunkFields.tool_calls?.map((tc) => ({\n ...tc,\n type: \"tool_call_chunk\",\n index: undefined,\n args: JSON.stringify(tc.args),\n })),\n };\n }\n return new AIMessageChunk({ ...aiChunkFields });\n } else if (type === \"system\") {\n return new SystemMessageChunk({ ...message });\n } else if (type === \"function\") {\n return new FunctionMessageChunk({ ...message });\n } else if (ChatMessage.isInstance(message)) {\n return new ChatMessageChunk({ ...message });\n } else {\n throw new Error(\"Unknown message type.\");\n }\n}\n\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n} {\n const groupedToolCallChunks = chunks.reduce((acc, chunk) => {\n const matchedChunkIndex = acc.findIndex(([match]) => {\n // If chunk has an id and index, match if both are present\n if (\n \"id\" in chunk &&\n chunk.id &&\n \"index\" in chunk &&\n chunk.index !== undefined\n ) {\n return chunk.id === match.id && chunk.index === match.index;\n }\n // If chunk has an id, we match on id\n if (\"id\" in chunk && chunk.id) {\n return chunk.id === match.id;\n }\n // If chunk has an index, we match on index\n if (\"index\" in chunk && chunk.index !== undefined) {\n return chunk.index === match.index;\n }\n return false;\n });\n if (matchedChunkIndex !== -1) {\n acc[matchedChunkIndex].push(chunk);\n } else {\n acc.push([chunk]);\n }\n return acc;\n }, [] as ToolCallChunk[][]);\n\n const toolCalls: ToolCall[] = [];\n const invalidToolCalls: InvalidToolCall[] = [];\n for (const chunks of groupedToolCallChunks) {\n let parsedArgs: Record<string, unknown> | null = null;\n const name = chunks[0]?.name ?? \"\";\n const joinedArgs = chunks\n .map((c) => c.args || \"\")\n .join(\"\")\n .trim();\n const argsStr = joinedArgs.length ? joinedArgs : \"{}\";\n const id = chunks[0]?.id;\n try {\n parsedArgs = parsePartialJson(argsStr);\n if (\n !id ||\n parsedArgs === null ||\n typeof parsedArgs !== \"object\" ||\n Array.isArray(parsedArgs)\n ) {\n throw new Error(\"Malformed tool call chunk args.\");\n }\n toolCalls.push({\n name,\n args: parsedArgs,\n id,\n type: \"tool_call\",\n });\n } catch {\n invalidToolCalls.push({\n name,\n args: argsStr,\n id,\n error: \"Malformed args.\",\n type: \"invalid_tool_call\",\n });\n }\n }\n return {\n tool_call_chunks: chunks,\n tool_calls: toolCalls,\n invalid_tool_calls: invalidToolCalls,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsKA,MAAa,QAAW,OAAgB,IAAI;AAE5C,SAAS,gBACP,UACU;AACV,KAAI,YAAY,SAAS,CACvB,QAAO;UAEP,OAAO,SAAS,OAAO,YACvB,SAAS,SAAS,cAClB,OAAO,SAAS,aAAa,YAC7B,SAAS,aAAa,QACtB,eAAe,SAAS,YACxB,OAAO,SAAS,SAAS,cAAc,YAC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QAAQ;EAChC,MAAM,aAAa,OAChB,KAAK,MAAM,EAAE,QAAQ,GAAG,CACxB,KAAK,GAAG,CACR,MAAM;EACT,MAAM,UAAU,WAAW,SAAS,aAAa;EACjD,MAAM,KAAK,OAAO,IAAI;AACtB,MAAI;AACF,gBAAa,iBAAiB,QAAQ;AACtC,OACE,CAAC,MACD,eAAe,QACf,OAAO,eAAe,YACtB,MAAM,QAAQ,WAAW,CAEzB,OAAM,IAAI,MAAM,kCAAkC;AAEpD,aAAU,KAAK;IACb;IACA,MAAM;IACN;IACA,MAAM;IACP,CAAC;UACI;AACN,oBAAiB,KAAK;IACpB;IACA,MAAM;IACN;IACA,OAAO;IACP,MAAM;IACP,CAAC;;;AAGN,QAAO;EACL,kBAAkB;EAClB,YAAY;EACZ,oBAAoB;EACrB"}
@@ -37,14 +37,14 @@ var BaseLLMOutputParser = class extends require_base.Runnable {
37
37
  * @returns A promise of the parsed output.
38
38
  */
39
39
  async invoke(input, options) {
40
- if (typeof input === "string") return this._callWithConfig(async (input$1, options$1) => this.parseResult([{ text: input$1 }], options$1?.callbacks), input, {
40
+ if (typeof input === "string") return this._callWithConfig(async (input, options) => this.parseResult([{ text: input }], options?.callbacks), input, {
41
41
  ...options,
42
42
  runType: "parser"
43
43
  });
44
- else return this._callWithConfig(async (input$1, options$1) => this.parseResult([{
45
- message: input$1,
46
- text: this._baseMessageToString(input$1)
47
- }], options$1?.callbacks), input, {
44
+ else return this._callWithConfig(async (input, options) => this.parseResult([{
45
+ message: input,
46
+ text: this._baseMessageToString(input)
47
+ }], options?.callbacks), input, {
48
48
  ...options,
49
49
  runType: "parser"
50
50
  });
@@ -1 +1 @@
1
- {"version":3,"file":"base.cjs","names":["Runnable","generations: Generation[] | ChatGeneration[]","_prompt: BasePromptValueInterface","callbacks?: Callbacks","message: BaseMessage","content: ContentBlock[]","input: string | BaseMessage","options?: RunnableConfig","input: string","options","input","input: BaseMessage","text: string","message: string","llmOutput?: string","observation?: string","addLangChainErrorFields"],"sources":["../../src/output_parsers/base.ts"],"sourcesContent":["import { Runnable } from \"../runnables/index.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport type { BasePromptValueInterface } from \"../prompt_values.js\";\nimport type { BaseMessage, ContentBlock } from \"../messages/index.js\";\nimport type { Callbacks } from \"../callbacks/manager.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\n/**\n * Options for formatting instructions.\n */\nexport interface FormatInstructionsOptions {}\n\n/**\n * Abstract base class for parsing the output of a Large Language Model\n * (LLM) call. It provides methods for parsing the result of an LLM call\n * and invoking the parser with a given input.\n */\nexport abstract class BaseLLMOutputParser<T = unknown> extends Runnable<\n string | BaseMessage,\n T\n> {\n /**\n * Parses the result of an LLM call. This method is meant to be\n * implemented by subclasses to define how the output from the LLM should\n * be parsed.\n * @param generations The generations from an LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n abstract parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T>;\n\n /**\n * Parses the result of an LLM call with a given prompt. By default, it\n * simply calls `parseResult`.\n * @param generations The generations from an LLM call.\n * @param _prompt The prompt used in the LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n parseResultWithPrompt(\n generations: Generation[] | ChatGeneration[],\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parseResult(generations, callbacks);\n }\n\n protected _baseMessageToString(message: BaseMessage): string {\n return typeof message.content === \"string\"\n ? message.content\n : this._baseMessageContentToString(message.content);\n }\n\n protected _baseMessageContentToString(content: ContentBlock[]): string {\n return JSON.stringify(content);\n }\n\n /**\n * Calls the parser with a given input and optional configuration options.\n * If the input is a string, it creates a generation with the input as\n * text and calls `parseResult`. If the input is a `BaseMessage`, it\n * creates a generation with the input as a message and the content of the\n * input as text, and then calls `parseResult`.\n * @param input The input to the parser, which can be a string or a `BaseMessage`.\n * @param options Optional configuration options.\n * @returns A promise of the parsed output.\n */\n async invoke(\n input: string | BaseMessage,\n options?: RunnableConfig\n ): Promise<T> {\n if (typeof input === \"string\") {\n return this._callWithConfig(\n async (input: string, options): Promise<T> =>\n this.parseResult([{ text: input }], options?.callbacks),\n input,\n { ...options, runType: \"parser\" }\n );\n } else {\n return this._callWithConfig(\n async (input: BaseMessage, options): Promise<T> =>\n this.parseResult(\n [\n {\n message: input,\n text: this._baseMessageToString(input),\n },\n ],\n options?.callbacks\n ),\n input,\n { ...options, runType: \"parser\" }\n );\n }\n }\n}\n\n/**\n * Class to parse the output of an LLM call.\n */\nexport abstract class BaseOutputParser<\n T = unknown,\n> extends BaseLLMOutputParser<T> {\n parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(generations[0].text, callbacks);\n }\n\n /**\n * Parse the output of an LLM call.\n *\n * @param text - LLM output to parse.\n * @returns Parsed output.\n */\n abstract parse(text: string, callbacks?: Callbacks): Promise<T>;\n\n async parseWithPrompt(\n text: string,\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(text, callbacks);\n }\n\n /**\n * Return a string describing the format of the output.\n * @returns Format instructions.\n * @param options - Options for formatting instructions.\n * @example\n * ```json\n * {\n * \"foo\": \"bar\"\n * }\n * ```\n */\n abstract getFormatInstructions(options?: FormatInstructionsOptions): string;\n\n /**\n * Return the string type key uniquely identifying this class of parser\n */\n _type(): string {\n throw new Error(\"_type not implemented\");\n }\n}\n\n/**\n * Exception that output parsers should raise to signify a parsing error.\n *\n * This exists to differentiate parsing errors from other code or execution errors\n * that also may arise inside the output parser. OutputParserExceptions will be\n * available to catch and handle in ways to fix the parsing error, while other\n * errors will be raised.\n *\n * @param message - The error that's being re-raised or an error message.\n * @param llmOutput - String model output which is error-ing.\n * @param observation - String explanation of error which can be passed to a\n * model to try and remediate the issue.\n * @param sendToLLM - Whether to send the observation and llm_output back to an Agent\n * after an OutputParserException has been raised. This gives the underlying\n * model driving the agent the context that the previous output was improperly\n * structured, in the hopes that it will update the output to the correct\n * format.\n */\nexport class OutputParserException extends Error {\n llmOutput?: string;\n\n observation?: string;\n\n sendToLLM: boolean;\n\n constructor(\n message: string,\n llmOutput?: string,\n observation?: string,\n sendToLLM = false\n ) {\n super(message);\n this.llmOutput = llmOutput;\n this.observation = observation;\n this.sendToLLM = sendToLLM;\n\n if (sendToLLM) {\n if (observation === undefined || llmOutput === undefined) {\n throw new Error(\n \"Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true\"\n );\n }\n }\n\n addLangChainErrorFields(this, \"OUTPUT_PARSING_FAILURE\");\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAsB,sBAAtB,cAA+DA,sBAG7D;;;;;;;;;CAsBA,sBACEC,aACAC,SACAC,WACY;AACZ,SAAO,KAAK,YAAY,aAAa,UAAU;CAChD;CAED,AAAU,qBAAqBC,SAA8B;AAC3D,SAAO,OAAO,QAAQ,YAAY,WAC9B,QAAQ,UACR,KAAK,4BAA4B,QAAQ,QAAQ;CACtD;CAED,AAAU,4BAA4BC,SAAiC;AACrE,SAAO,KAAK,UAAU,QAAQ;CAC/B;;;;;;;;;;;CAYD,MAAM,OACJC,OACAC,SACY;AACZ,MAAI,OAAO,UAAU,SACnB,QAAO,KAAK,gBACV,OAAOC,SAAeC,cACpB,KAAK,YAAY,CAAC,EAAE,MAAMC,QAAO,CAAC,GAAED,WAAS,UAAU,EACzD,OACA;GAAE,GAAG;GAAS,SAAS;EAAU,EAClC;MAED,QAAO,KAAK,gBACV,OAAOE,SAAoBF,cACzB,KAAK,YACH,CACE;GACE,SAASC;GACT,MAAM,KAAK,qBAAqBA,QAAM;EACvC,CACF,GACDD,WAAS,UACV,EACH,OACA;GAAE,GAAG;GAAS,SAAS;EAAU,EAClC;CAEJ;AACF;;;;AAKD,IAAsB,mBAAtB,cAEU,oBAAuB;CAC/B,YACER,aACAE,WACY;AACZ,SAAO,KAAK,MAAM,YAAY,GAAG,MAAM,UAAU;CAClD;CAUD,MAAM,gBACJS,MACAV,SACAC,WACY;AACZ,SAAO,KAAK,MAAM,MAAM,UAAU;CACnC;;;;CAkBD,QAAgB;AACd,QAAM,IAAI,MAAM;CACjB;AACF;;;;;;;;;;;;;;;;;;;AAoBD,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CAEA;CAEA;CAEA,YACEU,SACAC,WACAC,aACA,YAAY,OACZ;EACA,MAAM,QAAQ;EACd,KAAK,YAAY;EACjB,KAAK,cAAc;EACnB,KAAK,YAAY;AAEjB,MAAI,WACF;OAAI,gBAAgB,UAAa,cAAc,OAC7C,OAAM,IAAI,MACR;EAEH;EAGHC,6CAAwB,MAAM,yBAAyB;CACxD;AACF"}
1
+ {"version":3,"file":"base.cjs","names":["Runnable"],"sources":["../../src/output_parsers/base.ts"],"sourcesContent":["import { Runnable } from \"../runnables/index.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport type { BasePromptValueInterface } from \"../prompt_values.js\";\nimport type { BaseMessage, ContentBlock } from \"../messages/index.js\";\nimport type { Callbacks } from \"../callbacks/manager.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\n/**\n * Options for formatting instructions.\n */\nexport interface FormatInstructionsOptions {}\n\n/**\n * Abstract base class for parsing the output of a Large Language Model\n * (LLM) call. It provides methods for parsing the result of an LLM call\n * and invoking the parser with a given input.\n */\nexport abstract class BaseLLMOutputParser<T = unknown> extends Runnable<\n string | BaseMessage,\n T\n> {\n /**\n * Parses the result of an LLM call. This method is meant to be\n * implemented by subclasses to define how the output from the LLM should\n * be parsed.\n * @param generations The generations from an LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n abstract parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T>;\n\n /**\n * Parses the result of an LLM call with a given prompt. By default, it\n * simply calls `parseResult`.\n * @param generations The generations from an LLM call.\n * @param _prompt The prompt used in the LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n parseResultWithPrompt(\n generations: Generation[] | ChatGeneration[],\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parseResult(generations, callbacks);\n }\n\n protected _baseMessageToString(message: BaseMessage): string {\n return typeof message.content === \"string\"\n ? message.content\n : this._baseMessageContentToString(message.content);\n }\n\n protected _baseMessageContentToString(content: ContentBlock[]): string {\n return JSON.stringify(content);\n }\n\n /**\n * Calls the parser with a given input and optional configuration options.\n * If the input is a string, it creates a generation with the input as\n * text and calls `parseResult`. If the input is a `BaseMessage`, it\n * creates a generation with the input as a message and the content of the\n * input as text, and then calls `parseResult`.\n * @param input The input to the parser, which can be a string or a `BaseMessage`.\n * @param options Optional configuration options.\n * @returns A promise of the parsed output.\n */\n async invoke(\n input: string | BaseMessage,\n options?: RunnableConfig\n ): Promise<T> {\n if (typeof input === \"string\") {\n return this._callWithConfig(\n async (input: string, options): Promise<T> =>\n this.parseResult([{ text: input }], options?.callbacks),\n input,\n { ...options, runType: \"parser\" }\n );\n } else {\n return this._callWithConfig(\n async (input: BaseMessage, options): Promise<T> =>\n this.parseResult(\n [\n {\n message: input,\n text: this._baseMessageToString(input),\n },\n ],\n options?.callbacks\n ),\n input,\n { ...options, runType: \"parser\" }\n );\n }\n }\n}\n\n/**\n * Class to parse the output of an LLM call.\n */\nexport abstract class BaseOutputParser<\n T = unknown,\n> extends BaseLLMOutputParser<T> {\n parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(generations[0].text, callbacks);\n }\n\n /**\n * Parse the output of an LLM call.\n *\n * @param text - LLM output to parse.\n * @returns Parsed output.\n */\n abstract parse(text: string, callbacks?: Callbacks): Promise<T>;\n\n async parseWithPrompt(\n text: string,\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(text, callbacks);\n }\n\n /**\n * Return a string describing the format of the output.\n * @returns Format instructions.\n * @param options - Options for formatting instructions.\n * @example\n * ```json\n * {\n * \"foo\": \"bar\"\n * }\n * ```\n */\n abstract getFormatInstructions(options?: FormatInstructionsOptions): string;\n\n /**\n * Return the string type key uniquely identifying this class of parser\n */\n _type(): string {\n throw new Error(\"_type not implemented\");\n }\n}\n\n/**\n * Exception that output parsers should raise to signify a parsing error.\n *\n * This exists to differentiate parsing errors from other code or execution errors\n * that also may arise inside the output parser. OutputParserExceptions will be\n * available to catch and handle in ways to fix the parsing error, while other\n * errors will be raised.\n *\n * @param message - The error that's being re-raised or an error message.\n * @param llmOutput - String model output which is error-ing.\n * @param observation - String explanation of error which can be passed to a\n * model to try and remediate the issue.\n * @param sendToLLM - Whether to send the observation and llm_output back to an Agent\n * after an OutputParserException has been raised. This gives the underlying\n * model driving the agent the context that the previous output was improperly\n * structured, in the hopes that it will update the output to the correct\n * format.\n */\nexport class OutputParserException extends Error {\n llmOutput?: string;\n\n observation?: string;\n\n sendToLLM: boolean;\n\n constructor(\n message: string,\n llmOutput?: string,\n observation?: string,\n sendToLLM = false\n ) {\n super(message);\n this.llmOutput = llmOutput;\n this.observation = observation;\n this.sendToLLM = sendToLLM;\n\n if (sendToLLM) {\n if (observation === undefined || llmOutput === undefined) {\n throw new Error(\n \"Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true\"\n );\n }\n }\n\n addLangChainErrorFields(this, \"OUTPUT_PARSING_FAILURE\");\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAsB,sBAAtB,cAA+DA,sBAG7D;;;;;;;;;CAsBA,sBACE,aACA,SACA,WACY;AACZ,SAAO,KAAK,YAAY,aAAa,UAAU;;CAGjD,AAAU,qBAAqB,SAA8B;AAC3D,SAAO,OAAO,QAAQ,YAAY,WAC9B,QAAQ,UACR,KAAK,4BAA4B,QAAQ,QAAQ;;CAGvD,AAAU,4BAA4B,SAAiC;AACrE,SAAO,KAAK,UAAU,QAAQ;;;;;;;;;;;;CAahC,MAAM,OACJ,OACA,SACY;AACZ,MAAI,OAAO,UAAU,SACnB,QAAO,KAAK,gBACV,OAAO,OAAe,YACpB,KAAK,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,EAAE,SAAS,UAAU,EACzD,OACA;GAAE,GAAG;GAAS,SAAS;GAAU,CAClC;MAED,QAAO,KAAK,gBACV,OAAO,OAAoB,YACzB,KAAK,YACH,CACE;GACE,SAAS;GACT,MAAM,KAAK,qBAAqB,MAAM;GACvC,CACF,EACD,SAAS,UACV,EACH,OACA;GAAE,GAAG;GAAS,SAAS;GAAU,CAClC;;;;;;AAQP,IAAsB,mBAAtB,cAEU,oBAAuB;CAC/B,YACE,aACA,WACY;AACZ,SAAO,KAAK,MAAM,YAAY,GAAG,MAAM,UAAU;;CAWnD,MAAM,gBACJ,MACA,SACA,WACY;AACZ,SAAO,KAAK,MAAM,MAAM,UAAU;;;;;CAmBpC,QAAgB;AACd,QAAM,IAAI,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;AAsB5C,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CAEA;CAEA;CAEA,YACE,SACA,WACA,aACA,YAAY,OACZ;AACA,QAAM,QAAQ;AACd,OAAK,YAAY;AACjB,OAAK,cAAc;AACnB,OAAK,YAAY;AAEjB,MAAI,WACF;OAAI,gBAAgB,UAAa,cAAc,OAC7C,OAAM,IAAI,MACR,4EACD;;AAIL,+CAAwB,MAAM,yBAAyB"}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.cts","names":["Runnable","RunnableConfig","BasePromptValueInterface","BaseMessage","ContentBlock","Callbacks","Generation","ChatGeneration","FormatInstructionsOptions","BaseLLMOutputParser","T","Promise","BaseOutputParser","OutputParserException","Error"],"sources":["../../src/output_parsers/base.d.ts"],"sourcesContent":["import { Runnable } from \"../runnables/index.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport type { BasePromptValueInterface } from \"../prompt_values.js\";\nimport type { BaseMessage, ContentBlock } from \"../messages/index.js\";\nimport type { Callbacks } from \"../callbacks/manager.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\n/**\n * Options for formatting instructions.\n */\nexport interface FormatInstructionsOptions {\n}\n/**\n * Abstract base class for parsing the output of a Large Language Model\n * (LLM) call. It provides methods for parsing the result of an LLM call\n * and invoking the parser with a given input.\n */\nexport declare abstract class BaseLLMOutputParser<T = unknown> extends Runnable<string | BaseMessage, T> {\n /**\n * Parses the result of an LLM call. This method is meant to be\n * implemented by subclasses to define how the output from the LLM should\n * be parsed.\n * @param generations The generations from an LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n abstract parseResult(generations: Generation[] | ChatGeneration[], callbacks?: Callbacks): Promise<T>;\n /**\n * Parses the result of an LLM call with a given prompt. By default, it\n * simply calls `parseResult`.\n * @param generations The generations from an LLM call.\n * @param _prompt The prompt used in the LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n parseResultWithPrompt(generations: Generation[] | ChatGeneration[], _prompt: BasePromptValueInterface, callbacks?: Callbacks): Promise<T>;\n protected _baseMessageToString(message: BaseMessage): string;\n protected _baseMessageContentToString(content: ContentBlock[]): string;\n /**\n * Calls the parser with a given input and optional configuration options.\n * If the input is a string, it creates a generation with the input as\n * text and calls `parseResult`. If the input is a `BaseMessage`, it\n * creates a generation with the input as a message and the content of the\n * input as text, and then calls `parseResult`.\n * @param input The input to the parser, which can be a string or a `BaseMessage`.\n * @param options Optional configuration options.\n * @returns A promise of the parsed output.\n */\n invoke(input: string | BaseMessage, options?: RunnableConfig): Promise<T>;\n}\n/**\n * Class to parse the output of an LLM call.\n */\nexport declare abstract class BaseOutputParser<T = unknown> extends BaseLLMOutputParser<T> {\n parseResult(generations: Generation[] | ChatGeneration[], callbacks?: Callbacks): Promise<T>;\n /**\n * Parse the output of an LLM call.\n *\n * @param text - LLM output to parse.\n * @returns Parsed output.\n */\n abstract parse(text: string, callbacks?: Callbacks): Promise<T>;\n parseWithPrompt(text: string, _prompt: BasePromptValueInterface, callbacks?: Callbacks): Promise<T>;\n /**\n * Return a string describing the format of the output.\n * @returns Format instructions.\n * @param options - Options for formatting instructions.\n * @example\n * ```json\n * {\n * \"foo\": \"bar\"\n * }\n * ```\n */\n abstract getFormatInstructions(options?: FormatInstructionsOptions): string;\n /**\n * Return the string type key uniquely identifying this class of parser\n */\n _type(): string;\n}\n/**\n * Exception that output parsers should raise to signify a parsing error.\n *\n * This exists to differentiate parsing errors from other code or execution errors\n * that also may arise inside the output parser. OutputParserExceptions will be\n * available to catch and handle in ways to fix the parsing error, while other\n * errors will be raised.\n *\n * @param message - The error that's being re-raised or an error message.\n * @param llmOutput - String model output which is error-ing.\n * @param observation - String explanation of error which can be passed to a\n * model to try and remediate the issue.\n * @param sendToLLM - Whether to send the observation and llm_output back to an Agent\n * after an OutputParserException has been raised. This gives the underlying\n * model driving the agent the context that the previous output was improperly\n * structured, in the hopes that it will update the output to the correct\n * format.\n */\nexport declare class OutputParserException extends Error {\n llmOutput?: string;\n observation?: string;\n sendToLLM: boolean;\n constructor(message: string, llmOutput?: string, observation?: string, sendToLLM?: boolean);\n}\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;;;AASiBQ,UAAAA,yBAAAA,CAAyB,CAO1C;;;;;;AASuGE,uBATzED,mBASyEC,CAAAA,IAAAA,OAAAA,CAAAA,SAThCV,QASgCU,CAAAA,MAAAA,GATdP,WAScO,EATDA,CASCA,CAAAA,CAAAA;EAARC;;;;;;;;EAW5CP,SAAAA,WAAAA,CAAAA,WAAAA,EAXbE,UAWaF,EAAAA,GAXEG,cAWFH,EAAAA,EAAAA,SAAAA,CAAAA,EAXgCC,SAWhCD,CAAAA,EAX4CO,OAW5CP,CAXoDM,CAWpDN,CAAAA;EAWxBD;;;;;AA/BoD;AAoC/E;;EAC6BG,qBAAAA,CAAAA,WAAAA,EAnBUA,UAmBVA,EAAAA,GAnByBC,c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MAAA,CACJ,KAAA,WAAgB,WAAA,EAChB,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,CAAA;AAAA;;;;uBA8BS,gBAAA,sBAEZ,mBAAA,CAAoB,CAAA;EAC5B,WAAA,CACE,WAAA,EAAa,UAAA,KAAe,cAAA,IAC5B,SAAA,GAAY,SAAA,GACX,OAAA,CAAQ,CAAA;EAlET;;;;;;EAAA,SA4EO,KAAA,CAAM,IAAA,UAAc,SAAA,GAAY,SAAA,GAAY,OAAA,CAAQ,CAAA;EAEvD,eAAA,CACJ,IAAA,UACA,OAAA,EAAS,wBAAA,EACT,SAAA,GAAY,SAAA,GACX,OAAA,CAAQ,CAAA;EA3E6B;;;;;;;;;;;EAAA,SA0F/B,qBAAA,CAAsB,OAAA,GAAU,yBAAA;EAnE7B;;AA8Bd;EA0CE,KAAA,CAAA;AAAA;;;;;;;;;;;;;;;;;;;cAuBW,qBAAA,SAA8B,KAAA;EACzC,SAAA;EAEA,WAAA;EAEA,SAAA;EAEA,WAAA,CACE,OAAA,UACA,SAAA,WACA,WAAA,WACA,SAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","names":["Runnable","RunnableConfig","BasePromptValueInterface","BaseMessage","ContentBlock","Callbacks","Generation","ChatGeneration","FormatInstructionsOptions","BaseLLMOutputParser","T","Promise","BaseOutputParser","OutputParserException","Error"],"sources":["../../src/output_parsers/base.d.ts"],"sourcesContent":["import { Runnable } from \"../runnables/index.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport type { BasePromptValueInterface } from \"../prompt_values.js\";\nimport type { BaseMessage, ContentBlock } from \"../messages/index.js\";\nimport type { Callbacks } from \"../callbacks/manager.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\n/**\n * Options for formatting instructions.\n */\nexport interface FormatInstructionsOptions {\n}\n/**\n * Abstract base class for parsing the output of a Large Language Model\n * (LLM) call. It provides methods for parsing the result of an LLM call\n * and invoking the parser with a given input.\n */\nexport declare abstract class BaseLLMOutputParser<T = unknown> extends Runnable<string | BaseMessage, T> {\n /**\n * Parses the result of an LLM call. This method is meant to be\n * implemented by subclasses to define how the output from the LLM should\n * be parsed.\n * @param generations The generations from an LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n abstract parseResult(generations: Generation[] | ChatGeneration[], callbacks?: Callbacks): Promise<T>;\n /**\n * Parses the result of an LLM call with a given prompt. By default, it\n * simply calls `parseResult`.\n * @param generations The generations from an LLM call.\n * @param _prompt The prompt used in the LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n parseResultWithPrompt(generations: Generation[] | ChatGeneration[], _prompt: BasePromptValueInterface, callbacks?: Callbacks): Promise<T>;\n protected _baseMessageToString(message: BaseMessage): string;\n protected _baseMessageContentToString(content: ContentBlock[]): string;\n /**\n * Calls the parser with a given input and optional configuration options.\n * If the input is a string, it creates a generation with the input as\n * text and calls `parseResult`. If the input is a `BaseMessage`, it\n * creates a generation with the input as a message and the content of the\n * input as text, and then calls `parseResult`.\n * @param input The input to the parser, which can be a string or a `BaseMessage`.\n * @param options Optional configuration options.\n * @returns A promise of the parsed output.\n */\n invoke(input: string | BaseMessage, options?: RunnableConfig): Promise<T>;\n}\n/**\n * Class to parse the output of an LLM call.\n */\nexport declare abstract class BaseOutputParser<T = unknown> extends BaseLLMOutputParser<T> {\n parseResult(generations: Generation[] | ChatGeneration[], callbacks?: Callbacks): Promise<T>;\n /**\n * Parse the output of an LLM call.\n *\n * @param text - LLM output to parse.\n * @returns Parsed output.\n */\n abstract parse(text: string, callbacks?: Callbacks): Promise<T>;\n parseWithPrompt(text: string, _prompt: BasePromptValueInterface, callbacks?: Callbacks): Promise<T>;\n /**\n * Return a string describing the format of the output.\n * @returns Format instructions.\n * @param options - Options for formatting instructions.\n * @example\n * ```json\n * {\n * \"foo\": \"bar\"\n * }\n * ```\n */\n abstract getFormatInstructions(options?: FormatInstructionsOptions): string;\n /**\n * Return the string type key uniquely identifying this class of parser\n */\n _type(): string;\n}\n/**\n * Exception that output parsers should raise to signify a parsing error.\n *\n * This exists to differentiate parsing errors from other code or execution errors\n * that also may arise inside the output parser. OutputParserExceptions will be\n * available to catch and handle in ways to fix the parsing error, while other\n * errors will be raised.\n *\n * @param message - The error that's being re-raised or an error message.\n * @param llmOutput - String model output which is error-ing.\n * @param observation - String explanation of error which can be passed to a\n * model to try and remediate the issue.\n * @param sendToLLM - Whether to send the observation and llm_output back to an Agent\n * after an OutputParserException has been raised. This gives the underlying\n * model driving the agent the context that the previous output was improperly\n * structured, in the hopes that it will update the output to the correct\n * format.\n */\nexport declare class OutputParserException extends Error {\n llmOutput?: string;\n observation?: string;\n sendToLLM: boolean;\n constructor(message: string, llmOutput?: string, observation?: string, sendToLLM?: boolean);\n}\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;;;;;;;UASiBQ,yBAAAA;;AAAjB;AAOA;;;AASsCF,uBATRG,mBASQH,CAAAA,IAAAA,OAAAA,CAAAA,SATiCN,QASjCM,CAAAA,MAAAA,GATmDH,WASnDG,EATgEI,CAShEJ,CAAAA,CAAAA;EAAeC;;;;;;;;EASsFG,SAAAA,WAAAA,CAAAA,WAAAA,EATrGJ,UASqGI,EAAAA,GATtFH,cASsFG,EAAAA,EAAAA,SAAAA,CAAAA,EATxDL,SASwDK,CAAAA,EAT5CC,OAS4CD,CATpCA,CASoCA,CAAAA;EAARC;;;;;;;;EAlBpD,qBAAA,CAAA,WAAA,EAkBxCL,UAlBwC,EAAA,GAkBzBC,cAlByB,EAAA,EAAA,OAAA,EAkBEL,wBAlBF,EAAA,SAAA,CAAA,EAkBwCG,SAlBxC,CAAA,EAkBoDM,OAlBpD,CAkB4DD,CAlB5D,CAAA;EAoCjDE,UAAAA,oBAAgBF,CAAAA,OAAA,EAjBFP,WAiBE,CAAA,EAAA,MAAA;EAA0CO,UAAAA,2BAAAA,CAAAA,OAAAA,EAhBrCN,YAgBqCM,EAAAA,CAAAA,EAAAA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AA;EAnEX;;;;;;EAAA,SA6ES,KAAA,CAAM,IAAA,UAAc,SAAA,GAAY,SAAA,GAAY,OAAA,CAAQ,CAAA;EAEvD,eAAA,CACJ,IAAA,UACA,OAAA,EAAS,wBAAA,EACT,SAAA,GAAY,SAAA,GACX,OAAA,CAAQ,CAAA;EA/ER;;;;;;;;;;;EAAA,SA8FM,qBAAA,CAAsB,OAAA,GAAU,yBAAA;EApEvC;;;EAyEF,KAAA,CAAA;AAAA;AA1CF;;;;;;;;;;;;;;;;;;AAAA,cAiEa,qBAAA,SAA8B,KAAA;EACzC,SAAA;EAEA,WAAA;EAEA,SAAA;EAEA,WAAA,CACE,OAAA,UACA,SAAA,WACA,WAAA,WACA,SAAA;AAAA"}
@@ -37,14 +37,14 @@ var BaseLLMOutputParser = class extends Runnable {
37
37
  * @returns A promise of the parsed output.
38
38
  */
39
39
  async invoke(input, options) {
40
- if (typeof input === "string") return this._callWithConfig(async (input$1, options$1) => this.parseResult([{ text: input$1 }], options$1?.callbacks), input, {
40
+ if (typeof input === "string") return this._callWithConfig(async (input, options) => this.parseResult([{ text: input }], options?.callbacks), input, {
41
41
  ...options,
42
42
  runType: "parser"
43
43
  });
44
- else return this._callWithConfig(async (input$1, options$1) => this.parseResult([{
45
- message: input$1,
46
- text: this._baseMessageToString(input$1)
47
- }], options$1?.callbacks), input, {
44
+ else return this._callWithConfig(async (input, options) => this.parseResult([{
45
+ message: input,
46
+ text: this._baseMessageToString(input)
47
+ }], options?.callbacks), input, {
48
48
  ...options,
49
49
  runType: "parser"
50
50
  });
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["generations: Generation[] | ChatGeneration[]","_prompt: BasePromptValueInterface","callbacks?: Callbacks","message: BaseMessage","content: ContentBlock[]","input: string | BaseMessage","options?: RunnableConfig","input: string","options","input","input: BaseMessage","text: string","message: string","llmOutput?: string","observation?: string"],"sources":["../../src/output_parsers/base.ts"],"sourcesContent":["import { Runnable } from \"../runnables/index.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport type { BasePromptValueInterface } from \"../prompt_values.js\";\nimport type { BaseMessage, ContentBlock } from \"../messages/index.js\";\nimport type { Callbacks } from \"../callbacks/manager.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\n/**\n * Options for formatting instructions.\n */\nexport interface FormatInstructionsOptions {}\n\n/**\n * Abstract base class for parsing the output of a Large Language Model\n * (LLM) call. It provides methods for parsing the result of an LLM call\n * and invoking the parser with a given input.\n */\nexport abstract class BaseLLMOutputParser<T = unknown> extends Runnable<\n string | BaseMessage,\n T\n> {\n /**\n * Parses the result of an LLM call. This method is meant to be\n * implemented by subclasses to define how the output from the LLM should\n * be parsed.\n * @param generations The generations from an LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n abstract parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T>;\n\n /**\n * Parses the result of an LLM call with a given prompt. By default, it\n * simply calls `parseResult`.\n * @param generations The generations from an LLM call.\n * @param _prompt The prompt used in the LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n parseResultWithPrompt(\n generations: Generation[] | ChatGeneration[],\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parseResult(generations, callbacks);\n }\n\n protected _baseMessageToString(message: BaseMessage): string {\n return typeof message.content === \"string\"\n ? message.content\n : this._baseMessageContentToString(message.content);\n }\n\n protected _baseMessageContentToString(content: ContentBlock[]): string {\n return JSON.stringify(content);\n }\n\n /**\n * Calls the parser with a given input and optional configuration options.\n * If the input is a string, it creates a generation with the input as\n * text and calls `parseResult`. If the input is a `BaseMessage`, it\n * creates a generation with the input as a message and the content of the\n * input as text, and then calls `parseResult`.\n * @param input The input to the parser, which can be a string or a `BaseMessage`.\n * @param options Optional configuration options.\n * @returns A promise of the parsed output.\n */\n async invoke(\n input: string | BaseMessage,\n options?: RunnableConfig\n ): Promise<T> {\n if (typeof input === \"string\") {\n return this._callWithConfig(\n async (input: string, options): Promise<T> =>\n this.parseResult([{ text: input }], options?.callbacks),\n input,\n { ...options, runType: \"parser\" }\n );\n } else {\n return this._callWithConfig(\n async (input: BaseMessage, options): Promise<T> =>\n this.parseResult(\n [\n {\n message: input,\n text: this._baseMessageToString(input),\n },\n ],\n options?.callbacks\n ),\n input,\n { ...options, runType: \"parser\" }\n );\n }\n }\n}\n\n/**\n * Class to parse the output of an LLM call.\n */\nexport abstract class BaseOutputParser<\n T = unknown,\n> extends BaseLLMOutputParser<T> {\n parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(generations[0].text, callbacks);\n }\n\n /**\n * Parse the output of an LLM call.\n *\n * @param text - LLM output to parse.\n * @returns Parsed output.\n */\n abstract parse(text: string, callbacks?: Callbacks): Promise<T>;\n\n async parseWithPrompt(\n text: string,\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(text, callbacks);\n }\n\n /**\n * Return a string describing the format of the output.\n * @returns Format instructions.\n * @param options - Options for formatting instructions.\n * @example\n * ```json\n * {\n * \"foo\": \"bar\"\n * }\n * ```\n */\n abstract getFormatInstructions(options?: FormatInstructionsOptions): string;\n\n /**\n * Return the string type key uniquely identifying this class of parser\n */\n _type(): string {\n throw new Error(\"_type not implemented\");\n }\n}\n\n/**\n * Exception that output parsers should raise to signify a parsing error.\n *\n * This exists to differentiate parsing errors from other code or execution errors\n * that also may arise inside the output parser. OutputParserExceptions will be\n * available to catch and handle in ways to fix the parsing error, while other\n * errors will be raised.\n *\n * @param message - The error that's being re-raised or an error message.\n * @param llmOutput - String model output which is error-ing.\n * @param observation - String explanation of error which can be passed to a\n * model to try and remediate the issue.\n * @param sendToLLM - Whether to send the observation and llm_output back to an Agent\n * after an OutputParserException has been raised. This gives the underlying\n * model driving the agent the context that the previous output was improperly\n * structured, in the hopes that it will update the output to the correct\n * format.\n */\nexport class OutputParserException extends Error {\n llmOutput?: string;\n\n observation?: string;\n\n sendToLLM: boolean;\n\n constructor(\n message: string,\n llmOutput?: string,\n observation?: string,\n sendToLLM = false\n ) {\n super(message);\n this.llmOutput = llmOutput;\n this.observation = observation;\n this.sendToLLM = sendToLLM;\n\n if (sendToLLM) {\n if (observation === undefined || llmOutput === undefined) {\n throw new Error(\n \"Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true\"\n );\n }\n }\n\n addLangChainErrorFields(this, \"OUTPUT_PARSING_FAILURE\");\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAsB,sBAAtB,cAA+D,SAG7D;;;;;;;;;CAsBA,sBACEA,aACAC,SACAC,WACY;AACZ,SAAO,KAAK,YAAY,aAAa,UAAU;CAChD;CAED,AAAU,qBAAqBC,SAA8B;AAC3D,SAAO,OAAO,QAAQ,YAAY,WAC9B,QAAQ,UACR,KAAK,4BAA4B,QAAQ,QAAQ;CACtD;CAED,AAAU,4BAA4BC,SAAiC;AACrE,SAAO,KAAK,UAAU,QAAQ;CAC/B;;;;;;;;;;;CAYD,MAAM,OACJC,OACAC,SACY;AACZ,MAAI,OAAO,UAAU,SACnB,QAAO,KAAK,gBACV,OAAOC,SAAeC,cACpB,KAAK,YAAY,CAAC,EAAE,MAAMC,QAAO,CAAC,GAAED,WAAS,UAAU,EACzD,OACA;GAAE,GAAG;GAAS,SAAS;EAAU,EAClC;MAED,QAAO,KAAK,gBACV,OAAOE,SAAoBF,cACzB,KAAK,YACH,CACE;GACE,SAASC;GACT,MAAM,KAAK,qBAAqBA,QAAM;EACvC,CACF,GACDD,WAAS,UACV,EACH,OACA;GAAE,GAAG;GAAS,SAAS;EAAU,EAClC;CAEJ;AACF;;;;AAKD,IAAsB,mBAAtB,cAEU,oBAAuB;CAC/B,YACER,aACAE,WACY;AACZ,SAAO,KAAK,MAAM,YAAY,GAAG,MAAM,UAAU;CAClD;CAUD,MAAM,gBACJS,MACAV,SACAC,WACY;AACZ,SAAO,KAAK,MAAM,MAAM,UAAU;CACnC;;;;CAkBD,QAAgB;AACd,QAAM,IAAI,MAAM;CACjB;AACF;;;;;;;;;;;;;;;;;;;AAoBD,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CAEA;CAEA;CAEA,YACEU,SACAC,WACAC,aACA,YAAY,OACZ;EACA,MAAM,QAAQ;EACd,KAAK,YAAY;EACjB,KAAK,cAAc;EACnB,KAAK,YAAY;AAEjB,MAAI,WACF;OAAI,gBAAgB,UAAa,cAAc,OAC7C,OAAM,IAAI,MACR;EAEH;EAGH,wBAAwB,MAAM,yBAAyB;CACxD;AACF"}
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../src/output_parsers/base.ts"],"sourcesContent":["import { Runnable } from \"../runnables/index.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport type { BasePromptValueInterface } from \"../prompt_values.js\";\nimport type { BaseMessage, ContentBlock } from \"../messages/index.js\";\nimport type { Callbacks } from \"../callbacks/manager.js\";\nimport type { Generation, ChatGeneration } from \"../outputs.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\n/**\n * Options for formatting instructions.\n */\nexport interface FormatInstructionsOptions {}\n\n/**\n * Abstract base class for parsing the output of a Large Language Model\n * (LLM) call. It provides methods for parsing the result of an LLM call\n * and invoking the parser with a given input.\n */\nexport abstract class BaseLLMOutputParser<T = unknown> extends Runnable<\n string | BaseMessage,\n T\n> {\n /**\n * Parses the result of an LLM call. This method is meant to be\n * implemented by subclasses to define how the output from the LLM should\n * be parsed.\n * @param generations The generations from an LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n abstract parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T>;\n\n /**\n * Parses the result of an LLM call with a given prompt. By default, it\n * simply calls `parseResult`.\n * @param generations The generations from an LLM call.\n * @param _prompt The prompt used in the LLM call.\n * @param callbacks Optional callbacks.\n * @returns A promise of the parsed output.\n */\n parseResultWithPrompt(\n generations: Generation[] | ChatGeneration[],\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parseResult(generations, callbacks);\n }\n\n protected _baseMessageToString(message: BaseMessage): string {\n return typeof message.content === \"string\"\n ? message.content\n : this._baseMessageContentToString(message.content);\n }\n\n protected _baseMessageContentToString(content: ContentBlock[]): string {\n return JSON.stringify(content);\n }\n\n /**\n * Calls the parser with a given input and optional configuration options.\n * If the input is a string, it creates a generation with the input as\n * text and calls `parseResult`. If the input is a `BaseMessage`, it\n * creates a generation with the input as a message and the content of the\n * input as text, and then calls `parseResult`.\n * @param input The input to the parser, which can be a string or a `BaseMessage`.\n * @param options Optional configuration options.\n * @returns A promise of the parsed output.\n */\n async invoke(\n input: string | BaseMessage,\n options?: RunnableConfig\n ): Promise<T> {\n if (typeof input === \"string\") {\n return this._callWithConfig(\n async (input: string, options): Promise<T> =>\n this.parseResult([{ text: input }], options?.callbacks),\n input,\n { ...options, runType: \"parser\" }\n );\n } else {\n return this._callWithConfig(\n async (input: BaseMessage, options): Promise<T> =>\n this.parseResult(\n [\n {\n message: input,\n text: this._baseMessageToString(input),\n },\n ],\n options?.callbacks\n ),\n input,\n { ...options, runType: \"parser\" }\n );\n }\n }\n}\n\n/**\n * Class to parse the output of an LLM call.\n */\nexport abstract class BaseOutputParser<\n T = unknown,\n> extends BaseLLMOutputParser<T> {\n parseResult(\n generations: Generation[] | ChatGeneration[],\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(generations[0].text, callbacks);\n }\n\n /**\n * Parse the output of an LLM call.\n *\n * @param text - LLM output to parse.\n * @returns Parsed output.\n */\n abstract parse(text: string, callbacks?: Callbacks): Promise<T>;\n\n async parseWithPrompt(\n text: string,\n _prompt: BasePromptValueInterface,\n callbacks?: Callbacks\n ): Promise<T> {\n return this.parse(text, callbacks);\n }\n\n /**\n * Return a string describing the format of the output.\n * @returns Format instructions.\n * @param options - Options for formatting instructions.\n * @example\n * ```json\n * {\n * \"foo\": \"bar\"\n * }\n * ```\n */\n abstract getFormatInstructions(options?: FormatInstructionsOptions): string;\n\n /**\n * Return the string type key uniquely identifying this class of parser\n */\n _type(): string {\n throw new Error(\"_type not implemented\");\n }\n}\n\n/**\n * Exception that output parsers should raise to signify a parsing error.\n *\n * This exists to differentiate parsing errors from other code or execution errors\n * that also may arise inside the output parser. OutputParserExceptions will be\n * available to catch and handle in ways to fix the parsing error, while other\n * errors will be raised.\n *\n * @param message - The error that's being re-raised or an error message.\n * @param llmOutput - String model output which is error-ing.\n * @param observation - String explanation of error which can be passed to a\n * model to try and remediate the issue.\n * @param sendToLLM - Whether to send the observation and llm_output back to an Agent\n * after an OutputParserException has been raised. This gives the underlying\n * model driving the agent the context that the previous output was improperly\n * structured, in the hopes that it will update the output to the correct\n * format.\n */\nexport class OutputParserException extends Error {\n llmOutput?: string;\n\n observation?: string;\n\n sendToLLM: boolean;\n\n constructor(\n message: string,\n llmOutput?: string,\n observation?: string,\n sendToLLM = false\n ) {\n super(message);\n this.llmOutput = llmOutput;\n this.observation = observation;\n this.sendToLLM = sendToLLM;\n\n if (sendToLLM) {\n if (observation === undefined || llmOutput === undefined) {\n throw new Error(\n \"Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true\"\n );\n }\n }\n\n addLangChainErrorFields(this, \"OUTPUT_PARSING_FAILURE\");\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAsB,sBAAtB,cAA+D,SAG7D;;;;;;;;;CAsBA,sBACE,aACA,SACA,WACY;AACZ,SAAO,KAAK,YAAY,aAAa,UAAU;;CAGjD,AAAU,qBAAqB,SAA8B;AAC3D,SAAO,OAAO,QAAQ,YAAY,WAC9B,QAAQ,UACR,KAAK,4BAA4B,QAAQ,QAAQ;;CAGvD,AAAU,4BAA4B,SAAiC;AACrE,SAAO,KAAK,UAAU,QAAQ;;;;;;;;;;;;CAahC,MAAM,OACJ,OACA,SACY;AACZ,MAAI,OAAO,UAAU,SACnB,QAAO,KAAK,gBACV,OAAO,OAAe,YACpB,KAAK,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,EAAE,SAAS,UAAU,EACzD,OACA;GAAE,GAAG;GAAS,SAAS;GAAU,CAClC;MAED,QAAO,KAAK,gBACV,OAAO,OAAoB,YACzB,KAAK,YACH,CACE;GACE,SAAS;GACT,MAAM,KAAK,qBAAqB,MAAM;GACvC,CACF,EACD,SAAS,UACV,EACH,OACA;GAAE,GAAG;GAAS,SAAS;GAAU,CAClC;;;;;;AAQP,IAAsB,mBAAtB,cAEU,oBAAuB;CAC/B,YACE,aACA,WACY;AACZ,SAAO,KAAK,MAAM,YAAY,GAAG,MAAM,UAAU;;CAWnD,MAAM,gBACJ,MACA,SACA,WACY;AACZ,SAAO,KAAK,MAAM,MAAM,UAAU;;;;;CAmBpC,QAAgB;AACd,QAAM,IAAI,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;AAsB5C,IAAa,wBAAb,cAA2C,MAAM;CAC/C;CAEA;CAEA;CAEA,YACE,SACA,WACA,aACA,YAAY,OACZ;AACA,QAAM,QAAQ;AACd,OAAK,YAAY;AACjB,OAAK,cAAc;AACnB,OAAK,YAAY;AAEjB,MAAI,WACF;OAAI,gBAAgB,UAAa,cAAc,OAC7C,OAAM,IAAI,MACR,4EACD;;AAIL,0BAAwB,MAAM,yBAAyB"}
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.cjs","names":["BaseTransformOutputParser","text: string"],"sources":["../../src/output_parsers/bytes.ts"],"sourcesContent":["import { BaseTransformOutputParser } from \"./transform.js\";\n\n/**\n * OutputParser that parses LLMResult into the top likely string and\n * encodes it into bytes.\n */\nexport class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> {\n static lc_name() {\n return \"BytesOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\", \"bytes\"];\n\n lc_serializable = true;\n\n protected textEncoder: InstanceType<typeof TextEncoder> = new TextEncoder();\n\n parse(text: string): Promise<Uint8Array> {\n return Promise.resolve(this.textEncoder.encode(text));\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,oBAAb,cAAuCA,4CAAsC;CAC3E,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAkB;EAAkB;CAAQ;CAE5D,kBAAkB;CAElB,AAAU,cAAgD,IAAI;CAE9D,MAAMC,MAAmC;AACvC,SAAO,QAAQ,QAAQ,KAAK,YAAY,OAAO,KAAK,CAAC;CACtD;CAED,wBAAgC;AAC9B,SAAO;CACR;AACF"}
1
+ {"version":3,"file":"bytes.cjs","names":["BaseTransformOutputParser"],"sources":["../../src/output_parsers/bytes.ts"],"sourcesContent":["import { BaseTransformOutputParser } from \"./transform.js\";\n\n/**\n * OutputParser that parses LLMResult into the top likely string and\n * encodes it into bytes.\n */\nexport class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> {\n static lc_name() {\n return \"BytesOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\", \"bytes\"];\n\n lc_serializable = true;\n\n protected textEncoder: InstanceType<typeof TextEncoder> = new TextEncoder();\n\n parse(text: string): Promise<Uint8Array> {\n return Promise.resolve(this.textEncoder.encode(text));\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,oBAAb,cAAuCA,4CAAsC;CAC3E,OAAO,UAAU;AACf,SAAO;;CAGT,eAAe;EAAC;EAAkB;EAAkB;EAAQ;CAE5D,kBAAkB;CAElB,AAAU,cAAgD,IAAI,aAAa;CAE3E,MAAM,MAAmC;AACvC,SAAO,QAAQ,QAAQ,KAAK,YAAY,OAAO,KAAK,CAAC;;CAGvD,wBAAgC;AAC9B,SAAO"}
@@ -1,7 +1,6 @@
1
1
  import { BaseTransformOutputParser } from "./transform.cjs";
2
2
 
3
3
  //#region src/output_parsers/bytes.d.ts
4
-
5
4
  /**
6
5
  * OutputParser that parses LLMResult into the top likely string and
7
6
  * encodes it into bytes.
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.d.cts","names":["BaseTransformOutputParser","BytesOutputParser","Uint8Array","TextEncoder","InstanceType","Promise"],"sources":["../../src/output_parsers/bytes.d.ts"],"sourcesContent":["import { BaseTransformOutputParser } from \"./transform.js\";\n/**\n * OutputParser that parses LLMResult into the top likely string and\n * encodes it into bytes.\n */\nexport declare class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n protected textEncoder: InstanceType<typeof TextEncoder>;\n parse(text: string): Promise<Uint8Array>;\n getFormatInstructions(): string;\n}\n//# sourceMappingURL=bytes.d.ts.map"],"mappings":";;;;;;AAKA;;AAI+CG,cAJ1BF,iBAAAA,SAA0BD,yBAIAG,CAJ0BD,UAI1BC,CAAAA,CAAAA;EAApBC,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EACMF,YAAAA,EAAAA,MAAAA,EAAAA;EAARG,eAAAA,EAAAA,OAAAA;EALsBL,UAAAA,WAAAA,EAIpBI,YAJoBJ,CAAAA,OAIAG,WAJAH,CAAAA;EAAyB,KAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EAK/CK,OAL+C,CAKvCH,UALuC,CAAA"}
1
+ {"version":3,"file":"bytes.d.cts","names":[],"sources":["../../src/output_parsers/bytes.ts"],"mappings":";;;;;AAMA;;cAAa,iBAAA,SAA0B,yBAAA,CAA0B,UAAA;EAAA,OACxD,OAAA,CAAA;EAIP,YAAA;EAEA,eAAA;EAAA,UAEU,WAAA,EAAa,YAAA,QAAoB,WAAA;EAE3C,KAAA,CAAM,IAAA,WAAe,OAAA,CAAQ,UAAA;EAI7B,qBAAA,CAAA;AAAA"}
@@ -1,7 +1,6 @@
1
1
  import { BaseTransformOutputParser } from "./transform.js";
2
2
 
3
3
  //#region src/output_parsers/bytes.d.ts
4
-
5
4
  /**
6
5
  * OutputParser that parses LLMResult into the top likely string and
7
6
  * encodes it into bytes.
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.d.ts","names":["BaseTransformOutputParser","BytesOutputParser","Uint8Array","TextEncoder","InstanceType","Promise"],"sources":["../../src/output_parsers/bytes.d.ts"],"sourcesContent":["import { BaseTransformOutputParser } from \"./transform.js\";\n/**\n * OutputParser that parses LLMResult into the top likely string and\n * encodes it into bytes.\n */\nexport declare class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n protected textEncoder: InstanceType<typeof TextEncoder>;\n parse(text: string): Promise<Uint8Array>;\n getFormatInstructions(): string;\n}\n//# sourceMappingURL=bytes.d.ts.map"],"mappings":";;;;;;AAKA;;AAI+CG,cAJ1BF,iBAAAA,SAA0BD,yBAIAG,CAJ0BD,UAI1BC,CAAAA,CAAAA;EAApBC,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EACMF,YAAAA,EAAAA,MAAAA,EAAAA;EAARG,eAAAA,EAAAA,OAAAA;EALsBL,UAAAA,WAAAA,EAIpBI,YAJoBJ,CAAAA,OAIAG,WAJAH,CAAAA;EAAyB,KAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EAK/CK,OAL+C,CAKvCH,UALuC,CAAA"}
1
+ {"version":3,"file":"bytes.d.ts","names":[],"sources":["../../src/output_parsers/bytes.ts"],"mappings":";;;;;AAMA;;cAAa,iBAAA,SAA0B,yBAAA,CAA0B,UAAA;EAAA,OACxD,OAAA,CAAA;EAIP,YAAA;EAEA,eAAA;EAAA,UAEU,WAAA,EAAa,YAAA,QAAoB,WAAA;EAE3C,KAAA,CAAM,IAAA,WAAe,OAAA,CAAQ,UAAA;EAI7B,qBAAA,CAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.js","names":["text: string"],"sources":["../../src/output_parsers/bytes.ts"],"sourcesContent":["import { BaseTransformOutputParser } from \"./transform.js\";\n\n/**\n * OutputParser that parses LLMResult into the top likely string and\n * encodes it into bytes.\n */\nexport class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> {\n static lc_name() {\n return \"BytesOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\", \"bytes\"];\n\n lc_serializable = true;\n\n protected textEncoder: InstanceType<typeof TextEncoder> = new TextEncoder();\n\n parse(text: string): Promise<Uint8Array> {\n return Promise.resolve(this.textEncoder.encode(text));\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,oBAAb,cAAuC,0BAAsC;CAC3E,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAkB;EAAkB;CAAQ;CAE5D,kBAAkB;CAElB,AAAU,cAAgD,IAAI;CAE9D,MAAMA,MAAmC;AACvC,SAAO,QAAQ,QAAQ,KAAK,YAAY,OAAO,KAAK,CAAC;CACtD;CAED,wBAAgC;AAC9B,SAAO;CACR;AACF"}
1
+ {"version":3,"file":"bytes.js","names":[],"sources":["../../src/output_parsers/bytes.ts"],"sourcesContent":["import { BaseTransformOutputParser } from \"./transform.js\";\n\n/**\n * OutputParser that parses LLMResult into the top likely string and\n * encodes it into bytes.\n */\nexport class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> {\n static lc_name() {\n return \"BytesOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\", \"bytes\"];\n\n lc_serializable = true;\n\n protected textEncoder: InstanceType<typeof TextEncoder> = new TextEncoder();\n\n parse(text: string): Promise<Uint8Array> {\n return Promise.resolve(this.textEncoder.encode(text));\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,oBAAb,cAAuC,0BAAsC;CAC3E,OAAO,UAAU;AACf,SAAO;;CAGT,eAAe;EAAC;EAAkB;EAAkB;EAAQ;CAE5D,kBAAkB;CAElB,AAAU,cAAgD,IAAI,aAAa;CAE3E,MAAM,MAAmC;AACvC,SAAO,QAAQ,QAAQ,KAAK,YAAY,OAAO,KAAK,CAAC;;CAGvD,wBAAgC;AAC9B,SAAO"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_json = require('../utils/json.cjs');
3
4
  const require_base = require('./base.cjs');
4
5
  const require_transform = require('./transform.cjs');
@@ -10,8 +11,7 @@ const require_json$1 = require('./json.cjs');
10
11
  const require_xml = require('./xml.cjs');
11
12
 
12
13
  //#region src/output_parsers/index.ts
13
- var output_parsers_exports = {};
14
- require_rolldown_runtime.__export(output_parsers_exports, {
14
+ var output_parsers_exports = /* @__PURE__ */ require_runtime.__exportAll({
15
15
  AsymmetricStructuredOutputParser: () => require_structured.AsymmetricStructuredOutputParser,
16
16
  BaseCumulativeTransformOutputParser: () => require_transform.BaseCumulativeTransformOutputParser,
17
17
  BaseLLMOutputParser: () => require_base.BaseLLMOutputParser,
@@ -1,4 +1,4 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { parseJsonMarkdown, parsePartialJson } from "../utils/json.js";
3
3
  import { BaseLLMOutputParser, BaseOutputParser, OutputParserException } from "./base.js";
4
4
  import { BaseCumulativeTransformOutputParser, BaseTransformOutputParser } from "./transform.js";
@@ -10,8 +10,7 @@ import { JsonOutputParser } from "./json.js";
10
10
  import { XMLOutputParser, XML_FORMAT_INSTRUCTIONS, parseXMLMarkdown } from "./xml.js";
11
11
 
12
12
  //#region src/output_parsers/index.ts
13
- var output_parsers_exports = {};
14
- __export(output_parsers_exports, {
13
+ var output_parsers_exports = /* @__PURE__ */ __exportAll({
15
14
  AsymmetricStructuredOutputParser: () => AsymmetricStructuredOutputParser,
16
15
  BaseCumulativeTransformOutputParser: () => BaseCumulativeTransformOutputParser,
17
16
  BaseLLMOutputParser: () => BaseLLMOutputParser,
@@ -19,7 +19,7 @@ var JsonOutputParser = class extends require_transform.BaseCumulativeTransformOu
19
19
  return second;
20
20
  }
21
21
  _diff(prev, next) {
22
- if (!next) return void 0;
22
+ if (!next) return;
23
23
  if (!prev) return [{
24
24
  op: "replace",
25
25
  path: "",
@@ -1 +1 @@
1
- {"version":3,"file":"json.cjs","names":["BaseCumulativeTransformOutputParser","first: T","second: T","prev: unknown | undefined","next: unknown","compare","generations: ChatGeneration[] | Generation[]","parseJsonMarkdown","text: string","message: BaseMessage"],"sources":["../../src/output_parsers/json.ts"],"sourcesContent":["import { BaseCumulativeTransformOutputParser } from \"./transform.js\";\nimport { Operation, compare } from \"../utils/json_patch.js\";\nimport { ChatGeneration, Generation } from \"../outputs.js\";\nimport { parseJsonMarkdown, parsePartialJson } from \"../utils/json.js\";\nimport type { BaseMessage } from \"../messages/index.js\";\n\n/**\n * Class for parsing the output of an LLM into a JSON object.\n */\nexport class JsonOutputParser<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>,\n> extends BaseCumulativeTransformOutputParser<T> {\n static lc_name() {\n return \"JsonOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\"];\n\n lc_serializable = true;\n\n /** @internal */\n override _concatOutputChunks<T>(first: T, second: T): T {\n if (this.diff) {\n return super._concatOutputChunks(first, second);\n }\n return second;\n }\n\n protected _diff(\n prev: unknown | undefined,\n next: unknown\n ): Operation[] | undefined {\n if (!next) {\n return undefined;\n }\n if (!prev) {\n return [{ op: \"replace\", path: \"\", value: next }];\n }\n return compare(prev, next);\n }\n\n // This should actually return Partial<T>, but there's no way\n // to specify emitted chunks as instances separate from the main output type.\n async parsePartialResult(\n generations: ChatGeneration[] | Generation[]\n ): Promise<T | undefined> {\n return parseJsonMarkdown(generations[0].text) as T | undefined;\n }\n\n async parse(text: string): Promise<T> {\n return parseJsonMarkdown(text, JSON.parse) as T;\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n\n /**\n * Extracts text content from a message for JSON parsing.\n * Uses the message's `.text` accessor which properly handles both\n * string content and ContentBlock[] arrays (extracting text from text blocks).\n * @param message The message to extract text from\n * @returns The text content of the message\n */\n protected _baseMessageToString(message: BaseMessage): string {\n return message.text;\n }\n}\n\nexport { parsePartialJson, parseJsonMarkdown };\n"],"mappings":";;;;;;;;;AASA,IAAa,mBAAb,cAGUA,sDAAuC;CAC/C,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe,CAAC,kBAAkB,gBAAiB;CAEnD,kBAAkB;;CAGlB,AAAS,oBAAuBC,OAAUC,QAAc;AACtD,MAAI,KAAK,KACP,QAAO,MAAM,oBAAoB,OAAO,OAAO;AAEjD,SAAO;CACR;CAED,AAAU,MACRC,MACAC,MACyB;AACzB,MAAI,CAAC,KACH,QAAO;AAET,MAAI,CAAC,KACH,QAAO,CAAC;GAAE,IAAI;GAAW,MAAM;GAAI,OAAO;EAAM,CAAC;AAEnD,SAAOC,uBAAQ,MAAM,KAAK;CAC3B;CAID,MAAM,mBACJC,aACwB;AACxB,SAAOC,+BAAkB,YAAY,GAAG,KAAK;CAC9C;CAED,MAAM,MAAMC,MAA0B;AACpC,SAAOD,+BAAkB,MAAM,KAAK,MAAM;CAC3C;CAED,wBAAgC;AAC9B,SAAO;CACR;;;;;;;;CASD,AAAU,qBAAqBE,SAA8B;AAC3D,SAAO,QAAQ;CAChB;AACF"}
1
+ {"version":3,"file":"json.cjs","names":["BaseCumulativeTransformOutputParser","compare","parseJsonMarkdown"],"sources":["../../src/output_parsers/json.ts"],"sourcesContent":["import { BaseCumulativeTransformOutputParser } from \"./transform.js\";\nimport { Operation, compare } from \"../utils/json_patch.js\";\nimport { ChatGeneration, Generation } from \"../outputs.js\";\nimport { parseJsonMarkdown, parsePartialJson } from \"../utils/json.js\";\nimport type { BaseMessage } from \"../messages/index.js\";\n\n/**\n * Class for parsing the output of an LLM into a JSON object.\n */\nexport class JsonOutputParser<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>,\n> extends BaseCumulativeTransformOutputParser<T> {\n static lc_name() {\n return \"JsonOutputParser\";\n }\n\n lc_namespace = [\"langchain_core\", \"output_parsers\"];\n\n lc_serializable = true;\n\n /** @internal */\n override _concatOutputChunks<T>(first: T, second: T): T {\n if (this.diff) {\n return super._concatOutputChunks(first, second);\n }\n return second;\n }\n\n protected _diff(\n prev: unknown | undefined,\n next: unknown\n ): Operation[] | undefined {\n if (!next) {\n return undefined;\n }\n if (!prev) {\n return [{ op: \"replace\", path: \"\", value: next }];\n }\n return compare(prev, next);\n }\n\n // This should actually return Partial<T>, but there's no way\n // to specify emitted chunks as instances separate from the main output type.\n async parsePartialResult(\n generations: ChatGeneration[] | Generation[]\n ): Promise<T | undefined> {\n return parseJsonMarkdown(generations[0].text) as T | undefined;\n }\n\n async parse(text: string): Promise<T> {\n return parseJsonMarkdown(text, JSON.parse) as T;\n }\n\n getFormatInstructions(): string {\n return \"\";\n }\n\n /**\n * Extracts text content from a message for JSON parsing.\n * Uses the message's `.text` accessor which properly handles both\n * string content and ContentBlock[] arrays (extracting text from text blocks).\n * @param message The message to extract text from\n * @returns The text content of the message\n */\n protected _baseMessageToString(message: BaseMessage): string {\n return message.text;\n }\n}\n\nexport { parsePartialJson, parseJsonMarkdown };\n"],"mappings":";;;;;;;;;AASA,IAAa,mBAAb,cAGUA,sDAAuC;CAC/C,OAAO,UAAU;AACf,SAAO;;CAGT,eAAe,CAAC,kBAAkB,iBAAiB;CAEnD,kBAAkB;;CAGlB,AAAS,oBAAuB,OAAU,QAAc;AACtD,MAAI,KAAK,KACP,QAAO,MAAM,oBAAoB,OAAO,OAAO;AAEjD,SAAO;;CAGT,AAAU,MACR,MACA,MACyB;AACzB,MAAI,CAAC,KACH;AAEF,MAAI,CAAC,KACH,QAAO,CAAC;GAAE,IAAI;GAAW,MAAM;GAAI,OAAO;GAAM,CAAC;AAEnD,SAAOC,uBAAQ,MAAM,KAAK;;CAK5B,MAAM,mBACJ,aACwB;AACxB,SAAOC,+BAAkB,YAAY,GAAG,KAAK;;CAG/C,MAAM,MAAM,MAA0B;AACpC,SAAOA,+BAAkB,MAAM,KAAK,MAAM;;CAG5C,wBAAgC;AAC9B,SAAO;;;;;;;;;CAUT,AAAU,qBAAqB,SAA8B;AAC3D,SAAO,QAAQ"}
@@ -5,7 +5,6 @@ import { BaseCumulativeTransformOutputParser } from "./transform.cjs";
5
5
  import { parseJsonMarkdown, parsePartialJson } from "../utils/json.cjs";
6
6
 
7
7
  //#region src/output_parsers/json.d.ts
8
-
9
8
  /**
10
9
  * Class for parsing the output of an LLM into a JSON object.
11
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.cts","names":["BaseCumulativeTransformOutputParser","Operation","ChatGeneration","Generation","parseJsonMarkdown","parsePartialJson","BaseMessage","JsonOutputParser","T","Record","Promise"],"sources":["../../src/output_parsers/json.d.ts"],"sourcesContent":["import { BaseCumulativeTransformOutputParser } from \"./transform.js\";\nimport { Operation } from \"../utils/json_patch.js\";\nimport { ChatGeneration, Generation } from \"../outputs.js\";\nimport { parseJsonMarkdown, parsePartialJson } from \"../utils/json.js\";\nimport type { BaseMessage } from \"../messages/index.js\";\n/**\n * Class for parsing the output of an LLM into a JSON object.\n */\nexport declare class JsonOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n /** @internal */\n _concatOutputChunks<T>(first: T, second: T): T;\n protected _diff(prev: unknown | undefined, next: unknown): Operation[] | undefined;\n parsePartialResult(generations: ChatGeneration[] | Generation[]): Promise<T | undefined>;\n parse(text: string): Promise<T>;\n getFormatInstructions(): string;\n /**\n * Extracts text content from a message for JSON parsing.\n * Uses the message's `.text` accessor which properly handles both\n * string content and ContentBlock[] arrays (extracting text from text blocks).\n * @param message The message to extract text from\n * @returns The text content of the message\n */\n protected _baseMessageToString(message: BaseMessage): string;\n}\nexport { parsePartialJson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AA,UAO5C,KAAA,CACR,IAAA,uBACA,IAAA,YACC,SAAA;EAYG,kBAAA,CACJ,WAAA,EAAa,cAAA,KAAmB,UAAA,KAC/B,OAAA,CAAQ,CAAA;EAIL,KAAA,CAAM,IAAA,WAAe,OAAA,CAAQ,CAAA;EAInC,qBAAA,CAAA;EATkC;;;;;;;EAAA,UAoBxB,oBAAA,CAAqB,OAAA,EAAS,WAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","names":["BaseCumulativeTransformOutputParser","Operation","ChatGeneration","Generation","parseJsonMarkdown","parsePartialJson","BaseMessage","JsonOutputParser","T","Record","Promise"],"sources":["../../src/output_parsers/json.d.ts"],"sourcesContent":["import { BaseCumulativeTransformOutputParser } from \"./transform.js\";\nimport { Operation } from \"../utils/json_patch.js\";\nimport { ChatGeneration, Generation } from \"../outputs.js\";\nimport { parseJsonMarkdown, parsePartialJson } from \"../utils/json.js\";\nimport type { BaseMessage } from \"../messages/index.js\";\n/**\n * Class for parsing the output of an LLM into a JSON object.\n */\nexport declare class JsonOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n /** @internal */\n _concatOutputChunks<T>(first: T, second: T): T;\n protected _diff(prev: unknown | undefined, next: unknown): Operation[] | undefined;\n parsePartialResult(generations: ChatGeneration[] | Generation[]): Promise<T | undefined>;\n parse(text: string): Promise<T>;\n getFormatInstructions(): string;\n /**\n * Extracts text content from a message for JSON parsing.\n * Uses the message's `.text` accessor which properly handles both\n * string content and ContentBlock[] arrays (extracting text from text blocks).\n * @param message The message to extract text from\n * @returns The text content of the message\n */\n protected _baseMessageToString(message: BaseMessage): string;\n}\nexport { parsePartialJson, parseJsonMarkdown };\n//# sourceMappingURL=json.d.ts.map"],"mappings":";;;;;;;;;;;AAQqBO,cAAAA,gBAAgB,CAAA,UAAWE,MAAX,CAAA,MAAA,EAAA,GAAA,CAAA,GAA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AA;EATe;;;;;;;EAAA,UAoBL,oBAAA,CAAqB,OAAA,EAAS,WAAA;AAAA"}
@@ -19,7 +19,7 @@ var JsonOutputParser = class extends BaseCumulativeTransformOutputParser {
19
19
  return second;
20
20
  }
21
21
  _diff(prev, next) {
22
- if (!next) return void 0;
22
+ if (!next) return;
23
23
  if (!prev) return [{
24
24
  op: "replace",
25
25
  path: "",