@langchain/core 1.2.0-dev-1765937705265 → 1.2.0-dev-1775763803878

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 (1447) hide show
  1. package/CHANGELOG.md +309 -0
  2. package/README.md +1 -1
  3. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +7 -6
  4. package/dist/_virtual/_rolldown/runtime.js +13 -0
  5. package/dist/agents.cjs +8 -8
  6. package/dist/agents.cjs.map +1 -1
  7. package/dist/agents.d.cts.map +1 -1
  8. package/dist/agents.d.ts.map +1 -1
  9. package/dist/agents.js +3 -2
  10. package/dist/agents.js.map +1 -1
  11. package/dist/caches/index.cjs +12 -13
  12. package/dist/caches/index.cjs.map +1 -1
  13. package/dist/caches/index.d.cts.map +1 -1
  14. package/dist/caches/index.d.ts.map +1 -1
  15. package/dist/caches/index.js +4 -6
  16. package/dist/caches/index.js.map +1 -1
  17. package/dist/callbacks/base.cjs +17 -25
  18. package/dist/callbacks/base.cjs.map +1 -1
  19. package/dist/callbacks/base.d.cts +80 -38
  20. package/dist/callbacks/base.d.cts.map +1 -1
  21. package/dist/callbacks/base.d.ts +80 -38
  22. package/dist/callbacks/base.d.ts.map +1 -1
  23. package/dist/callbacks/base.js +7 -17
  24. package/dist/callbacks/base.js.map +1 -1
  25. package/dist/callbacks/dispatch/index.cjs +11 -12
  26. package/dist/callbacks/dispatch/index.cjs.map +1 -1
  27. package/dist/callbacks/dispatch/index.d.cts +0 -2
  28. package/dist/callbacks/dispatch/index.d.cts.map +1 -1
  29. package/dist/callbacks/dispatch/index.d.ts +0 -3
  30. package/dist/callbacks/dispatch/index.d.ts.map +1 -1
  31. package/dist/callbacks/dispatch/index.js +5 -7
  32. package/dist/callbacks/dispatch/index.js.map +1 -1
  33. package/dist/callbacks/dispatch/web.cjs +3 -3
  34. package/dist/callbacks/dispatch/web.cjs.map +1 -1
  35. package/dist/callbacks/dispatch/web.d.cts +0 -2
  36. package/dist/callbacks/dispatch/web.d.cts.map +1 -1
  37. package/dist/callbacks/dispatch/web.d.ts +0 -3
  38. package/dist/callbacks/dispatch/web.d.ts.map +1 -1
  39. package/dist/callbacks/dispatch/web.js +1 -2
  40. package/dist/callbacks/dispatch/web.js.map +1 -1
  41. package/dist/callbacks/manager.cjs +68 -76
  42. package/dist/callbacks/manager.cjs.map +1 -1
  43. package/dist/callbacks/manager.d.cts +3 -2
  44. package/dist/callbacks/manager.d.cts.map +1 -1
  45. package/dist/callbacks/manager.d.ts +3 -2
  46. package/dist/callbacks/manager.d.ts.map +1 -1
  47. package/dist/callbacks/manager.js +51 -60
  48. package/dist/callbacks/manager.js.map +1 -1
  49. package/dist/callbacks/promises.cjs +10 -11
  50. package/dist/callbacks/promises.js +3 -5
  51. package/dist/chat_history.cjs +13 -14
  52. package/dist/chat_history.cjs.map +1 -1
  53. package/dist/chat_history.d.cts +0 -2
  54. package/dist/chat_history.d.cts.map +1 -1
  55. package/dist/chat_history.d.ts +0 -3
  56. package/dist/chat_history.d.ts.map +1 -1
  57. package/dist/chat_history.js +4 -6
  58. package/dist/chat_history.js.map +1 -1
  59. package/dist/context.cjs +14 -7
  60. package/dist/context.cjs.map +1 -1
  61. package/dist/context.d.cts.map +1 -1
  62. package/dist/context.d.ts.map +1 -1
  63. package/dist/context.js +8 -2
  64. package/dist/context.js.map +1 -1
  65. package/dist/document_loaders/base.cjs +8 -10
  66. package/dist/document_loaders/base.cjs.map +1 -1
  67. package/dist/document_loaders/base.d.cts +0 -1
  68. package/dist/document_loaders/base.d.cts.map +1 -1
  69. package/dist/document_loaders/base.d.ts +0 -1
  70. package/dist/document_loaders/base.d.ts.map +1 -1
  71. package/dist/document_loaders/base.js +3 -5
  72. package/dist/document_loaders/base.js.map +1 -1
  73. package/dist/document_loaders/langsmith.cjs +11 -12
  74. package/dist/document_loaders/langsmith.cjs.map +1 -1
  75. package/dist/document_loaders/langsmith.d.cts.map +1 -1
  76. package/dist/document_loaders/langsmith.d.ts.map +1 -1
  77. package/dist/document_loaders/langsmith.js +3 -5
  78. package/dist/document_loaders/langsmith.js.map +1 -1
  79. package/dist/documents/document.cjs +1 -2
  80. package/dist/documents/document.cjs.map +1 -1
  81. package/dist/documents/document.d.cts.map +1 -1
  82. package/dist/documents/document.d.ts.map +1 -1
  83. package/dist/documents/document.js +1 -1
  84. package/dist/documents/document.js.map +1 -1
  85. package/dist/documents/index.cjs +11 -12
  86. package/dist/documents/index.js +3 -5
  87. package/dist/documents/transformers.cjs +2 -3
  88. package/dist/documents/transformers.cjs.map +1 -1
  89. package/dist/documents/transformers.d.cts +0 -1
  90. package/dist/documents/transformers.d.cts.map +1 -1
  91. package/dist/documents/transformers.d.ts +0 -1
  92. package/dist/documents/transformers.d.ts.map +1 -1
  93. package/dist/documents/transformers.js +1 -2
  94. package/dist/documents/transformers.js.map +1 -1
  95. package/dist/embeddings.cjs +10 -11
  96. package/dist/embeddings.cjs.map +1 -1
  97. package/dist/embeddings.d.cts +0 -1
  98. package/dist/embeddings.d.cts.map +1 -1
  99. package/dist/embeddings.d.ts +0 -1
  100. package/dist/embeddings.d.ts.map +1 -1
  101. package/dist/embeddings.js +3 -5
  102. package/dist/embeddings.js.map +1 -1
  103. package/dist/errors/index.cjs +165 -2
  104. package/dist/errors/index.cjs.map +1 -1
  105. package/dist/errors/index.d.cts +150 -0
  106. package/dist/errors/index.d.cts.map +1 -0
  107. package/dist/errors/index.d.ts +150 -0
  108. package/dist/errors/index.d.ts.map +1 -0
  109. package/dist/errors/index.js +155 -2
  110. package/dist/errors/index.js.map +1 -1
  111. package/dist/example_selectors/base.cjs +2 -3
  112. package/dist/example_selectors/base.cjs.map +1 -1
  113. package/dist/example_selectors/base.d.cts +0 -1
  114. package/dist/example_selectors/base.d.cts.map +1 -1
  115. package/dist/example_selectors/base.d.ts +0 -1
  116. package/dist/example_selectors/base.d.ts.map +1 -1
  117. package/dist/example_selectors/base.js +1 -2
  118. package/dist/example_selectors/base.js.map +1 -1
  119. package/dist/example_selectors/conditional.cjs +2 -4
  120. package/dist/example_selectors/conditional.cjs.map +1 -1
  121. package/dist/example_selectors/conditional.d.cts.map +1 -1
  122. package/dist/example_selectors/conditional.d.ts.map +1 -1
  123. package/dist/example_selectors/conditional.js +2 -3
  124. package/dist/example_selectors/conditional.js.map +1 -1
  125. package/dist/example_selectors/index.cjs +13 -14
  126. package/dist/example_selectors/index.js +3 -5
  127. package/dist/example_selectors/length_based.cjs +3 -5
  128. package/dist/example_selectors/length_based.cjs.map +1 -1
  129. package/dist/example_selectors/length_based.d.cts +0 -1
  130. package/dist/example_selectors/length_based.d.cts.map +1 -1
  131. package/dist/example_selectors/length_based.d.ts +0 -1
  132. package/dist/example_selectors/length_based.d.ts.map +1 -1
  133. package/dist/example_selectors/length_based.js +2 -4
  134. package/dist/example_selectors/length_based.js.map +1 -1
  135. package/dist/example_selectors/semantic_similarity.cjs +7 -12
  136. package/dist/example_selectors/semantic_similarity.cjs.map +1 -1
  137. package/dist/example_selectors/semantic_similarity.d.cts +0 -1
  138. package/dist/example_selectors/semantic_similarity.d.cts.map +1 -1
  139. package/dist/example_selectors/semantic_similarity.d.ts +0 -1
  140. package/dist/example_selectors/semantic_similarity.d.ts.map +1 -1
  141. package/dist/example_selectors/semantic_similarity.js +5 -10
  142. package/dist/example_selectors/semantic_similarity.js.map +1 -1
  143. package/dist/index.cjs +8 -8
  144. package/dist/index.js +3 -2
  145. package/dist/indexing/base.cjs +12 -17
  146. package/dist/indexing/base.cjs.map +1 -1
  147. package/dist/indexing/base.d.cts.map +1 -1
  148. package/dist/indexing/base.d.ts.map +1 -1
  149. package/dist/indexing/base.js +6 -11
  150. package/dist/indexing/base.js.map +1 -1
  151. package/dist/indexing/index.cjs +11 -12
  152. package/dist/indexing/index.js +3 -5
  153. package/dist/indexing/record_manager.cjs +2 -3
  154. package/dist/indexing/record_manager.cjs.map +1 -1
  155. package/dist/indexing/record_manager.d.cts.map +1 -1
  156. package/dist/indexing/record_manager.d.ts.map +1 -1
  157. package/dist/indexing/record_manager.js +1 -2
  158. package/dist/indexing/record_manager.js.map +1 -1
  159. package/dist/language_models/base.cjs +32 -26
  160. package/dist/language_models/base.cjs.map +1 -1
  161. package/dist/language_models/base.d.cts +17 -14
  162. package/dist/language_models/base.d.cts.map +1 -1
  163. package/dist/language_models/base.d.ts +17 -16
  164. package/dist/language_models/base.d.ts.map +1 -1
  165. package/dist/language_models/base.js +21 -16
  166. package/dist/language_models/base.js.map +1 -1
  167. package/dist/language_models/chat_models.cjs +130 -70
  168. package/dist/language_models/chat_models.cjs.map +1 -1
  169. package/dist/language_models/chat_models.d.cts +76 -10
  170. package/dist/language_models/chat_models.d.cts.map +1 -1
  171. package/dist/language_models/chat_models.d.ts +76 -13
  172. package/dist/language_models/chat_models.d.ts.map +1 -1
  173. package/dist/language_models/chat_models.js +111 -52
  174. package/dist/language_models/chat_models.js.map +1 -1
  175. package/dist/language_models/compat.cjs +235 -0
  176. package/dist/language_models/compat.cjs.map +1 -0
  177. package/dist/language_models/compat.d.cts +34 -0
  178. package/dist/language_models/compat.d.cts.map +1 -0
  179. package/dist/language_models/compat.d.ts +34 -0
  180. package/dist/language_models/compat.d.ts.map +1 -0
  181. package/dist/language_models/compat.js +226 -0
  182. package/dist/language_models/compat.js.map +1 -0
  183. package/dist/language_models/event.cjs +12 -0
  184. package/dist/language_models/event.cjs.map +1 -0
  185. package/dist/language_models/event.d.cts +193 -0
  186. package/dist/language_models/event.d.cts.map +1 -0
  187. package/dist/language_models/event.d.ts +193 -0
  188. package/dist/language_models/event.d.ts.map +1 -0
  189. package/dist/language_models/event.js +7 -0
  190. package/dist/language_models/event.js.map +1 -0
  191. package/dist/language_models/llms.cjs +23 -27
  192. package/dist/language_models/llms.cjs.map +1 -1
  193. package/dist/language_models/llms.d.cts +4 -4
  194. package/dist/language_models/llms.d.cts.map +1 -1
  195. package/dist/language_models/llms.d.ts +4 -5
  196. package/dist/language_models/llms.d.ts.map +1 -1
  197. package/dist/language_models/llms.js +12 -17
  198. package/dist/language_models/llms.js.map +1 -1
  199. package/dist/language_models/profile.cjs +8 -8
  200. package/dist/language_models/profile.d.cts.map +1 -1
  201. package/dist/language_models/profile.d.ts.map +1 -1
  202. package/dist/language_models/profile.js +3 -2
  203. package/dist/language_models/stream.cjs +376 -0
  204. package/dist/language_models/stream.cjs.map +1 -0
  205. package/dist/language_models/stream.d.cts +129 -0
  206. package/dist/language_models/stream.d.cts.map +1 -0
  207. package/dist/language_models/stream.d.ts +129 -0
  208. package/dist/language_models/stream.d.ts.map +1 -0
  209. package/dist/language_models/stream.js +365 -0
  210. package/dist/language_models/stream.js.map +1 -0
  211. package/dist/language_models/structured_output.cjs +87 -0
  212. package/dist/language_models/structured_output.cjs.map +1 -0
  213. package/dist/language_models/structured_output.d.cts +45 -0
  214. package/dist/language_models/structured_output.d.cts.map +1 -0
  215. package/dist/language_models/structured_output.d.ts +45 -0
  216. package/dist/language_models/structured_output.d.ts.map +1 -0
  217. package/dist/language_models/structured_output.js +78 -0
  218. package/dist/language_models/structured_output.js.map +1 -0
  219. package/dist/language_models/utils.cjs +1 -2
  220. package/dist/language_models/utils.cjs.map +1 -1
  221. package/dist/language_models/utils.js +1 -1
  222. package/dist/language_models/utils.js.map +1 -1
  223. package/dist/load/import_constants.cjs +1 -2
  224. package/dist/load/import_constants.cjs.map +1 -1
  225. package/dist/load/import_constants.js +1 -1
  226. package/dist/load/import_constants.js.map +1 -1
  227. package/dist/load/import_map.cjs +82 -66
  228. package/dist/load/import_map.cjs.map +1 -1
  229. package/dist/load/import_map.js +45 -29
  230. package/dist/load/import_map.js.map +1 -1
  231. package/dist/load/import_type.d.cts.map +1 -1
  232. package/dist/load/import_type.d.ts.map +1 -1
  233. package/dist/load/index.cjs +160 -41
  234. package/dist/load/index.cjs.map +1 -1
  235. package/dist/load/index.d.cts +122 -3
  236. package/dist/load/index.d.cts.map +1 -1
  237. package/dist/load/index.d.ts +122 -3
  238. package/dist/load/index.d.ts.map +1 -1
  239. package/dist/load/index.js +149 -31
  240. package/dist/load/index.js.map +1 -1
  241. package/dist/load/map_keys.cjs +6 -5
  242. package/dist/load/map_keys.cjs.map +1 -1
  243. package/dist/load/map_keys.d.cts.map +1 -1
  244. package/dist/load/map_keys.d.ts.map +1 -1
  245. package/dist/load/map_keys.js +1 -2
  246. package/dist/load/map_keys.js.map +1 -1
  247. package/dist/load/serializable.cjs +22 -26
  248. package/dist/load/serializable.cjs.map +1 -1
  249. package/dist/load/serializable.d.cts +15 -1
  250. package/dist/load/serializable.d.cts.map +1 -1
  251. package/dist/load/serializable.d.ts +15 -1
  252. package/dist/load/serializable.d.ts.map +1 -1
  253. package/dist/load/serializable.js +15 -20
  254. package/dist/load/serializable.js.map +1 -1
  255. package/dist/load/validation.cjs +120 -0
  256. package/dist/load/validation.cjs.map +1 -0
  257. package/dist/load/validation.js +118 -0
  258. package/dist/load/validation.js.map +1 -0
  259. package/dist/memory.cjs +10 -18
  260. package/dist/memory.cjs.map +1 -1
  261. package/dist/memory.d.cts +2 -2
  262. package/dist/memory.d.cts.map +1 -1
  263. package/dist/memory.d.ts +2 -2
  264. package/dist/memory.d.ts.map +1 -1
  265. package/dist/memory.js +5 -13
  266. package/dist/memory.js.map +1 -1
  267. package/dist/messages/ai.cjs +15 -9
  268. package/dist/messages/ai.cjs.map +1 -1
  269. package/dist/messages/ai.d.cts +2 -2
  270. package/dist/messages/ai.d.cts.map +1 -1
  271. package/dist/messages/ai.d.ts +2 -2
  272. package/dist/messages/ai.d.ts.map +1 -1
  273. package/dist/messages/ai.js +10 -4
  274. package/dist/messages/ai.js.map +1 -1
  275. package/dist/messages/base.cjs +111 -44
  276. package/dist/messages/base.cjs.map +1 -1
  277. package/dist/messages/base.d.cts +49 -12
  278. package/dist/messages/base.d.cts.map +1 -1
  279. package/dist/messages/base.d.ts +49 -12
  280. package/dist/messages/base.d.ts.map +1 -1
  281. package/dist/messages/base.js +104 -38
  282. package/dist/messages/base.js.map +1 -1
  283. package/dist/messages/block_translators/anthropic.cjs +32 -38
  284. package/dist/messages/block_translators/anthropic.cjs.map +1 -1
  285. package/dist/messages/block_translators/anthropic.js +31 -37
  286. package/dist/messages/block_translators/anthropic.js.map +1 -1
  287. package/dist/messages/block_translators/bedrock_converse.cjs +40 -49
  288. package/dist/messages/block_translators/bedrock_converse.cjs.map +1 -1
  289. package/dist/messages/block_translators/bedrock_converse.js +39 -48
  290. package/dist/messages/block_translators/bedrock_converse.js.map +1 -1
  291. package/dist/messages/block_translators/data.cjs +3 -4
  292. package/dist/messages/block_translators/data.cjs.map +1 -1
  293. package/dist/messages/block_translators/data.js +1 -2
  294. package/dist/messages/block_translators/data.js.map +1 -1
  295. package/dist/messages/block_translators/deepseek.cjs +58 -0
  296. package/dist/messages/block_translators/deepseek.cjs.map +1 -0
  297. package/dist/messages/block_translators/deepseek.js +58 -0
  298. package/dist/messages/block_translators/deepseek.js.map +1 -0
  299. package/dist/messages/block_translators/google.cjs +97 -0
  300. package/dist/messages/block_translators/google.cjs.map +1 -0
  301. package/dist/messages/block_translators/google.js +97 -0
  302. package/dist/messages/block_translators/google.js.map +1 -0
  303. package/dist/messages/block_translators/google_genai.cjs +9 -3
  304. package/dist/messages/block_translators/google_genai.cjs.map +1 -1
  305. package/dist/messages/block_translators/google_genai.js +8 -2
  306. package/dist/messages/block_translators/google_genai.js.map +1 -1
  307. package/dist/messages/block_translators/google_vertexai.cjs +10 -6
  308. package/dist/messages/block_translators/google_vertexai.cjs.map +1 -1
  309. package/dist/messages/block_translators/google_vertexai.js +9 -5
  310. package/dist/messages/block_translators/google_vertexai.js.map +1 -1
  311. package/dist/messages/block_translators/groq.cjs +96 -0
  312. package/dist/messages/block_translators/groq.cjs.map +1 -0
  313. package/dist/messages/block_translators/groq.js +96 -0
  314. package/dist/messages/block_translators/groq.js.map +1 -0
  315. package/dist/messages/block_translators/index.cjs +17 -8
  316. package/dist/messages/block_translators/index.cjs.map +1 -1
  317. package/dist/messages/block_translators/index.js +12 -3
  318. package/dist/messages/block_translators/index.js.map +1 -1
  319. package/dist/messages/block_translators/ollama.cjs +58 -0
  320. package/dist/messages/block_translators/ollama.cjs.map +1 -0
  321. package/dist/messages/block_translators/ollama.js +58 -0
  322. package/dist/messages/block_translators/ollama.js.map +1 -0
  323. package/dist/messages/block_translators/openai.cjs +85 -26
  324. package/dist/messages/block_translators/openai.cjs.map +1 -1
  325. package/dist/messages/block_translators/openai.js +83 -24
  326. package/dist/messages/block_translators/openai.js.map +1 -1
  327. package/dist/messages/block_translators/utils.cjs +2 -3
  328. package/dist/messages/block_translators/utils.cjs.map +1 -1
  329. package/dist/messages/block_translators/utils.js +2 -2
  330. package/dist/messages/block_translators/utils.js.map +1 -1
  331. package/dist/messages/block_translators/xai.cjs +94 -0
  332. package/dist/messages/block_translators/xai.cjs.map +1 -0
  333. package/dist/messages/block_translators/xai.js +94 -0
  334. package/dist/messages/block_translators/xai.js.map +1 -0
  335. package/dist/messages/chat.cjs +2 -3
  336. package/dist/messages/chat.cjs.map +1 -1
  337. package/dist/messages/chat.d.cts.map +1 -1
  338. package/dist/messages/chat.d.ts.map +1 -1
  339. package/dist/messages/chat.js +1 -2
  340. package/dist/messages/chat.js.map +1 -1
  341. package/dist/messages/content/base.d.cts.map +1 -1
  342. package/dist/messages/content/base.d.ts.map +1 -1
  343. package/dist/messages/content/data.cjs +2 -5
  344. package/dist/messages/content/data.cjs.map +1 -1
  345. package/dist/messages/content/data.d.cts +0 -1
  346. package/dist/messages/content/data.d.cts.map +1 -1
  347. package/dist/messages/content/data.d.ts +0 -1
  348. package/dist/messages/content/data.d.ts.map +1 -1
  349. package/dist/messages/content/data.js +2 -4
  350. package/dist/messages/content/data.js.map +1 -1
  351. package/dist/messages/content/index.cjs +5 -6
  352. package/dist/messages/content/index.cjs.map +1 -1
  353. package/dist/messages/content/index.d.cts +7 -3
  354. package/dist/messages/content/index.d.cts.map +1 -1
  355. package/dist/messages/content/index.d.ts +7 -3
  356. package/dist/messages/content/index.d.ts.map +1 -1
  357. package/dist/messages/content/index.js +7 -8
  358. package/dist/messages/content/index.js.map +1 -1
  359. package/dist/messages/content/multimodal.cjs +1 -2
  360. package/dist/messages/content/multimodal.cjs.map +1 -1
  361. package/dist/messages/content/multimodal.d.cts +4 -8
  362. package/dist/messages/content/multimodal.d.cts.map +1 -1
  363. package/dist/messages/content/multimodal.d.ts +4 -8
  364. package/dist/messages/content/multimodal.d.ts.map +1 -1
  365. package/dist/messages/content/multimodal.js +1 -1
  366. package/dist/messages/content/multimodal.js.map +1 -1
  367. package/dist/messages/content/tools.cjs +1 -2
  368. package/dist/messages/content/tools.cjs.map +1 -1
  369. package/dist/messages/content/tools.d.cts +1 -1
  370. package/dist/messages/content/tools.d.cts.map +1 -1
  371. package/dist/messages/content/tools.d.ts +1 -1
  372. package/dist/messages/content/tools.d.ts.map +1 -1
  373. package/dist/messages/content/tools.js +1 -1
  374. package/dist/messages/content/tools.js.map +1 -1
  375. package/dist/messages/format.cjs +1 -2
  376. package/dist/messages/format.cjs.map +1 -1
  377. package/dist/messages/format.d.cts.map +1 -1
  378. package/dist/messages/format.d.ts.map +1 -1
  379. package/dist/messages/format.js +1 -1
  380. package/dist/messages/format.js.map +1 -1
  381. package/dist/messages/function.cjs +2 -3
  382. package/dist/messages/function.cjs.map +1 -1
  383. package/dist/messages/function.d.cts.map +1 -1
  384. package/dist/messages/function.d.ts.map +1 -1
  385. package/dist/messages/function.js +1 -2
  386. package/dist/messages/function.js.map +1 -1
  387. package/dist/messages/human.cjs +2 -3
  388. package/dist/messages/human.cjs.map +1 -1
  389. package/dist/messages/human.d.cts.map +1 -1
  390. package/dist/messages/human.d.ts.map +1 -1
  391. package/dist/messages/human.js +1 -2
  392. package/dist/messages/human.js.map +1 -1
  393. package/dist/messages/index.cjs +25 -24
  394. package/dist/messages/index.d.cts +3 -3
  395. package/dist/messages/index.d.ts +3 -3
  396. package/dist/messages/index.js +7 -8
  397. package/dist/messages/message.cjs +1 -2
  398. package/dist/messages/message.cjs.map +1 -1
  399. package/dist/messages/message.d.cts +50 -27
  400. package/dist/messages/message.d.cts.map +1 -1
  401. package/dist/messages/message.d.ts +50 -27
  402. package/dist/messages/message.d.ts.map +1 -1
  403. package/dist/messages/message.js +1 -1
  404. package/dist/messages/message.js.map +1 -1
  405. package/dist/messages/metadata.cjs +3 -5
  406. package/dist/messages/metadata.cjs.map +1 -1
  407. package/dist/messages/metadata.d.cts.map +1 -1
  408. package/dist/messages/metadata.d.ts.map +1 -1
  409. package/dist/messages/metadata.js +2 -4
  410. package/dist/messages/metadata.js.map +1 -1
  411. package/dist/messages/modifier.cjs +2 -3
  412. package/dist/messages/modifier.cjs.map +1 -1
  413. package/dist/messages/modifier.d.cts.map +1 -1
  414. package/dist/messages/modifier.d.ts.map +1 -1
  415. package/dist/messages/modifier.js +1 -2
  416. package/dist/messages/modifier.js.map +1 -1
  417. package/dist/messages/system.cjs +10 -7
  418. package/dist/messages/system.cjs.map +1 -1
  419. package/dist/messages/system.d.cts.map +1 -1
  420. package/dist/messages/system.d.ts.map +1 -1
  421. package/dist/messages/system.js +9 -6
  422. package/dist/messages/system.js.map +1 -1
  423. package/dist/messages/tool.cjs +10 -11
  424. package/dist/messages/tool.cjs.map +1 -1
  425. package/dist/messages/tool.d.cts +1 -1
  426. package/dist/messages/tool.d.cts.map +1 -1
  427. package/dist/messages/tool.d.ts +1 -1
  428. package/dist/messages/tool.d.ts.map +1 -1
  429. package/dist/messages/tool.js +3 -5
  430. package/dist/messages/tool.js.map +1 -1
  431. package/dist/messages/transformers.cjs +18 -25
  432. package/dist/messages/transformers.cjs.map +1 -1
  433. package/dist/messages/transformers.d.cts.map +1 -1
  434. package/dist/messages/transformers.d.ts.map +1 -1
  435. package/dist/messages/transformers.js +9 -16
  436. package/dist/messages/transformers.js.map +1 -1
  437. package/dist/messages/utils.cjs +71 -32
  438. package/dist/messages/utils.cjs.map +1 -1
  439. package/dist/messages/utils.d.cts +16 -7
  440. package/dist/messages/utils.d.cts.map +1 -1
  441. package/dist/messages/utils.d.ts +16 -7
  442. package/dist/messages/utils.d.ts.map +1 -1
  443. package/dist/messages/utils.js +63 -24
  444. package/dist/messages/utils.js.map +1 -1
  445. package/dist/output_parsers/base.cjs +10 -11
  446. package/dist/output_parsers/base.cjs.map +1 -1
  447. package/dist/output_parsers/base.d.cts +0 -1
  448. package/dist/output_parsers/base.d.cts.map +1 -1
  449. package/dist/output_parsers/base.d.ts +0 -4
  450. package/dist/output_parsers/base.d.ts.map +1 -1
  451. package/dist/output_parsers/base.js +6 -7
  452. package/dist/output_parsers/base.js.map +1 -1
  453. package/dist/output_parsers/bytes.cjs +2 -3
  454. package/dist/output_parsers/bytes.cjs.map +1 -1
  455. package/dist/output_parsers/bytes.d.cts +0 -1
  456. package/dist/output_parsers/bytes.d.cts.map +1 -1
  457. package/dist/output_parsers/bytes.d.ts +0 -1
  458. package/dist/output_parsers/bytes.d.ts.map +1 -1
  459. package/dist/output_parsers/bytes.js +1 -2
  460. package/dist/output_parsers/bytes.js.map +1 -1
  461. package/dist/output_parsers/index.cjs +21 -19
  462. package/dist/output_parsers/index.cjs.map +1 -1
  463. package/dist/output_parsers/index.d.cts +2 -1
  464. package/dist/output_parsers/index.d.ts +2 -1
  465. package/dist/output_parsers/index.js +7 -7
  466. package/dist/output_parsers/index.js.map +1 -1
  467. package/dist/output_parsers/json.cjs +16 -7
  468. package/dist/output_parsers/json.cjs.map +1 -1
  469. package/dist/output_parsers/json.d.cts +9 -1
  470. package/dist/output_parsers/json.d.cts.map +1 -1
  471. package/dist/output_parsers/json.d.ts +9 -1
  472. package/dist/output_parsers/json.d.ts.map +1 -1
  473. package/dist/output_parsers/json.js +13 -4
  474. package/dist/output_parsers/json.js.map +1 -1
  475. package/dist/output_parsers/list.cjs +3 -4
  476. package/dist/output_parsers/list.cjs.map +1 -1
  477. package/dist/output_parsers/list.d.cts +0 -1
  478. package/dist/output_parsers/list.d.cts.map +1 -1
  479. package/dist/output_parsers/list.d.ts +0 -2
  480. package/dist/output_parsers/list.d.ts.map +1 -1
  481. package/dist/output_parsers/list.js +1 -2
  482. package/dist/output_parsers/list.js.map +1 -1
  483. package/dist/output_parsers/openai_functions/index.cjs +10 -11
  484. package/dist/output_parsers/openai_functions/index.js +3 -5
  485. package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs +13 -17
  486. package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs.map +1 -1
  487. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -2
  488. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -1
  489. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -2
  490. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -1
  491. package/dist/output_parsers/openai_functions/json_output_functions_parsers.js +7 -11
  492. package/dist/output_parsers/openai_functions/json_output_functions_parsers.js.map +1 -1
  493. package/dist/output_parsers/openai_tools/index.cjs +10 -11
  494. package/dist/output_parsers/openai_tools/index.d.cts +2 -2
  495. package/dist/output_parsers/openai_tools/index.d.ts +2 -2
  496. package/dist/output_parsers/openai_tools/index.js +3 -5
  497. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +29 -30
  498. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  499. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +10 -8
  500. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -1
  501. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +10 -8
  502. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -1
  503. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +23 -24
  504. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  505. package/dist/output_parsers/standard_schema.cjs +39 -0
  506. package/dist/output_parsers/standard_schema.cjs.map +1 -0
  507. package/dist/output_parsers/standard_schema.d.cts +16 -0
  508. package/dist/output_parsers/standard_schema.d.cts.map +1 -0
  509. package/dist/output_parsers/standard_schema.d.ts +16 -0
  510. package/dist/output_parsers/standard_schema.d.ts.map +1 -0
  511. package/dist/output_parsers/standard_schema.js +39 -0
  512. package/dist/output_parsers/standard_schema.js.map +1 -0
  513. package/dist/output_parsers/string.cjs +5 -3
  514. package/dist/output_parsers/string.cjs.map +1 -1
  515. package/dist/output_parsers/string.d.cts +0 -1
  516. package/dist/output_parsers/string.d.cts.map +1 -1
  517. package/dist/output_parsers/string.d.ts +0 -2
  518. package/dist/output_parsers/string.d.ts.map +1 -1
  519. package/dist/output_parsers/string.js +4 -2
  520. package/dist/output_parsers/string.js.map +1 -1
  521. package/dist/output_parsers/structured.cjs +14 -18
  522. package/dist/output_parsers/structured.cjs.map +1 -1
  523. package/dist/output_parsers/structured.d.cts.map +1 -1
  524. package/dist/output_parsers/structured.d.ts.map +1 -1
  525. package/dist/output_parsers/structured.js +9 -13
  526. package/dist/output_parsers/structured.js.map +1 -1
  527. package/dist/output_parsers/transform.cjs +8 -9
  528. package/dist/output_parsers/transform.cjs.map +1 -1
  529. package/dist/output_parsers/transform.d.cts +0 -1
  530. package/dist/output_parsers/transform.d.cts.map +1 -1
  531. package/dist/output_parsers/transform.d.ts +0 -1
  532. package/dist/output_parsers/transform.d.ts.map +1 -1
  533. package/dist/output_parsers/transform.js +1 -2
  534. package/dist/output_parsers/transform.js.map +1 -1
  535. package/dist/output_parsers/xml.cjs +11 -15
  536. package/dist/output_parsers/xml.cjs.map +1 -1
  537. package/dist/output_parsers/xml.d.cts +1 -1
  538. package/dist/output_parsers/xml.d.cts.map +1 -1
  539. package/dist/output_parsers/xml.d.ts +1 -1
  540. package/dist/output_parsers/xml.d.ts.map +1 -1
  541. package/dist/output_parsers/xml.js +7 -11
  542. package/dist/output_parsers/xml.js.map +1 -1
  543. package/dist/outputs.cjs +8 -10
  544. package/dist/outputs.cjs.map +1 -1
  545. package/dist/outputs.d.cts.map +1 -1
  546. package/dist/outputs.d.ts.map +1 -1
  547. package/dist/outputs.js +3 -5
  548. package/dist/outputs.js.map +1 -1
  549. package/dist/prompt_values.cjs +12 -13
  550. package/dist/prompt_values.cjs.map +1 -1
  551. package/dist/prompt_values.d.cts +1 -3
  552. package/dist/prompt_values.d.cts.map +1 -1
  553. package/dist/prompt_values.d.ts +1 -3
  554. package/dist/prompt_values.d.ts.map +1 -1
  555. package/dist/prompt_values.js +3 -5
  556. package/dist/prompt_values.js.map +1 -1
  557. package/dist/prompts/base.cjs +4 -6
  558. package/dist/prompts/base.cjs.map +1 -1
  559. package/dist/prompts/base.d.cts +0 -1
  560. package/dist/prompts/base.d.cts.map +1 -1
  561. package/dist/prompts/base.d.ts +0 -2
  562. package/dist/prompts/base.d.ts.map +1 -1
  563. package/dist/prompts/base.js +3 -5
  564. package/dist/prompts/base.js.map +1 -1
  565. package/dist/prompts/chat.cjs +37 -53
  566. package/dist/prompts/chat.cjs.map +1 -1
  567. package/dist/prompts/chat.d.cts +1 -0
  568. package/dist/prompts/chat.d.cts.map +1 -1
  569. package/dist/prompts/chat.d.ts +1 -1
  570. package/dist/prompts/chat.d.ts.map +1 -1
  571. package/dist/prompts/chat.js +23 -39
  572. package/dist/prompts/chat.js.map +1 -1
  573. package/dist/prompts/dict.cjs +3 -4
  574. package/dist/prompts/dict.cjs.map +1 -1
  575. package/dist/prompts/dict.d.cts.map +1 -1
  576. package/dist/prompts/dict.d.ts.map +1 -1
  577. package/dist/prompts/dict.js +1 -2
  578. package/dist/prompts/dict.js.map +1 -1
  579. package/dist/prompts/few_shot.cjs +14 -20
  580. package/dist/prompts/few_shot.cjs.map +1 -1
  581. package/dist/prompts/few_shot.d.cts.map +1 -1
  582. package/dist/prompts/few_shot.d.ts +0 -1
  583. package/dist/prompts/few_shot.d.ts.map +1 -1
  584. package/dist/prompts/few_shot.js +10 -16
  585. package/dist/prompts/few_shot.js.map +1 -1
  586. package/dist/prompts/image.cjs +7 -10
  587. package/dist/prompts/image.cjs.map +1 -1
  588. package/dist/prompts/image.d.cts +0 -1
  589. package/dist/prompts/image.d.cts.map +1 -1
  590. package/dist/prompts/image.d.ts +0 -2
  591. package/dist/prompts/image.d.ts.map +1 -1
  592. package/dist/prompts/image.js +4 -7
  593. package/dist/prompts/image.js.map +1 -1
  594. package/dist/prompts/index.cjs +19 -20
  595. package/dist/prompts/index.js +3 -5
  596. package/dist/prompts/pipeline.cjs +3 -4
  597. package/dist/prompts/pipeline.cjs.map +1 -1
  598. package/dist/prompts/pipeline.d.cts +0 -1
  599. package/dist/prompts/pipeline.d.cts.map +1 -1
  600. package/dist/prompts/pipeline.d.ts +0 -1
  601. package/dist/prompts/pipeline.d.ts.map +1 -1
  602. package/dist/prompts/pipeline.js +1 -2
  603. package/dist/prompts/pipeline.js.map +1 -1
  604. package/dist/prompts/prompt.cjs +12 -16
  605. package/dist/prompts/prompt.cjs.map +1 -1
  606. package/dist/prompts/prompt.d.cts +0 -1
  607. package/dist/prompts/prompt.d.cts.map +1 -1
  608. package/dist/prompts/prompt.d.ts +0 -1
  609. package/dist/prompts/prompt.d.ts.map +1 -1
  610. package/dist/prompts/prompt.js +10 -14
  611. package/dist/prompts/prompt.js.map +1 -1
  612. package/dist/prompts/serde.d.cts +0 -1
  613. package/dist/prompts/serde.d.cts.map +1 -1
  614. package/dist/prompts/serde.d.ts +0 -2
  615. package/dist/prompts/serde.d.ts.map +1 -1
  616. package/dist/prompts/string.cjs +4 -6
  617. package/dist/prompts/string.cjs.map +1 -1
  618. package/dist/prompts/string.d.cts +0 -1
  619. package/dist/prompts/string.d.cts.map +1 -1
  620. package/dist/prompts/string.d.ts +0 -1
  621. package/dist/prompts/string.d.ts.map +1 -1
  622. package/dist/prompts/string.js +2 -4
  623. package/dist/prompts/string.js.map +1 -1
  624. package/dist/prompts/structured.cjs +3 -4
  625. package/dist/prompts/structured.cjs.map +1 -1
  626. package/dist/prompts/structured.d.cts +0 -1
  627. package/dist/prompts/structured.d.cts.map +1 -1
  628. package/dist/prompts/structured.d.ts +0 -1
  629. package/dist/prompts/structured.d.ts.map +1 -1
  630. package/dist/prompts/structured.js +1 -2
  631. package/dist/prompts/structured.js.map +1 -1
  632. package/dist/prompts/template.cjs +12 -23
  633. package/dist/prompts/template.cjs.map +1 -1
  634. package/dist/prompts/template.d.cts +0 -2
  635. package/dist/prompts/template.d.cts.map +1 -1
  636. package/dist/prompts/template.d.ts +0 -2
  637. package/dist/prompts/template.d.ts.map +1 -1
  638. package/dist/prompts/template.js +8 -20
  639. package/dist/prompts/template.js.map +1 -1
  640. package/dist/retrievers/document_compressors/index.cjs +8 -10
  641. package/dist/retrievers/document_compressors/index.cjs.map +1 -1
  642. package/dist/retrievers/document_compressors/index.d.cts +0 -1
  643. package/dist/retrievers/document_compressors/index.d.cts.map +1 -1
  644. package/dist/retrievers/document_compressors/index.d.ts +0 -1
  645. package/dist/retrievers/document_compressors/index.d.ts.map +1 -1
  646. package/dist/retrievers/document_compressors/index.js +3 -5
  647. package/dist/retrievers/document_compressors/index.js.map +1 -1
  648. package/dist/retrievers/index.cjs +13 -15
  649. package/dist/retrievers/index.cjs.map +1 -1
  650. package/dist/retrievers/index.d.cts +0 -1
  651. package/dist/retrievers/index.d.cts.map +1 -1
  652. package/dist/retrievers/index.d.ts +0 -2
  653. package/dist/retrievers/index.d.ts.map +1 -1
  654. package/dist/retrievers/index.js +4 -7
  655. package/dist/retrievers/index.js.map +1 -1
  656. package/dist/runnables/base.cjs +73 -100
  657. package/dist/runnables/base.cjs.map +1 -1
  658. package/dist/runnables/base.d.cts +3 -4
  659. package/dist/runnables/base.d.cts.map +1 -1
  660. package/dist/runnables/base.d.ts +3 -4
  661. package/dist/runnables/base.d.ts.map +1 -1
  662. package/dist/runnables/base.js +55 -82
  663. package/dist/runnables/base.js.map +1 -1
  664. package/dist/runnables/branch.cjs +8 -13
  665. package/dist/runnables/branch.cjs.map +1 -1
  666. package/dist/runnables/branch.d.cts +0 -1
  667. package/dist/runnables/branch.d.cts.map +1 -1
  668. package/dist/runnables/branch.d.ts +0 -2
  669. package/dist/runnables/branch.d.ts.map +1 -1
  670. package/dist/runnables/branch.js +5 -10
  671. package/dist/runnables/branch.js.map +1 -1
  672. package/dist/runnables/config.cjs +5 -8
  673. package/dist/runnables/config.cjs.map +1 -1
  674. package/dist/runnables/config.d.cts.map +1 -1
  675. package/dist/runnables/config.d.ts.map +1 -1
  676. package/dist/runnables/config.js +3 -5
  677. package/dist/runnables/config.js.map +1 -1
  678. package/dist/runnables/graph.cjs +15 -18
  679. package/dist/runnables/graph.cjs.map +1 -1
  680. package/dist/runnables/graph.d.cts.map +1 -1
  681. package/dist/runnables/graph.d.ts.map +1 -1
  682. package/dist/runnables/graph.js +5 -9
  683. package/dist/runnables/graph.js.map +1 -1
  684. package/dist/runnables/graph_mermaid.cjs +8 -12
  685. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  686. package/dist/runnables/graph_mermaid.js +7 -11
  687. package/dist/runnables/graph_mermaid.js.map +1 -1
  688. package/dist/runnables/history.cjs +12 -17
  689. package/dist/runnables/history.cjs.map +1 -1
  690. package/dist/runnables/history.d.cts +2 -4
  691. package/dist/runnables/history.d.cts.map +1 -1
  692. package/dist/runnables/history.d.ts +2 -6
  693. package/dist/runnables/history.d.ts.map +1 -1
  694. package/dist/runnables/history.js +7 -12
  695. package/dist/runnables/history.js.map +1 -1
  696. package/dist/runnables/index.cjs +16 -17
  697. package/dist/runnables/index.js +3 -5
  698. package/dist/runnables/iter.cjs +21 -5
  699. package/dist/runnables/iter.cjs.map +1 -1
  700. package/dist/runnables/iter.js +17 -3
  701. package/dist/runnables/iter.js.map +1 -1
  702. package/dist/runnables/passthrough.cjs +5 -6
  703. package/dist/runnables/passthrough.cjs.map +1 -1
  704. package/dist/runnables/passthrough.d.cts.map +1 -1
  705. package/dist/runnables/passthrough.d.ts +0 -1
  706. package/dist/runnables/passthrough.d.ts.map +1 -1
  707. package/dist/runnables/passthrough.js +2 -3
  708. package/dist/runnables/passthrough.js.map +1 -1
  709. package/dist/runnables/router.cjs +5 -7
  710. package/dist/runnables/router.cjs.map +1 -1
  711. package/dist/runnables/router.d.cts.map +1 -1
  712. package/dist/runnables/router.d.ts +0 -1
  713. package/dist/runnables/router.d.ts.map +1 -1
  714. package/dist/runnables/router.js +3 -5
  715. package/dist/runnables/router.js.map +1 -1
  716. package/dist/runnables/types.d.cts +1 -2
  717. package/dist/runnables/types.d.cts.map +1 -1
  718. package/dist/runnables/types.d.ts +1 -2
  719. package/dist/runnables/types.d.ts.map +1 -1
  720. package/dist/runnables/utils.cjs +2 -4
  721. package/dist/runnables/utils.cjs.map +1 -1
  722. package/dist/runnables/utils.js +2 -3
  723. package/dist/runnables/utils.js.map +1 -1
  724. package/dist/runnables/wrappers.cjs +2 -3
  725. package/dist/runnables/wrappers.cjs.map +1 -1
  726. package/dist/runnables/wrappers.js +1 -2
  727. package/dist/runnables/wrappers.js.map +1 -1
  728. package/dist/singletons/async_local_storage/context.cjs +6 -8
  729. package/dist/singletons/async_local_storage/context.cjs.map +1 -1
  730. package/dist/singletons/async_local_storage/context.d.cts +0 -1
  731. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  732. package/dist/singletons/async_local_storage/context.d.ts +0 -1
  733. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  734. package/dist/singletons/async_local_storage/context.js +3 -5
  735. package/dist/singletons/async_local_storage/context.js.map +1 -1
  736. package/dist/singletons/async_local_storage/globals.cjs +1 -2
  737. package/dist/singletons/async_local_storage/globals.cjs.map +1 -1
  738. package/dist/singletons/async_local_storage/globals.d.cts.map +1 -1
  739. package/dist/singletons/async_local_storage/globals.d.ts.map +1 -1
  740. package/dist/singletons/async_local_storage/globals.js +1 -1
  741. package/dist/singletons/async_local_storage/globals.js.map +1 -1
  742. package/dist/singletons/async_local_storage/index.cjs +8 -14
  743. package/dist/singletons/async_local_storage/index.cjs.map +1 -1
  744. package/dist/singletons/async_local_storage/index.d.cts.map +1 -1
  745. package/dist/singletons/async_local_storage/index.d.ts.map +1 -1
  746. package/dist/singletons/async_local_storage/index.js +4 -10
  747. package/dist/singletons/async_local_storage/index.js.map +1 -1
  748. package/dist/singletons/callbacks.cjs +7 -8
  749. package/dist/singletons/callbacks.cjs.map +1 -1
  750. package/dist/singletons/callbacks.d.cts +0 -1
  751. package/dist/singletons/callbacks.d.cts.map +1 -1
  752. package/dist/singletons/callbacks.d.ts +0 -1
  753. package/dist/singletons/callbacks.d.ts.map +1 -1
  754. package/dist/singletons/callbacks.js +2 -4
  755. package/dist/singletons/callbacks.js.map +1 -1
  756. package/dist/singletons/index.cjs +11 -12
  757. package/dist/singletons/index.js +3 -5
  758. package/dist/singletons/tracer.cjs +5 -9
  759. package/dist/singletons/tracer.cjs.map +1 -1
  760. package/dist/singletons/tracer.js +2 -6
  761. package/dist/singletons/tracer.js.map +1 -1
  762. package/dist/stores.cjs +10 -11
  763. package/dist/stores.cjs.map +1 -1
  764. package/dist/stores.d.cts +0 -1
  765. package/dist/stores.d.cts.map +1 -1
  766. package/dist/stores.d.ts +0 -1
  767. package/dist/stores.d.ts.map +1 -1
  768. package/dist/stores.js +3 -5
  769. package/dist/stores.js.map +1 -1
  770. package/dist/structured_query/base.cjs +6 -7
  771. package/dist/structured_query/base.cjs.map +1 -1
  772. package/dist/structured_query/base.d.cts +0 -1
  773. package/dist/structured_query/base.d.cts.map +1 -1
  774. package/dist/structured_query/base.d.ts +0 -1
  775. package/dist/structured_query/base.d.ts.map +1 -1
  776. package/dist/structured_query/base.js +4 -5
  777. package/dist/structured_query/base.js.map +1 -1
  778. package/dist/structured_query/functional.cjs +7 -8
  779. package/dist/structured_query/functional.cjs.map +1 -1
  780. package/dist/structured_query/functional.d.cts +0 -1
  781. package/dist/structured_query/functional.d.cts.map +1 -1
  782. package/dist/structured_query/functional.d.ts +0 -1
  783. package/dist/structured_query/functional.d.ts.map +1 -1
  784. package/dist/structured_query/functional.js +4 -5
  785. package/dist/structured_query/functional.js.map +1 -1
  786. package/dist/structured_query/index.cjs +13 -14
  787. package/dist/structured_query/index.js +3 -5
  788. package/dist/structured_query/ir.cjs +1 -2
  789. package/dist/structured_query/ir.cjs.map +1 -1
  790. package/dist/structured_query/ir.d.cts +0 -1
  791. package/dist/structured_query/ir.d.cts.map +1 -1
  792. package/dist/structured_query/ir.d.ts +0 -1
  793. package/dist/structured_query/ir.d.ts.map +1 -1
  794. package/dist/structured_query/ir.js +1 -1
  795. package/dist/structured_query/ir.js.map +1 -1
  796. package/dist/structured_query/utils.cjs +1 -2
  797. package/dist/structured_query/utils.cjs.map +1 -1
  798. package/dist/structured_query/utils.d.cts.map +1 -1
  799. package/dist/structured_query/utils.d.ts.map +1 -1
  800. package/dist/structured_query/utils.js +1 -1
  801. package/dist/structured_query/utils.js.map +1 -1
  802. package/dist/testing/fake_model_builder.cjs +225 -0
  803. package/dist/testing/fake_model_builder.cjs.map +1 -0
  804. package/dist/testing/fake_model_builder.d.cts +138 -0
  805. package/dist/testing/fake_model_builder.d.cts.map +1 -0
  806. package/dist/testing/fake_model_builder.d.ts +138 -0
  807. package/dist/testing/fake_model_builder.d.ts.map +1 -0
  808. package/dist/testing/fake_model_builder.js +224 -0
  809. package/dist/testing/fake_model_builder.js.map +1 -0
  810. package/dist/testing/index.cjs +42 -0
  811. package/dist/testing/index.cjs.map +1 -0
  812. package/dist/testing/index.d.cts +3 -0
  813. package/dist/testing/index.d.ts +3 -0
  814. package/dist/testing/index.js +23 -0
  815. package/dist/testing/index.js.map +1 -0
  816. package/dist/testing/matchers.cjs +212 -0
  817. package/dist/testing/matchers.cjs.map +1 -0
  818. package/dist/testing/matchers.d.cts +94 -0
  819. package/dist/testing/matchers.d.cts.map +1 -0
  820. package/dist/testing/matchers.d.ts +94 -0
  821. package/dist/testing/matchers.d.ts.map +1 -0
  822. package/dist/testing/matchers.js +202 -0
  823. package/dist/testing/matchers.js.map +1 -0
  824. package/dist/tools/index.cjs +51 -36
  825. package/dist/tools/index.cjs.map +1 -1
  826. package/dist/tools/index.d.cts +31 -24
  827. package/dist/tools/index.d.cts.map +1 -1
  828. package/dist/tools/index.d.ts +31 -26
  829. package/dist/tools/index.d.ts.map +1 -1
  830. package/dist/tools/index.js +32 -18
  831. package/dist/tools/index.js.map +1 -1
  832. package/dist/tools/types.cjs +3 -4
  833. package/dist/tools/types.cjs.map +1 -1
  834. package/dist/tools/types.d.cts +26 -11
  835. package/dist/tools/types.d.cts.map +1 -1
  836. package/dist/tools/types.d.ts +26 -13
  837. package/dist/tools/types.d.ts.map +1 -1
  838. package/dist/tools/types.js +1 -2
  839. package/dist/tools/types.js.map +1 -1
  840. package/dist/tools/utils.cjs +1 -2
  841. package/dist/tools/utils.cjs.map +1 -1
  842. package/dist/tools/utils.d.cts +0 -1
  843. package/dist/tools/utils.d.cts.map +1 -1
  844. package/dist/tools/utils.d.ts +0 -1
  845. package/dist/tools/utils.d.ts.map +1 -1
  846. package/dist/tools/utils.js +1 -1
  847. package/dist/tools/utils.js.map +1 -1
  848. package/dist/tracers/base.cjs +20 -18
  849. package/dist/tracers/base.cjs.map +1 -1
  850. package/dist/tracers/base.d.cts +92 -98
  851. package/dist/tracers/base.d.cts.map +1 -1
  852. package/dist/tracers/base.d.ts +92 -98
  853. package/dist/tracers/base.d.ts.map +1 -1
  854. package/dist/tracers/base.js +11 -10
  855. package/dist/tracers/base.js.map +1 -1
  856. package/dist/tracers/console.cjs +16 -17
  857. package/dist/tracers/console.cjs.map +1 -1
  858. package/dist/tracers/console.d.cts +0 -1
  859. package/dist/tracers/console.d.cts.map +1 -1
  860. package/dist/tracers/console.d.ts +0 -1
  861. package/dist/tracers/console.d.ts.map +1 -1
  862. package/dist/tracers/console.js +7 -10
  863. package/dist/tracers/console.js.map +1 -1
  864. package/dist/tracers/event_stream.cjs +24 -10
  865. package/dist/tracers/event_stream.cjs.map +1 -1
  866. package/dist/tracers/event_stream.d.cts +7 -6
  867. package/dist/tracers/event_stream.d.cts.map +1 -1
  868. package/dist/tracers/event_stream.d.ts +7 -7
  869. package/dist/tracers/event_stream.d.ts.map +1 -1
  870. package/dist/tracers/event_stream.js +20 -6
  871. package/dist/tracers/event_stream.js.map +1 -1
  872. package/dist/tracers/log_stream.cjs +15 -16
  873. package/dist/tracers/log_stream.cjs.map +1 -1
  874. package/dist/tracers/log_stream.d.cts +14 -31
  875. package/dist/tracers/log_stream.d.cts.map +1 -1
  876. package/dist/tracers/log_stream.d.ts +14 -31
  877. package/dist/tracers/log_stream.d.ts.map +1 -1
  878. package/dist/tracers/log_stream.js +5 -7
  879. package/dist/tracers/log_stream.js.map +1 -1
  880. package/dist/tracers/root_listener.cjs +2 -3
  881. package/dist/tracers/root_listener.cjs.map +1 -1
  882. package/dist/tracers/root_listener.js +1 -2
  883. package/dist/tracers/root_listener.js.map +1 -1
  884. package/dist/tracers/run_collector.cjs +10 -11
  885. package/dist/tracers/run_collector.cjs.map +1 -1
  886. package/dist/tracers/run_collector.d.cts +0 -1
  887. package/dist/tracers/run_collector.d.cts.map +1 -1
  888. package/dist/tracers/run_collector.d.ts +0 -1
  889. package/dist/tracers/run_collector.d.ts.map +1 -1
  890. package/dist/tracers/run_collector.js +3 -5
  891. package/dist/tracers/run_collector.js.map +1 -1
  892. package/dist/tracers/tracer_langchain.cjs +43 -19
  893. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  894. package/dist/tracers/tracer_langchain.d.cts +2 -1
  895. package/dist/tracers/tracer_langchain.d.cts.map +1 -1
  896. package/dist/tracers/tracer_langchain.d.ts +2 -1
  897. package/dist/tracers/tracer_langchain.d.ts.map +1 -1
  898. package/dist/tracers/tracer_langchain.js +33 -10
  899. package/dist/tracers/tracer_langchain.js.map +1 -1
  900. package/dist/types/_internal.d.cts.map +1 -1
  901. package/dist/types/_internal.d.ts.map +1 -1
  902. package/dist/types/stream.cjs +8 -8
  903. package/dist/types/stream.js +3 -2
  904. package/dist/types/type-utils.d.cts +2 -1
  905. package/dist/types/type-utils.d.cts.map +1 -1
  906. package/dist/types/type-utils.d.ts +2 -1
  907. package/dist/types/type-utils.d.ts.map +1 -1
  908. package/dist/utils/async_caller.cjs +29 -22
  909. package/dist/utils/async_caller.cjs.map +1 -1
  910. package/dist/utils/async_caller.d.cts.map +1 -1
  911. package/dist/utils/async_caller.d.ts.map +1 -1
  912. package/dist/utils/async_caller.js +19 -14
  913. package/dist/utils/async_caller.js.map +1 -1
  914. package/dist/utils/callbacks.cjs +4 -6
  915. package/dist/utils/callbacks.cjs.map +1 -1
  916. package/dist/utils/callbacks.js +3 -5
  917. package/dist/utils/callbacks.js.map +1 -1
  918. package/dist/utils/chunk_array.cjs +9 -12
  919. package/dist/utils/chunk_array.cjs.map +1 -1
  920. package/dist/utils/chunk_array.d.cts.map +1 -1
  921. package/dist/utils/chunk_array.d.ts.map +1 -1
  922. package/dist/utils/chunk_array.js +4 -7
  923. package/dist/utils/chunk_array.js.map +1 -1
  924. package/dist/utils/context.cjs +104 -0
  925. package/dist/utils/context.cjs.map +1 -0
  926. package/dist/utils/context.d.cts +44 -0
  927. package/dist/utils/context.d.cts.map +1 -0
  928. package/dist/utils/context.d.ts +44 -0
  929. package/dist/utils/context.d.ts.map +1 -0
  930. package/dist/utils/context.js +98 -0
  931. package/dist/utils/context.js.map +1 -0
  932. package/dist/utils/env.cjs +14 -19
  933. package/dist/utils/env.cjs.map +1 -1
  934. package/dist/utils/env.d.cts.map +1 -1
  935. package/dist/utils/env.d.ts.map +1 -1
  936. package/dist/utils/env.js +9 -14
  937. package/dist/utils/env.js.map +1 -1
  938. package/dist/utils/event_source_parse.cjs +16 -17
  939. package/dist/utils/event_source_parse.cjs.map +1 -1
  940. package/dist/utils/event_source_parse.d.cts +2 -2
  941. package/dist/utils/event_source_parse.d.cts.map +1 -1
  942. package/dist/utils/event_source_parse.d.ts +2 -2
  943. package/dist/utils/event_source_parse.d.ts.map +1 -1
  944. package/dist/utils/event_source_parse.js +9 -11
  945. package/dist/utils/event_source_parse.js.map +1 -1
  946. package/dist/utils/fast-json-patch/index.cjs +5 -13
  947. package/dist/utils/fast-json-patch/index.cjs.map +1 -1
  948. package/dist/utils/fast-json-patch/index.js +6 -13
  949. package/dist/utils/fast-json-patch/index.js.map +1 -1
  950. package/dist/utils/fast-json-patch/src/core.cjs +16 -28
  951. package/dist/utils/fast-json-patch/src/core.cjs.map +1 -1
  952. package/dist/utils/fast-json-patch/src/core.d.cts +0 -1
  953. package/dist/utils/fast-json-patch/src/core.d.cts.map +1 -1
  954. package/dist/utils/fast-json-patch/src/core.d.ts +0 -1
  955. package/dist/utils/fast-json-patch/src/core.d.ts.map +1 -1
  956. package/dist/utils/fast-json-patch/src/core.js +10 -22
  957. package/dist/utils/fast-json-patch/src/core.js.map +1 -1
  958. package/dist/utils/fast-json-patch/src/duplex.cjs +8 -7
  959. package/dist/utils/fast-json-patch/src/duplex.cjs.map +1 -1
  960. package/dist/utils/fast-json-patch/src/duplex.d.cts +0 -1
  961. package/dist/utils/fast-json-patch/src/duplex.d.cts.map +1 -1
  962. package/dist/utils/fast-json-patch/src/duplex.d.ts +0 -1
  963. package/dist/utils/fast-json-patch/src/duplex.d.ts.map +1 -1
  964. package/dist/utils/fast-json-patch/src/duplex.js +6 -5
  965. package/dist/utils/fast-json-patch/src/duplex.js.map +1 -1
  966. package/dist/utils/fast-json-patch/src/helpers.cjs +5 -6
  967. package/dist/utils/fast-json-patch/src/helpers.cjs.map +1 -1
  968. package/dist/utils/fast-json-patch/src/helpers.js +5 -5
  969. package/dist/utils/fast-json-patch/src/helpers.js.map +1 -1
  970. package/dist/utils/format.cjs +8 -8
  971. package/dist/utils/format.d.cts.map +1 -1
  972. package/dist/utils/format.d.ts.map +1 -1
  973. package/dist/utils/format.js +3 -2
  974. package/dist/utils/function_calling.cjs +11 -12
  975. package/dist/utils/function_calling.cjs.map +1 -1
  976. package/dist/utils/function_calling.d.cts +0 -1
  977. package/dist/utils/function_calling.d.cts.map +1 -1
  978. package/dist/utils/function_calling.d.ts +0 -1
  979. package/dist/utils/function_calling.d.ts.map +1 -1
  980. package/dist/utils/function_calling.js +3 -5
  981. package/dist/utils/function_calling.js.map +1 -1
  982. package/dist/utils/hash.cjs +10 -11
  983. package/dist/utils/hash.d.cts +0 -1
  984. package/dist/utils/hash.d.cts.map +1 -1
  985. package/dist/utils/hash.d.ts +0 -1
  986. package/dist/utils/hash.d.ts.map +1 -1
  987. package/dist/utils/hash.js +3 -5
  988. package/dist/utils/is-network-error/index.cjs +3 -5
  989. package/dist/utils/is-network-error/index.cjs.map +1 -1
  990. package/dist/utils/is-network-error/index.js +3 -4
  991. package/dist/utils/is-network-error/index.js.map +1 -1
  992. package/dist/utils/js-sha256/hash.cjs +42 -37
  993. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  994. package/dist/utils/js-sha256/hash.d.cts.map +1 -1
  995. package/dist/utils/js-sha256/hash.d.ts.map +1 -1
  996. package/dist/utils/js-sha256/hash.js +42 -36
  997. package/dist/utils/js-sha256/hash.js.map +1 -1
  998. package/dist/utils/json.cjs +1 -2
  999. package/dist/utils/json.cjs.map +1 -1
  1000. package/dist/utils/json.d.cts.map +1 -1
  1001. package/dist/utils/json.d.ts.map +1 -1
  1002. package/dist/utils/json.js +1 -1
  1003. package/dist/utils/json.js.map +1 -1
  1004. package/dist/utils/json_patch.cjs +12 -13
  1005. package/dist/utils/json_patch.js +3 -5
  1006. package/dist/utils/json_schema.cjs +60 -37
  1007. package/dist/utils/json_schema.cjs.map +1 -1
  1008. package/dist/utils/json_schema.d.cts +4 -2
  1009. package/dist/utils/json_schema.d.cts.map +1 -1
  1010. package/dist/utils/json_schema.d.ts +4 -3
  1011. package/dist/utils/json_schema.d.ts.map +1 -1
  1012. package/dist/utils/json_schema.js +36 -14
  1013. package/dist/utils/json_schema.js.map +1 -1
  1014. package/dist/utils/math.cjs +16 -18
  1015. package/dist/utils/math.cjs.map +1 -1
  1016. package/dist/utils/math.d.cts.map +1 -1
  1017. package/dist/utils/math.d.ts.map +1 -1
  1018. package/dist/utils/math.js +9 -12
  1019. package/dist/utils/math.js.map +1 -1
  1020. package/dist/utils/ml-distance/distances.cjs +1 -2
  1021. package/dist/utils/ml-distance/distances.cjs.map +1 -1
  1022. package/dist/utils/ml-distance/distances.js +1 -1
  1023. package/dist/utils/ml-distance/distances.js.map +1 -1
  1024. package/dist/utils/ml-distance/similarities.cjs +1 -2
  1025. package/dist/utils/ml-distance/similarities.cjs.map +1 -1
  1026. package/dist/utils/ml-distance/similarities.d.cts.map +1 -1
  1027. package/dist/utils/ml-distance/similarities.d.ts.map +1 -1
  1028. package/dist/utils/ml-distance/similarities.js +1 -1
  1029. package/dist/utils/ml-distance/similarities.js.map +1 -1
  1030. package/dist/utils/ml-distance-euclidean/euclidean.cjs +1 -2
  1031. package/dist/utils/ml-distance-euclidean/euclidean.cjs.map +1 -1
  1032. package/dist/utils/ml-distance-euclidean/euclidean.js +1 -1
  1033. package/dist/utils/ml-distance-euclidean/euclidean.js.map +1 -1
  1034. package/dist/utils/namespace.cjs +62 -0
  1035. package/dist/utils/namespace.cjs.map +1 -0
  1036. package/dist/utils/namespace.d.cts +73 -0
  1037. package/dist/utils/namespace.d.cts.map +1 -0
  1038. package/dist/utils/namespace.d.ts +73 -0
  1039. package/dist/utils/namespace.d.ts.map +1 -0
  1040. package/dist/utils/namespace.js +62 -0
  1041. package/dist/utils/namespace.js.map +1 -0
  1042. package/dist/utils/p-retry/index.cjs +4 -5
  1043. package/dist/utils/p-retry/index.cjs.map +1 -1
  1044. package/dist/utils/p-retry/index.js +3 -4
  1045. package/dist/utils/p-retry/index.js.map +1 -1
  1046. package/dist/utils/sax-js/sax.cjs +29 -36
  1047. package/dist/utils/sax-js/sax.cjs.map +1 -1
  1048. package/dist/utils/sax-js/sax.js +29 -35
  1049. package/dist/utils/sax-js/sax.js.map +1 -1
  1050. package/dist/utils/signal.cjs +3 -4
  1051. package/dist/utils/signal.cjs.map +1 -1
  1052. package/dist/utils/signal.d.cts.map +1 -1
  1053. package/dist/utils/signal.d.ts.map +1 -1
  1054. package/dist/utils/signal.js +3 -3
  1055. package/dist/utils/signal.js.map +1 -1
  1056. package/dist/utils/ssrf.cjs +267 -0
  1057. package/dist/utils/ssrf.cjs.map +1 -0
  1058. package/dist/utils/ssrf.d.cts +52 -0
  1059. package/dist/utils/ssrf.d.cts.map +1 -0
  1060. package/dist/utils/ssrf.d.ts +52 -0
  1061. package/dist/utils/ssrf.d.ts.map +1 -0
  1062. package/dist/utils/ssrf.js +256 -0
  1063. package/dist/utils/ssrf.js.map +1 -0
  1064. package/dist/utils/standard_schema.cjs +41 -0
  1065. package/dist/utils/standard_schema.cjs.map +1 -0
  1066. package/dist/utils/standard_schema.d.cts +27 -0
  1067. package/dist/utils/standard_schema.d.cts.map +1 -0
  1068. package/dist/utils/standard_schema.d.ts +27 -0
  1069. package/dist/utils/standard_schema.d.ts.map +1 -0
  1070. package/dist/utils/standard_schema.js +33 -0
  1071. package/dist/utils/standard_schema.js.map +1 -0
  1072. package/dist/utils/stream.cjs +15 -16
  1073. package/dist/utils/stream.cjs.map +1 -1
  1074. package/dist/utils/stream.d.cts +2 -2
  1075. package/dist/utils/stream.d.cts.map +1 -1
  1076. package/dist/utils/stream.d.ts +2 -2
  1077. package/dist/utils/stream.d.ts.map +1 -1
  1078. package/dist/utils/stream.js +5 -7
  1079. package/dist/utils/stream.js.map +1 -1
  1080. package/dist/utils/testing/chat_models.cjs +10 -13
  1081. package/dist/utils/testing/chat_models.cjs.map +1 -1
  1082. package/dist/utils/testing/chat_models.d.cts.map +1 -1
  1083. package/dist/utils/testing/chat_models.d.ts +0 -1
  1084. package/dist/utils/testing/chat_models.d.ts.map +1 -1
  1085. package/dist/utils/testing/chat_models.js +4 -7
  1086. package/dist/utils/testing/chat_models.js.map +1 -1
  1087. package/dist/utils/testing/embeddings.cjs +4 -7
  1088. package/dist/utils/testing/embeddings.cjs.map +1 -1
  1089. package/dist/utils/testing/embeddings.d.cts +0 -1
  1090. package/dist/utils/testing/embeddings.d.cts.map +1 -1
  1091. package/dist/utils/testing/embeddings.d.ts +0 -1
  1092. package/dist/utils/testing/embeddings.d.ts.map +1 -1
  1093. package/dist/utils/testing/embeddings.js +3 -6
  1094. package/dist/utils/testing/embeddings.js.map +1 -1
  1095. package/dist/utils/testing/index.cjs +19 -20
  1096. package/dist/utils/testing/index.js +3 -5
  1097. package/dist/utils/testing/llms.cjs +2 -3
  1098. package/dist/utils/testing/llms.cjs.map +1 -1
  1099. package/dist/utils/testing/llms.d.cts.map +1 -1
  1100. package/dist/utils/testing/llms.d.ts.map +1 -1
  1101. package/dist/utils/testing/llms.js +1 -2
  1102. package/dist/utils/testing/llms.js.map +1 -1
  1103. package/dist/utils/testing/message_history.cjs +6 -7
  1104. package/dist/utils/testing/message_history.cjs.map +1 -1
  1105. package/dist/utils/testing/message_history.d.cts.map +1 -1
  1106. package/dist/utils/testing/message_history.d.ts +0 -1
  1107. package/dist/utils/testing/message_history.d.ts.map +1 -1
  1108. package/dist/utils/testing/message_history.js +2 -3
  1109. package/dist/utils/testing/message_history.js.map +1 -1
  1110. package/dist/utils/testing/output_parsers.cjs +2 -3
  1111. package/dist/utils/testing/output_parsers.cjs.map +1 -1
  1112. package/dist/utils/testing/output_parsers.d.cts +0 -1
  1113. package/dist/utils/testing/output_parsers.d.cts.map +1 -1
  1114. package/dist/utils/testing/output_parsers.d.ts +0 -1
  1115. package/dist/utils/testing/output_parsers.d.ts.map +1 -1
  1116. package/dist/utils/testing/output_parsers.js +1 -2
  1117. package/dist/utils/testing/output_parsers.js.map +1 -1
  1118. package/dist/utils/testing/retrievers.cjs +3 -4
  1119. package/dist/utils/testing/retrievers.cjs.map +1 -1
  1120. package/dist/utils/testing/retrievers.d.cts.map +1 -1
  1121. package/dist/utils/testing/retrievers.d.ts.map +1 -1
  1122. package/dist/utils/testing/retrievers.js +2 -3
  1123. package/dist/utils/testing/retrievers.js.map +1 -1
  1124. package/dist/utils/testing/runnables.cjs +2 -3
  1125. package/dist/utils/testing/runnables.cjs.map +1 -1
  1126. package/dist/utils/testing/runnables.d.cts.map +1 -1
  1127. package/dist/utils/testing/runnables.d.ts.map +1 -1
  1128. package/dist/utils/testing/runnables.js +1 -2
  1129. package/dist/utils/testing/runnables.js.map +1 -1
  1130. package/dist/utils/testing/tools.cjs +2 -3
  1131. package/dist/utils/testing/tools.cjs.map +1 -1
  1132. package/dist/utils/testing/tools.d.cts.map +1 -1
  1133. package/dist/utils/testing/tools.d.ts.map +1 -1
  1134. package/dist/utils/testing/tools.js +1 -2
  1135. package/dist/utils/testing/tools.js.map +1 -1
  1136. package/dist/utils/testing/tracers.cjs +2 -3
  1137. package/dist/utils/testing/tracers.cjs.map +1 -1
  1138. package/dist/utils/testing/tracers.d.cts.map +1 -1
  1139. package/dist/utils/testing/tracers.d.ts.map +1 -1
  1140. package/dist/utils/testing/tracers.js +1 -2
  1141. package/dist/utils/testing/tracers.js.map +1 -1
  1142. package/dist/utils/testing/vectorstores.cjs +10 -15
  1143. package/dist/utils/testing/vectorstores.cjs.map +1 -1
  1144. package/dist/utils/testing/vectorstores.d.cts +0 -1
  1145. package/dist/utils/testing/vectorstores.d.cts.map +1 -1
  1146. package/dist/utils/testing/vectorstores.d.ts +0 -1
  1147. package/dist/utils/testing/vectorstores.d.ts.map +1 -1
  1148. package/dist/utils/testing/vectorstores.js +8 -13
  1149. package/dist/utils/testing/vectorstores.js.map +1 -1
  1150. package/dist/utils/tiktoken.cjs +11 -12
  1151. package/dist/utils/tiktoken.cjs.map +1 -1
  1152. package/dist/utils/tiktoken.d.cts.map +1 -1
  1153. package/dist/utils/tiktoken.d.ts.map +1 -1
  1154. package/dist/utils/tiktoken.js +3 -5
  1155. package/dist/utils/tiktoken.js.map +1 -1
  1156. package/dist/utils/types/index.cjs +10 -11
  1157. package/dist/utils/types/index.cjs.map +1 -1
  1158. package/dist/utils/types/index.d.cts +2 -3
  1159. package/dist/utils/types/index.d.cts.map +1 -1
  1160. package/dist/utils/types/index.d.ts +2 -3
  1161. package/dist/utils/types/index.d.ts.map +1 -1
  1162. package/dist/utils/types/index.js +3 -5
  1163. package/dist/utils/types/index.js.map +1 -1
  1164. package/dist/utils/types/zod.cjs +20 -36
  1165. package/dist/utils/types/zod.cjs.map +1 -1
  1166. package/dist/utils/types/zod.d.cts +144 -33
  1167. package/dist/utils/types/zod.d.cts.map +1 -1
  1168. package/dist/utils/types/zod.d.ts +144 -33
  1169. package/dist/utils/types/zod.d.ts.map +1 -1
  1170. package/dist/utils/types/zod.js +18 -34
  1171. package/dist/utils/types/zod.js.map +1 -1
  1172. package/dist/utils/zod-to-json-schema/Options.cjs +1 -2
  1173. package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -1
  1174. package/dist/utils/zod-to-json-schema/Options.d.cts +1 -0
  1175. package/dist/utils/zod-to-json-schema/Options.d.ts +1 -3
  1176. package/dist/utils/zod-to-json-schema/Options.js +1 -1
  1177. package/dist/utils/zod-to-json-schema/Options.js.map +1 -1
  1178. package/dist/utils/zod-to-json-schema/Refs.cjs +2 -3
  1179. package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -1
  1180. package/dist/utils/zod-to-json-schema/Refs.d.cts +1 -0
  1181. package/dist/utils/zod-to-json-schema/Refs.d.ts +1 -3
  1182. package/dist/utils/zod-to-json-schema/Refs.js +1 -2
  1183. package/dist/utils/zod-to-json-schema/Refs.js.map +1 -1
  1184. package/dist/utils/zod-to-json-schema/errorMessages.cjs +1 -2
  1185. package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -1
  1186. package/dist/utils/zod-to-json-schema/errorMessages.d.cts +0 -1
  1187. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -1
  1188. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +0 -2
  1189. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -1
  1190. package/dist/utils/zod-to-json-schema/errorMessages.js +1 -1
  1191. package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -1
  1192. package/dist/utils/zod-to-json-schema/getRelativePath.cjs +1 -2
  1193. package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -1
  1194. package/dist/utils/zod-to-json-schema/getRelativePath.js +1 -1
  1195. package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -1
  1196. package/dist/utils/zod-to-json-schema/index.cjs +37 -37
  1197. package/dist/utils/zod-to-json-schema/index.d.cts +24 -0
  1198. package/dist/utils/zod-to-json-schema/index.d.ts +1 -14
  1199. package/dist/utils/zod-to-json-schema/index.js +38 -37
  1200. package/dist/utils/zod-to-json-schema/parseDef.cjs +5 -6
  1201. package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -1
  1202. package/dist/utils/zod-to-json-schema/parseDef.d.cts +1 -0
  1203. package/dist/utils/zod-to-json-schema/parseDef.d.ts +1 -3
  1204. package/dist/utils/zod-to-json-schema/parseDef.js +1 -2
  1205. package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -1
  1206. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -1
  1207. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -1
  1208. package/dist/utils/zod-to-json-schema/parsers/any.cjs +2 -3
  1209. package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -1
  1210. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -1
  1211. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +0 -2
  1212. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -1
  1213. package/dist/utils/zod-to-json-schema/parsers/any.js +1 -2
  1214. package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -1
  1215. package/dist/utils/zod-to-json-schema/parsers/array.cjs +5 -6
  1216. package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -1
  1217. package/dist/utils/zod-to-json-schema/parsers/array.d.cts +0 -1
  1218. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -1
  1219. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +0 -3
  1220. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -1
  1221. package/dist/utils/zod-to-json-schema/parsers/array.js +1 -2
  1222. package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -1
  1223. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +2 -3
  1224. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -1
  1225. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +0 -1
  1226. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -1
  1227. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +0 -3
  1228. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -1
  1229. package/dist/utils/zod-to-json-schema/parsers/bigint.js +1 -2
  1230. package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -1
  1231. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +1 -2
  1232. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -1
  1233. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -1
  1234. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -1
  1235. package/dist/utils/zod-to-json-schema/parsers/boolean.js +1 -1
  1236. package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -1
  1237. package/dist/utils/zod-to-json-schema/parsers/branded.cjs +2 -3
  1238. package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -1
  1239. package/dist/utils/zod-to-json-schema/parsers/branded.d.cts +1 -0
  1240. package/dist/utils/zod-to-json-schema/parsers/branded.d.ts +1 -3
  1241. package/dist/utils/zod-to-json-schema/parsers/branded.js +1 -2
  1242. package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -1
  1243. package/dist/utils/zod-to-json-schema/parsers/catch.cjs +2 -3
  1244. package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -1
  1245. package/dist/utils/zod-to-json-schema/parsers/catch.d.cts +1 -0
  1246. package/dist/utils/zod-to-json-schema/parsers/catch.d.ts +1 -3
  1247. package/dist/utils/zod-to-json-schema/parsers/catch.js +1 -2
  1248. package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -1
  1249. package/dist/utils/zod-to-json-schema/parsers/date.cjs +2 -3
  1250. package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -1
  1251. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +0 -2
  1252. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -1
  1253. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +0 -4
  1254. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -1
  1255. package/dist/utils/zod-to-json-schema/parsers/date.js +1 -2
  1256. package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -1
  1257. package/dist/utils/zod-to-json-schema/parsers/default.cjs +2 -3
  1258. package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -1
  1259. package/dist/utils/zod-to-json-schema/parsers/default.d.cts +1 -0
  1260. package/dist/utils/zod-to-json-schema/parsers/default.d.ts +1 -3
  1261. package/dist/utils/zod-to-json-schema/parsers/default.js +1 -2
  1262. package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -1
  1263. package/dist/utils/zod-to-json-schema/parsers/effects.cjs +3 -4
  1264. package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -1
  1265. package/dist/utils/zod-to-json-schema/parsers/effects.d.cts +1 -0
  1266. package/dist/utils/zod-to-json-schema/parsers/effects.d.ts +1 -3
  1267. package/dist/utils/zod-to-json-schema/parsers/effects.js +1 -2
  1268. package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -1
  1269. package/dist/utils/zod-to-json-schema/parsers/enum.cjs +1 -2
  1270. package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -1
  1271. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -1
  1272. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +0 -2
  1273. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -1
  1274. package/dist/utils/zod-to-json-schema/parsers/enum.js +1 -1
  1275. package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -1
  1276. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +3 -4
  1277. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -1
  1278. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +0 -1
  1279. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -1
  1280. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +0 -3
  1281. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -1
  1282. package/dist/utils/zod-to-json-schema/parsers/intersection.js +2 -3
  1283. package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -1
  1284. package/dist/utils/zod-to-json-schema/parsers/literal.cjs +1 -2
  1285. package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -1
  1286. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +0 -1
  1287. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -1
  1288. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +0 -3
  1289. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -1
  1290. package/dist/utils/zod-to-json-schema/parsers/literal.js +1 -1
  1291. package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -1
  1292. package/dist/utils/zod-to-json-schema/parsers/map.cjs +21 -24
  1293. package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -1
  1294. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +0 -2
  1295. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -1
  1296. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +0 -4
  1297. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -1
  1298. package/dist/utils/zod-to-json-schema/parsers/map.js +18 -21
  1299. package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -1
  1300. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +3 -5
  1301. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -1
  1302. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -1
  1303. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +0 -2
  1304. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -1
  1305. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +3 -4
  1306. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -1
  1307. package/dist/utils/zod-to-json-schema/parsers/never.cjs +2 -3
  1308. package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -1
  1309. package/dist/utils/zod-to-json-schema/parsers/never.d.cts +0 -1
  1310. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -1
  1311. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +0 -2
  1312. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -1
  1313. package/dist/utils/zod-to-json-schema/parsers/never.js +1 -2
  1314. package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -1
  1315. package/dist/utils/zod-to-json-schema/parsers/null.cjs +1 -2
  1316. package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -1
  1317. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -1
  1318. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +0 -2
  1319. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -1
  1320. package/dist/utils/zod-to-json-schema/parsers/null.js +1 -1
  1321. package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -1
  1322. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +8 -9
  1323. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -1
  1324. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +0 -1
  1325. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -1
  1326. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +0 -3
  1327. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -1
  1328. package/dist/utils/zod-to-json-schema/parsers/nullable.js +6 -7
  1329. package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -1
  1330. package/dist/utils/zod-to-json-schema/parsers/number.cjs +2 -3
  1331. package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -1
  1332. package/dist/utils/zod-to-json-schema/parsers/number.d.cts +0 -1
  1333. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -1
  1334. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +0 -3
  1335. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -1
  1336. package/dist/utils/zod-to-json-schema/parsers/number.js +1 -2
  1337. package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -1
  1338. package/dist/utils/zod-to-json-schema/parsers/object.cjs +2 -3
  1339. package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -1
  1340. package/dist/utils/zod-to-json-schema/parsers/object.d.cts +0 -1
  1341. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -1
  1342. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +0 -3
  1343. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -1
  1344. package/dist/utils/zod-to-json-schema/parsers/object.js +1 -2
  1345. package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -1
  1346. package/dist/utils/zod-to-json-schema/parsers/optional.cjs +3 -4
  1347. package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -1
  1348. package/dist/utils/zod-to-json-schema/parsers/optional.d.cts +1 -0
  1349. package/dist/utils/zod-to-json-schema/parsers/optional.d.ts +1 -3
  1350. package/dist/utils/zod-to-json-schema/parsers/optional.js +1 -2
  1351. package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -1
  1352. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +4 -6
  1353. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -1
  1354. package/dist/utils/zod-to-json-schema/parsers/pipeline.d.cts +1 -0
  1355. package/dist/utils/zod-to-json-schema/parsers/pipeline.d.ts +1 -4
  1356. package/dist/utils/zod-to-json-schema/parsers/pipeline.js +3 -5
  1357. package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -1
  1358. package/dist/utils/zod-to-json-schema/parsers/promise.cjs +2 -3
  1359. package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -1
  1360. package/dist/utils/zod-to-json-schema/parsers/promise.d.cts +1 -0
  1361. package/dist/utils/zod-to-json-schema/parsers/promise.d.ts +1 -3
  1362. package/dist/utils/zod-to-json-schema/parsers/promise.js +1 -2
  1363. package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -1
  1364. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +2 -3
  1365. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -1
  1366. package/dist/utils/zod-to-json-schema/parsers/readonly.d.cts +1 -0
  1367. package/dist/utils/zod-to-json-schema/parsers/readonly.d.ts +1 -3
  1368. package/dist/utils/zod-to-json-schema/parsers/readonly.js +1 -2
  1369. package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -1
  1370. package/dist/utils/zod-to-json-schema/parsers/record.cjs +9 -10
  1371. package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -1
  1372. package/dist/utils/zod-to-json-schema/parsers/record.d.cts +0 -1
  1373. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -1
  1374. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +0 -3
  1375. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -1
  1376. package/dist/utils/zod-to-json-schema/parsers/record.js +3 -4
  1377. package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -1
  1378. package/dist/utils/zod-to-json-schema/parsers/set.cjs +7 -9
  1379. package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -1
  1380. package/dist/utils/zod-to-json-schema/parsers/set.d.cts +0 -1
  1381. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -1
  1382. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +0 -3
  1383. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -1
  1384. package/dist/utils/zod-to-json-schema/parsers/set.js +5 -7
  1385. package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -1
  1386. package/dist/utils/zod-to-json-schema/parsers/string.cjs +2 -3
  1387. package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -1
  1388. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +0 -2
  1389. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -1
  1390. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +0 -4
  1391. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -1
  1392. package/dist/utils/zod-to-json-schema/parsers/string.js +1 -2
  1393. package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -1
  1394. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +2 -3
  1395. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -1
  1396. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +0 -1
  1397. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -1
  1398. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +0 -3
  1399. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -1
  1400. package/dist/utils/zod-to-json-schema/parsers/tuple.js +1 -2
  1401. package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -1
  1402. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +2 -3
  1403. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -1
  1404. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +0 -1
  1405. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -1
  1406. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +0 -2
  1407. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -1
  1408. package/dist/utils/zod-to-json-schema/parsers/undefined.js +1 -2
  1409. package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -1
  1410. package/dist/utils/zod-to-json-schema/parsers/union.cjs +5 -9
  1411. package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -1
  1412. package/dist/utils/zod-to-json-schema/parsers/union.d.cts +1 -2
  1413. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -1
  1414. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +0 -3
  1415. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -1
  1416. package/dist/utils/zod-to-json-schema/parsers/union.js +4 -8
  1417. package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -1
  1418. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +2 -3
  1419. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -1
  1420. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +0 -1
  1421. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -1
  1422. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +0 -2
  1423. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -1
  1424. package/dist/utils/zod-to-json-schema/parsers/unknown.js +1 -2
  1425. package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -1
  1426. package/dist/utils/zod-to-json-schema/selectParser.cjs +34 -35
  1427. package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -1
  1428. package/dist/utils/zod-to-json-schema/selectParser.d.cts +1 -0
  1429. package/dist/utils/zod-to-json-schema/selectParser.d.ts +0 -2
  1430. package/dist/utils/zod-to-json-schema/selectParser.js +2 -3
  1431. package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -1
  1432. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +7 -8
  1433. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -1
  1434. package/dist/utils/zod-to-json-schema/zodToJsonSchema.d.cts +1 -0
  1435. package/dist/utils/zod-to-json-schema/zodToJsonSchema.d.ts +1 -3
  1436. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +4 -5
  1437. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -1
  1438. package/dist/vectorstores.cjs +12 -14
  1439. package/dist/vectorstores.cjs.map +1 -1
  1440. package/dist/vectorstores.d.cts +0 -1
  1441. package/dist/vectorstores.d.cts.map +1 -1
  1442. package/dist/vectorstores.d.ts +0 -1
  1443. package/dist/vectorstores.d.ts.map +1 -1
  1444. package/dist/vectorstores.js +4 -7
  1445. package/dist/vectorstores.js.map +1 -1
  1446. package/package.json +116 -19
  1447. package/dist/_virtual/rolldown_runtime.js +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"string.cjs","names":["BasePromptTemplate","values: TypedPromptInputValues<RunInput>","StringPromptValue"],"sources":["../../src/prompts/string.ts"],"sourcesContent":["// Default generic \"any\" values are for backwards compatibility.\n// Replace with \"string\" when we are comfortable with a breaking change.\n\nimport type { InputValues } from \"../utils/types/index.js\";\nimport {\n type StringPromptValueInterface,\n StringPromptValue,\n} from \"../prompt_values.js\";\nimport { BasePromptTemplate, type TypedPromptInputValues } from \"./base.js\";\n\n/**\n * Base class for string prompt templates. It extends the\n * BasePromptTemplate class and overrides the formatPromptValue method to\n * return a StringPromptValue.\n */\nexport abstract class BaseStringPromptTemplate<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any\n> extends BasePromptTemplate<\n RunInput,\n StringPromptValueInterface,\n PartialVariableName\n> {\n /**\n * Formats the prompt given the input values and returns a formatted\n * prompt value.\n * @param values The input values to format the prompt.\n * @returns A Promise that resolves to a formatted prompt value.\n */\n async formatPromptValue(\n values: TypedPromptInputValues<RunInput>\n ): Promise<StringPromptValueInterface> {\n const formattedPrompt = await this.format(values);\n return new StringPromptValue(formattedPrompt);\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAsB,2BAAtB,cAKUA,gCAIR;;;;;;;CAOA,MAAM,kBACJC,QACqC;EACrC,MAAM,kBAAkB,MAAM,KAAK,OAAO,OAAO;AACjD,SAAO,IAAIC,wCAAkB;CAC9B;AACF"}
1
+ {"version":3,"file":"string.cjs","names":["BasePromptTemplate","StringPromptValue"],"sources":["../../src/prompts/string.ts"],"sourcesContent":["// Default generic \"any\" values are for backwards compatibility.\n// Replace with \"string\" when we are comfortable with a breaking change.\n\nimport type { InputValues } from \"../utils/types/index.js\";\nimport {\n type StringPromptValueInterface,\n StringPromptValue,\n} from \"../prompt_values.js\";\nimport { BasePromptTemplate, type TypedPromptInputValues } from \"./base.js\";\n\n/**\n * Base class for string prompt templates. It extends the\n * BasePromptTemplate class and overrides the formatPromptValue method to\n * return a StringPromptValue.\n */\nexport abstract class BaseStringPromptTemplate<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any,\n> extends BasePromptTemplate<\n RunInput,\n StringPromptValueInterface,\n PartialVariableName\n> {\n /**\n * Formats the prompt given the input values and returns a formatted\n * prompt value.\n * @param values The input values to format the prompt.\n * @returns A Promise that resolves to a formatted prompt value.\n */\n async formatPromptValue(\n values: TypedPromptInputValues<RunInput>\n ): Promise<StringPromptValueInterface> {\n const formattedPrompt = await this.format(values);\n return new StringPromptValue(formattedPrompt);\n }\n}\n"],"mappings":";;;;;;;;AAeA,IAAsB,2BAAtB,cAKUA,aAAAA,mBAIR;;;;;;;CAOA,MAAM,kBACJ,QACqC;AAErC,SAAO,IAAIC,sBAAAA,kBADa,MAAM,KAAK,OAAO,OAAO,CACJ"}
@@ -3,7 +3,6 @@ import { StringPromptValueInterface } from "../prompt_values.cjs";
3
3
  import { BasePromptTemplate, TypedPromptInputValues } from "./base.cjs";
4
4
 
5
5
  //#region src/prompts/string.d.ts
6
-
7
6
  /**
8
7
  * Base class for string prompt templates. It extends the
9
8
  * BasePromptTemplate class and overrides the formatPromptValue method to
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.cts","names":["InputValues","StringPromptValueInterface","BasePromptTemplate","TypedPromptInputValues","BaseStringPromptTemplate","RunInput","PartialVariableName","Promise"],"sources":["../../src/prompts/string.d.ts"],"sourcesContent":["import type { InputValues } from \"../utils/types/index.js\";\nimport { type StringPromptValueInterface } from \"../prompt_values.js\";\nimport { BasePromptTemplate, type TypedPromptInputValues } from \"./base.js\";\n/**\n * Base class for string prompt templates. It extends the\n * BasePromptTemplate class and overrides the formatPromptValue method to\n * return a StringPromptValue.\n */\nexport declare abstract class BaseStringPromptTemplate<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BasePromptTemplate<RunInput, StringPromptValueInterface, PartialVariableName> {\n /**\n * Formats the prompt given the input values and returns a formatted\n * prompt value.\n * @param values The input values to format the prompt.\n * @returns A Promise that resolves to a formatted prompt value.\n */\n formatPromptValue(values: TypedPromptInputValues<RunInput>): Promise<StringPromptValueInterface>;\n}\n//# sourceMappingURL=string.d.ts.map"],"mappings":";;;;;;;;AAQA;;;AAA0KC,uBAA5IG,wBAA4IH,CAAAA,iBAAlGD,WAAkGC,GAAAA,GAAAA,EAAAA,4BAAAA,MAAAA,GAAAA,GAAAA,CAAAA,SAA7BC,kBAA6BD,CAAVI,QAAUJ,EAAAA,0BAAAA,EAA4BK,mBAA5BL,CAAAA,CAAAA;EAA4BK;;;;;;EAAvC,iBAAA,CAAA,MAAA,EAOjIH,sBAPiI,CAO1GE,QAP0G,CAAA,CAAA,EAO9FE,OAP8F,CAOtFN,0BAPsF,CAAA"}
1
+ {"version":3,"file":"string.d.cts","names":[],"sources":["../../src/prompts/string.ts"],"mappings":";;;;;;;AAeA;;;uBAAsB,wBAAA,kBAEH,WAAA,0DAGT,kBAAA,CACR,QAAA,EACA,0BAAA,EACA,mBAAA;EAFA;;;;;;EAUM,iBAAA,CACJ,MAAA,EAAQ,sBAAA,CAAuB,QAAA,IAC9B,OAAA,CAAQ,0BAAA;AAAA"}
@@ -3,7 +3,6 @@ import { StringPromptValueInterface } from "../prompt_values.js";
3
3
  import { BasePromptTemplate, TypedPromptInputValues } from "./base.js";
4
4
 
5
5
  //#region src/prompts/string.d.ts
6
-
7
6
  /**
8
7
  * Base class for string prompt templates. It extends the
9
8
  * BasePromptTemplate class and overrides the formatPromptValue method to
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","names":["InputValues","StringPromptValueInterface","BasePromptTemplate","TypedPromptInputValues","BaseStringPromptTemplate","RunInput","PartialVariableName","Promise"],"sources":["../../src/prompts/string.d.ts"],"sourcesContent":["import type { InputValues } from \"../utils/types/index.js\";\nimport { type StringPromptValueInterface } from \"../prompt_values.js\";\nimport { BasePromptTemplate, type TypedPromptInputValues } from \"./base.js\";\n/**\n * Base class for string prompt templates. It extends the\n * BasePromptTemplate class and overrides the formatPromptValue method to\n * return a StringPromptValue.\n */\nexport declare abstract class BaseStringPromptTemplate<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BasePromptTemplate<RunInput, StringPromptValueInterface, PartialVariableName> {\n /**\n * Formats the prompt given the input values and returns a formatted\n * prompt value.\n * @param values The input values to format the prompt.\n * @returns A Promise that resolves to a formatted prompt value.\n */\n formatPromptValue(values: TypedPromptInputValues<RunInput>): Promise<StringPromptValueInterface>;\n}\n//# sourceMappingURL=string.d.ts.map"],"mappings":";;;;;;;;AAQA;;;AAA0KC,uBAA5IG,wBAA4IH,CAAAA,iBAAlGD,WAAkGC,GAAAA,GAAAA,EAAAA,4BAAAA,MAAAA,GAAAA,GAAAA,CAAAA,SAA7BC,kBAA6BD,CAAVI,QAAUJ,EAAAA,0BAAAA,EAA4BK,mBAA5BL,CAAAA,CAAAA;EAA4BK;;;;;;EAAvC,iBAAA,CAAA,MAAA,EAOjIH,sBAPiI,CAO1GE,QAP0G,CAAA,CAAA,EAO9FE,OAP8F,CAOtFN,0BAPsF,CAAA"}
1
+ {"version":3,"file":"string.d.ts","names":[],"sources":["../../src/prompts/string.ts"],"mappings":";;;;;;;AAeA;;;uBAAsB,wBAAA,kBAEH,WAAA,0DAGT,kBAAA,CACR,QAAA,EACA,0BAAA,EACA,mBAAA;EAFA;;;;;;EAUM,iBAAA,CACJ,MAAA,EAAQ,sBAAA,CAAuB,QAAA,IAC9B,OAAA,CAAQ,0BAAA;AAAA"}
@@ -1,6 +1,5 @@
1
1
  import { StringPromptValue } from "../prompt_values.js";
2
2
  import { BasePromptTemplate } from "./base.js";
3
-
4
3
  //#region src/prompts/string.ts
5
4
  /**
6
5
  * Base class for string prompt templates. It extends the
@@ -15,11 +14,10 @@ var BaseStringPromptTemplate = class extends BasePromptTemplate {
15
14
  * @returns A Promise that resolves to a formatted prompt value.
16
15
  */
17
16
  async formatPromptValue(values) {
18
- const formattedPrompt = await this.format(values);
19
- return new StringPromptValue(formattedPrompt);
17
+ return new StringPromptValue(await this.format(values));
20
18
  }
21
19
  };
22
-
23
20
  //#endregion
24
21
  export { BaseStringPromptTemplate };
22
+
25
23
  //# sourceMappingURL=string.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","names":["values: TypedPromptInputValues<RunInput>"],"sources":["../../src/prompts/string.ts"],"sourcesContent":["// Default generic \"any\" values are for backwards compatibility.\n// Replace with \"string\" when we are comfortable with a breaking change.\n\nimport type { InputValues } from \"../utils/types/index.js\";\nimport {\n type StringPromptValueInterface,\n StringPromptValue,\n} from \"../prompt_values.js\";\nimport { BasePromptTemplate, type TypedPromptInputValues } from \"./base.js\";\n\n/**\n * Base class for string prompt templates. It extends the\n * BasePromptTemplate class and overrides the formatPromptValue method to\n * return a StringPromptValue.\n */\nexport abstract class BaseStringPromptTemplate<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any\n> extends BasePromptTemplate<\n RunInput,\n StringPromptValueInterface,\n PartialVariableName\n> {\n /**\n * Formats the prompt given the input values and returns a formatted\n * prompt value.\n * @param values The input values to format the prompt.\n * @returns A Promise that resolves to a formatted prompt value.\n */\n async formatPromptValue(\n values: TypedPromptInputValues<RunInput>\n ): Promise<StringPromptValueInterface> {\n const formattedPrompt = await this.format(values);\n return new StringPromptValue(formattedPrompt);\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAsB,2BAAtB,cAKU,mBAIR;;;;;;;CAOA,MAAM,kBACJA,QACqC;EACrC,MAAM,kBAAkB,MAAM,KAAK,OAAO,OAAO;AACjD,SAAO,IAAI,kBAAkB;CAC9B;AACF"}
1
+ {"version":3,"file":"string.js","names":[],"sources":["../../src/prompts/string.ts"],"sourcesContent":["// Default generic \"any\" values are for backwards compatibility.\n// Replace with \"string\" when we are comfortable with a breaking change.\n\nimport type { InputValues } from \"../utils/types/index.js\";\nimport {\n type StringPromptValueInterface,\n StringPromptValue,\n} from \"../prompt_values.js\";\nimport { BasePromptTemplate, type TypedPromptInputValues } from \"./base.js\";\n\n/**\n * Base class for string prompt templates. It extends the\n * BasePromptTemplate class and overrides the formatPromptValue method to\n * return a StringPromptValue.\n */\nexport abstract class BaseStringPromptTemplate<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any,\n> extends BasePromptTemplate<\n RunInput,\n StringPromptValueInterface,\n PartialVariableName\n> {\n /**\n * Formats the prompt given the input values and returns a formatted\n * prompt value.\n * @param values The input values to format the prompt.\n * @returns A Promise that resolves to a formatted prompt value.\n */\n async formatPromptValue(\n values: TypedPromptInputValues<RunInput>\n ): Promise<StringPromptValueInterface> {\n const formattedPrompt = await this.format(values);\n return new StringPromptValue(formattedPrompt);\n }\n}\n"],"mappings":";;;;;;;;AAeA,IAAsB,2BAAtB,cAKU,mBAIR;;;;;;;CAOA,MAAM,kBACJ,QACqC;AAErC,SAAO,IAAI,kBADa,MAAM,KAAK,OAAO,OAAO,CACJ"}
@@ -1,6 +1,5 @@
1
- const require_base = require('../runnables/base.cjs');
2
- const require_chat = require('./chat.cjs');
3
-
1
+ const require_base = require("../runnables/base.cjs");
2
+ const require_chat = require("./chat.cjs");
4
3
  //#region src/prompts/structured.ts
5
4
  function isWithStructuredOutput(x) {
6
5
  return typeof x === "object" && x != null && "withStructuredOutput" in x && typeof x.withStructuredOutput === "function";
@@ -44,7 +43,7 @@ var StructuredPrompt = class StructuredPrompt extends require_chat.ChatPromptTem
44
43
  });
45
44
  }
46
45
  };
47
-
48
46
  //#endregion
49
47
  exports.StructuredPrompt = StructuredPrompt;
48
+
50
49
  //# sourceMappingURL=structured.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"structured.cjs","names":["x: unknown","ChatPromptTemplate","input: StructuredPromptInput<RunInput, PartialVariableName>","coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>","RunnableBinding","promptMessages: (\n | ChatPromptTemplate<InputValues, string>\n | BaseMessagePromptTemplateLike\n )[]","schema: StructuredPromptInput[\"schema\"]","method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\""],"sources":["../../src/prompts/structured.ts"],"sourcesContent":["import { ChatPromptValueInterface } from \"../prompt_values.js\";\nimport { RunnableLike, Runnable, RunnableBinding } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { InputValues } from \"../utils/types/index.js\";\nimport {\n BaseMessagePromptTemplateLike,\n ChatPromptTemplate,\n ChatPromptTemplateInput,\n} from \"./chat.js\";\n\nfunction isWithStructuredOutput(x: unknown): x is {\n withStructuredOutput: (...arg: unknown[]) => Runnable;\n} {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"withStructuredOutput\" in x &&\n typeof x.withStructuredOutput === \"function\"\n );\n}\n\nfunction isRunnableBinding(x: unknown): x is RunnableBinding<unknown, unknown> {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"lc_id\" in x &&\n Array.isArray(x.lc_id) &&\n x.lc_id.join(\"/\") === \"langchain_core/runnables/RunnableBinding\"\n );\n}\n\n/**\n * Interface for the input of a ChatPromptTemplate.\n */\nexport interface StructuredPromptInput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any\n> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n}\n\nexport class StructuredPrompt<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any\n >\n extends ChatPromptTemplate<RunInput, PartialVariableName>\n implements StructuredPromptInput<RunInput, PartialVariableName>\n{\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n\n lc_namespace = [\"langchain_core\", \"prompts\", \"structured\"];\n\n get lc_aliases(): Record<string, string> {\n return {\n ...super.lc_aliases,\n schema: \"schema_\",\n };\n }\n\n constructor(input: StructuredPromptInput<RunInput, PartialVariableName>) {\n super(input);\n this.schema = input.schema;\n this.method = input.method;\n }\n\n pipe<NewRunOutput>(\n coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>\n ): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig> {\n if (isWithStructuredOutput(coerceable)) {\n return super.pipe(coerceable.withStructuredOutput(this.schema));\n }\n\n if (\n isRunnableBinding(coerceable) &&\n isWithStructuredOutput(coerceable.bound)\n ) {\n return super.pipe(\n new RunnableBinding({\n bound: coerceable.bound.withStructuredOutput(\n this.schema,\n ...(this.method ? [{ method: this.method }] : [])\n ),\n kwargs: coerceable.kwargs ?? {},\n config: coerceable.config,\n configFactories: coerceable.configFactories,\n })\n );\n }\n\n throw new Error(\n `Structured prompts need to be piped to a language model that supports the \"withStructuredOutput()\" method.`\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static fromMessagesAndSchema<RunInput extends InputValues = any>(\n promptMessages: (\n | ChatPromptTemplate<InputValues, string>\n | BaseMessagePromptTemplateLike\n )[],\n schema: StructuredPromptInput[\"schema\"],\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\"\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): ChatPromptTemplate<RunInput, any> {\n return StructuredPrompt.fromMessages<\n RunInput,\n StructuredPromptInput<RunInput>\n >(promptMessages, { schema, method });\n }\n}\n"],"mappings":";;;;AAUA,SAAS,uBAAuBA,GAE9B;AACA,QACE,OAAO,MAAM,YACb,KAAK,QACL,0BAA0B,KAC1B,OAAO,EAAE,yBAAyB;AAErC;AAED,SAAS,kBAAkBA,GAAoD;AAC7E,QACE,OAAO,MAAM,YACb,KAAK,QACL,WAAW,KACX,MAAM,QAAQ,EAAE,MAAM,IACtB,EAAE,MAAM,KAAK,IAAI,KAAK;AAEzB;AAgBD,IAAa,mBAAb,MAAa,yBAMHC,gCAEV;CAEE;CAEA;CAEA,eAAe;EAAC;EAAkB;EAAW;CAAa;CAE1D,IAAI,aAAqC;AACvC,SAAO;GACL,GAAG,MAAM;GACT,QAAQ;EACT;CACF;CAED,YAAYC,OAA6D;EACvE,MAAM,MAAM;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,SAAS,MAAM;CACrB;CAED,KACEC,YACkE;AAClE,MAAI,uBAAuB,WAAW,CACpC,QAAO,MAAM,KAAK,WAAW,qBAAqB,KAAK,OAAO,CAAC;AAGjE,MACE,kBAAkB,WAAW,IAC7B,uBAAuB,WAAW,MAAM,CAExC,QAAO,MAAM,KACX,IAAIC,6BAAgB;GAClB,OAAO,WAAW,MAAM,qBACtB,KAAK,QACL,GAAI,KAAK,SAAS,CAAC,EAAE,QAAQ,KAAK,OAAQ,CAAC,IAAG,CAAE,EACjD;GACD,QAAQ,WAAW,UAAU,CAAE;GAC/B,QAAQ,WAAW;GACnB,iBAAiB,WAAW;EAC7B,GACF;AAGH,QAAM,IAAI,MACR,CAAC,0GAA0G,CAAC;CAE/G;CAGD,OAAO,sBACLC,gBAIAC,QACAC,QAEmC;AACnC,SAAO,iBAAiB,aAGtB,gBAAgB;GAAE;GAAQ;EAAQ,EAAC;CACtC;AACF"}
1
+ {"version":3,"file":"structured.cjs","names":["ChatPromptTemplate","RunnableBinding"],"sources":["../../src/prompts/structured.ts"],"sourcesContent":["import { ChatPromptValueInterface } from \"../prompt_values.js\";\nimport { RunnableLike, Runnable, RunnableBinding } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { InputValues } from \"../utils/types/index.js\";\nimport {\n BaseMessagePromptTemplateLike,\n ChatPromptTemplate,\n ChatPromptTemplateInput,\n} from \"./chat.js\";\n\nfunction isWithStructuredOutput(x: unknown): x is {\n withStructuredOutput: (...arg: unknown[]) => Runnable;\n} {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"withStructuredOutput\" in x &&\n typeof x.withStructuredOutput === \"function\"\n );\n}\n\nfunction isRunnableBinding(x: unknown): x is RunnableBinding<unknown, unknown> {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"lc_id\" in x &&\n Array.isArray(x.lc_id) &&\n x.lc_id.join(\"/\") === \"langchain_core/runnables/RunnableBinding\"\n );\n}\n\n/**\n * Interface for the input of a ChatPromptTemplate.\n */\nexport interface StructuredPromptInput<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any,\n> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n}\n\nexport class StructuredPrompt<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any,\n>\n extends ChatPromptTemplate<RunInput, PartialVariableName>\n implements StructuredPromptInput<RunInput, PartialVariableName>\n{\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n\n lc_namespace = [\"langchain_core\", \"prompts\", \"structured\"];\n\n get lc_aliases(): Record<string, string> {\n return {\n ...super.lc_aliases,\n schema: \"schema_\",\n };\n }\n\n constructor(input: StructuredPromptInput<RunInput, PartialVariableName>) {\n super(input);\n this.schema = input.schema;\n this.method = input.method;\n }\n\n pipe<NewRunOutput>(\n coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>\n ): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig> {\n if (isWithStructuredOutput(coerceable)) {\n return super.pipe(coerceable.withStructuredOutput(this.schema));\n }\n\n if (\n isRunnableBinding(coerceable) &&\n isWithStructuredOutput(coerceable.bound)\n ) {\n return super.pipe(\n new RunnableBinding({\n bound: coerceable.bound.withStructuredOutput(\n this.schema,\n ...(this.method ? [{ method: this.method }] : [])\n ),\n kwargs: coerceable.kwargs ?? {},\n config: coerceable.config,\n configFactories: coerceable.configFactories,\n })\n );\n }\n\n throw new Error(\n `Structured prompts need to be piped to a language model that supports the \"withStructuredOutput()\" method.`\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n static fromMessagesAndSchema<RunInput extends InputValues = any>(\n promptMessages: (\n | ChatPromptTemplate<InputValues, string>\n | BaseMessagePromptTemplateLike\n )[],\n schema: StructuredPromptInput[\"schema\"],\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\"\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n ): ChatPromptTemplate<RunInput, any> {\n return StructuredPrompt.fromMessages<\n RunInput,\n StructuredPromptInput<RunInput>\n >(promptMessages, { schema, method });\n }\n}\n"],"mappings":";;;AAUA,SAAS,uBAAuB,GAE9B;AACA,QACE,OAAO,MAAM,YACb,KAAK,QACL,0BAA0B,KAC1B,OAAO,EAAE,yBAAyB;;AAItC,SAAS,kBAAkB,GAAoD;AAC7E,QACE,OAAO,MAAM,YACb,KAAK,QACL,WAAW,KACX,MAAM,QAAQ,EAAE,MAAM,IACtB,EAAE,MAAM,KAAK,IAAI,KAAK;;AAkB1B,IAAa,mBAAb,MAAa,yBAMHA,aAAAA,mBAEV;CAEE;CAEA;CAEA,eAAe;EAAC;EAAkB;EAAW;EAAa;CAE1D,IAAI,aAAqC;AACvC,SAAO;GACL,GAAG,MAAM;GACT,QAAQ;GACT;;CAGH,YAAY,OAA6D;AACvE,QAAM,MAAM;AACZ,OAAK,SAAS,MAAM;AACpB,OAAK,SAAS,MAAM;;CAGtB,KACE,YACkE;AAClE,MAAI,uBAAuB,WAAW,CACpC,QAAO,MAAM,KAAK,WAAW,qBAAqB,KAAK,OAAO,CAAC;AAGjE,MACE,kBAAkB,WAAW,IAC7B,uBAAuB,WAAW,MAAM,CAExC,QAAO,MAAM,KACX,IAAIC,aAAAA,gBAAgB;GAClB,OAAO,WAAW,MAAM,qBACtB,KAAK,QACL,GAAI,KAAK,SAAS,CAAC,EAAE,QAAQ,KAAK,QAAQ,CAAC,GAAG,EAAE,CACjD;GACD,QAAQ,WAAW,UAAU,EAAE;GAC/B,QAAQ,WAAW;GACnB,iBAAiB,WAAW;GAC7B,CAAC,CACH;AAGH,QAAM,IAAI,MACR,6GACD;;CAIH,OAAO,sBACL,gBAIA,QACA,QAEmC;AACnC,SAAO,iBAAiB,aAGtB,gBAAgB;GAAE;GAAQ;GAAQ,CAAC"}
@@ -5,7 +5,6 @@ import { ChatPromptValueInterface } from "../prompt_values.cjs";
5
5
  import { BaseMessagePromptTemplateLike, ChatPromptTemplate, ChatPromptTemplateInput } from "./chat.cjs";
6
6
 
7
7
  //#region src/prompts/structured.d.ts
8
-
9
8
  /**
10
9
  * Interface for the input of a ChatPromptTemplate.
11
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"structured.d.cts","names":["ChatPromptValueInterface","RunnableLike","Runnable","RunnableConfig","InputValues","BaseMessagePromptTemplateLike","ChatPromptTemplate","ChatPromptTemplateInput","StructuredPromptInput","RunInput","PartialVariableName","Record","StructuredPrompt","NewRunOutput","Error","Exclude"],"sources":["../../src/prompts/structured.d.ts"],"sourcesContent":["import { ChatPromptValueInterface } from \"../prompt_values.js\";\nimport { RunnableLike, Runnable } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { InputValues } from \"../utils/types/index.js\";\nimport { BaseMessagePromptTemplateLike, ChatPromptTemplate, ChatPromptTemplateInput } from \"./chat.js\";\n/**\n * Interface for the input of a ChatPromptTemplate.\n */\nexport interface StructuredPromptInput<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n}\nexport declare class StructuredPrompt<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplate<RunInput, PartialVariableName> implements StructuredPromptInput<RunInput, PartialVariableName> {\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n lc_namespace: string[];\n get lc_aliases(): Record<string, string>;\n constructor(input: StructuredPromptInput<RunInput, PartialVariableName>);\n pipe<NewRunOutput>(coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig>;\n static fromMessagesAndSchema<RunInput extends InputValues = any>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], schema: StructuredPromptInput[\"schema\"], method?: \"jsonMode\" | \"jsonSchema\" | \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iBAOvKN,WAPuKM,GAAAA,GAAAA,CAAAA,CAAAA,cAAAA,EAAAA,CAOnIJ,kBAPmII,CAOhHN,WAPgHM,EAAAA,MAAAA,CAAAA,GAOzFL,6BAPyFK,CAAAA,EAAAA,EAAAA,MAAAA,EAO/CF,qBAP+CE,CAAAA,QAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAAA,UAAAA,GAAAA,YAAAA,GAAAA,cAAAA,CAAAA,EAOwCJ,kBAPxCI,CAO2DD,QAP3DC,EAAAA,GAAAA,CAAAA"}
1
+ {"version":3,"file":"structured.d.cts","names":[],"sources":["../../src/prompts/structured.ts"],"mappings":";;;;;;;;;;UAkCiB,qBAAA,kBAEE,WAAA,0DAGT,uBAAA,CAAwB,QAAA,EAAU,mBAAA;EAE1C,MAAA,EAAQ,MAAA;EACR,MAAA;AAAA;AAAA,cAGW,gBAAA,kBAEM,WAAA,0DAIT,kBAAA,CAAmB,QAAA,EAAU,mBAAA,aAC1B,qBAAA,CAAsB,QAAA,EAAU,mBAAA;EAG3C,MAAA,EAAQ,MAAA;EAER,MAAA;EAEA,YAAA;EAAA,IAEI,UAAA,CAAA,GAAc,MAAA;EAOlB,WAAA,CAAY,KAAA,EAAO,qBAAA,CAAsB,QAAA,EAAU,mBAAA;EAMnD,IAAA,cAAA,CACE,UAAA,EAAY,YAAA,CAAa,wBAAA,EAA0B,YAAA,IAClD,QAAA,CAAS,QAAA,EAAU,OAAA,CAAQ,YAAA,EAAc,KAAA,GAAQ,cAAA;EAAA,OA4B7C,qBAAA,kBAAuC,WAAA,OAAA,CAC5C,cAAA,GACI,kBAAA,CAAmB,WAAA,YACnB,6BAAA,KAEJ,MAAA,EAAQ,qBAAA,YACR,MAAA,gDAEC,kBAAA,CAAmB,QAAA;AAAA"}
@@ -1,6 +1,5 @@
1
1
  import { InputValues } from "../utils/types/index.js";
2
2
  import { RunnableConfig } from "../runnables/types.js";
3
- import "../runnables/config.js";
4
3
  import { Runnable, RunnableLike } from "../runnables/base.js";
5
4
  import { ChatPromptValueInterface } from "../prompt_values.js";
6
5
  import { BaseMessagePromptTemplateLike, ChatPromptTemplate, ChatPromptTemplateInput } from "./chat.js";
@@ -1 +1 @@
1
- {"version":3,"file":"structured.d.ts","names":["ChatPromptValueInterface","RunnableLike","Runnable","RunnableConfig","InputValues","BaseMessagePromptTemplateLike","ChatPromptTemplate","ChatPromptTemplateInput","StructuredPromptInput","RunInput","PartialVariableName","Record","StructuredPrompt","NewRunOutput","Error","Exclude"],"sources":["../../src/prompts/structured.d.ts"],"sourcesContent":["import { ChatPromptValueInterface } from \"../prompt_values.js\";\nimport { RunnableLike, Runnable } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { InputValues } from \"../utils/types/index.js\";\nimport { BaseMessagePromptTemplateLike, ChatPromptTemplate, ChatPromptTemplateInput } from \"./chat.js\";\n/**\n * Interface for the input of a ChatPromptTemplate.\n */\nexport interface StructuredPromptInput<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n}\nexport declare class StructuredPrompt<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplate<RunInput, PartialVariableName> implements StructuredPromptInput<RunInput, PartialVariableName> {\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n lc_namespace: string[];\n get lc_aliases(): Record<string, string>;\n constructor(input: StructuredPromptInput<RunInput, PartialVariableName>);\n pipe<NewRunOutput>(coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig>;\n static fromMessagesAndSchema<RunInput extends InputValues = any>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], schema: StructuredPromptInput[\"schema\"], method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\"): ChatPromptTemplate<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,cAAAA,EAAAA,CAOzHH,kBAPyHG,CAOtGL,WAPsGK,EAAAA,MAAAA,CAAAA,GAO/EJ,6BAP+EI,CAAAA,EAAAA,EAAAA,MAAAA,EAOrCD,qBAPqCC,CAAAA,QAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAAA,UAAAA,GAAAA,YAAAA,GAAAA,cAAAA,CAAAA,EAOkDH,kBAPlDG,CAOqEA,QAPrEA,EAAAA,GAAAA,CAAAA"}
1
+ {"version":3,"file":"structured.d.ts","names":[],"sources":["../../src/prompts/structured.ts"],"mappings":";;;;;;;;;;UAkCiB,qBAAA,kBAEE,WAAA,0DAGT,uBAAA,CAAwB,QAAA,EAAU,mBAAA;EAE1C,MAAA,EAAQ,MAAA;EACR,MAAA;AAAA;AAAA,cAGW,gBAAA,kBAEM,WAAA,0DAIT,kBAAA,CAAmB,QAAA,EAAU,mBAAA,aAC1B,qBAAA,CAAsB,QAAA,EAAU,mBAAA;EAG3C,MAAA,EAAQ,MAAA;EAER,MAAA;EAEA,YAAA;EAAA,IAEI,UAAA,CAAA,GAAc,MAAA;EAOlB,WAAA,CAAY,KAAA,EAAO,qBAAA,CAAsB,QAAA,EAAU,mBAAA;EAMnD,IAAA,cAAA,CACE,UAAA,EAAY,YAAA,CAAa,wBAAA,EAA0B,YAAA,IAClD,QAAA,CAAS,QAAA,EAAU,OAAA,CAAQ,YAAA,EAAc,KAAA,GAAQ,cAAA;EAAA,OA4B7C,qBAAA,kBAAuC,WAAA,OAAA,CAC5C,cAAA,GACI,kBAAA,CAAmB,WAAA,YACnB,6BAAA,KAEJ,MAAA,EAAQ,qBAAA,YACR,MAAA,gDAEC,kBAAA,CAAmB,QAAA;AAAA"}
@@ -1,6 +1,5 @@
1
1
  import { RunnableBinding } from "../runnables/base.js";
2
2
  import { ChatPromptTemplate } from "./chat.js";
3
-
4
3
  //#region src/prompts/structured.ts
5
4
  function isWithStructuredOutput(x) {
6
5
  return typeof x === "object" && x != null && "withStructuredOutput" in x && typeof x.withStructuredOutput === "function";
@@ -44,7 +43,7 @@ var StructuredPrompt = class StructuredPrompt extends ChatPromptTemplate {
44
43
  });
45
44
  }
46
45
  };
47
-
48
46
  //#endregion
49
47
  export { StructuredPrompt };
48
+
50
49
  //# sourceMappingURL=structured.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"structured.js","names":["x: unknown","input: StructuredPromptInput<RunInput, PartialVariableName>","coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>","promptMessages: (\n | ChatPromptTemplate<InputValues, string>\n | BaseMessagePromptTemplateLike\n )[]","schema: StructuredPromptInput[\"schema\"]","method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\""],"sources":["../../src/prompts/structured.ts"],"sourcesContent":["import { ChatPromptValueInterface } from \"../prompt_values.js\";\nimport { RunnableLike, Runnable, RunnableBinding } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { InputValues } from \"../utils/types/index.js\";\nimport {\n BaseMessagePromptTemplateLike,\n ChatPromptTemplate,\n ChatPromptTemplateInput,\n} from \"./chat.js\";\n\nfunction isWithStructuredOutput(x: unknown): x is {\n withStructuredOutput: (...arg: unknown[]) => Runnable;\n} {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"withStructuredOutput\" in x &&\n typeof x.withStructuredOutput === \"function\"\n );\n}\n\nfunction isRunnableBinding(x: unknown): x is RunnableBinding<unknown, unknown> {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"lc_id\" in x &&\n Array.isArray(x.lc_id) &&\n x.lc_id.join(\"/\") === \"langchain_core/runnables/RunnableBinding\"\n );\n}\n\n/**\n * Interface for the input of a ChatPromptTemplate.\n */\nexport interface StructuredPromptInput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any\n> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n}\n\nexport class StructuredPrompt<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any\n >\n extends ChatPromptTemplate<RunInput, PartialVariableName>\n implements StructuredPromptInput<RunInput, PartialVariableName>\n{\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n\n lc_namespace = [\"langchain_core\", \"prompts\", \"structured\"];\n\n get lc_aliases(): Record<string, string> {\n return {\n ...super.lc_aliases,\n schema: \"schema_\",\n };\n }\n\n constructor(input: StructuredPromptInput<RunInput, PartialVariableName>) {\n super(input);\n this.schema = input.schema;\n this.method = input.method;\n }\n\n pipe<NewRunOutput>(\n coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>\n ): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig> {\n if (isWithStructuredOutput(coerceable)) {\n return super.pipe(coerceable.withStructuredOutput(this.schema));\n }\n\n if (\n isRunnableBinding(coerceable) &&\n isWithStructuredOutput(coerceable.bound)\n ) {\n return super.pipe(\n new RunnableBinding({\n bound: coerceable.bound.withStructuredOutput(\n this.schema,\n ...(this.method ? [{ method: this.method }] : [])\n ),\n kwargs: coerceable.kwargs ?? {},\n config: coerceable.config,\n configFactories: coerceable.configFactories,\n })\n );\n }\n\n throw new Error(\n `Structured prompts need to be piped to a language model that supports the \"withStructuredOutput()\" method.`\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static fromMessagesAndSchema<RunInput extends InputValues = any>(\n promptMessages: (\n | ChatPromptTemplate<InputValues, string>\n | BaseMessagePromptTemplateLike\n )[],\n schema: StructuredPromptInput[\"schema\"],\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\"\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): ChatPromptTemplate<RunInput, any> {\n return StructuredPrompt.fromMessages<\n RunInput,\n StructuredPromptInput<RunInput>\n >(promptMessages, { schema, method });\n }\n}\n"],"mappings":";;;;AAUA,SAAS,uBAAuBA,GAE9B;AACA,QACE,OAAO,MAAM,YACb,KAAK,QACL,0BAA0B,KAC1B,OAAO,EAAE,yBAAyB;AAErC;AAED,SAAS,kBAAkBA,GAAoD;AAC7E,QACE,OAAO,MAAM,YACb,KAAK,QACL,WAAW,KACX,MAAM,QAAQ,EAAE,MAAM,IACtB,EAAE,MAAM,KAAK,IAAI,KAAK;AAEzB;AAgBD,IAAa,mBAAb,MAAa,yBAMH,mBAEV;CAEE;CAEA;CAEA,eAAe;EAAC;EAAkB;EAAW;CAAa;CAE1D,IAAI,aAAqC;AACvC,SAAO;GACL,GAAG,MAAM;GACT,QAAQ;EACT;CACF;CAED,YAAYC,OAA6D;EACvE,MAAM,MAAM;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,SAAS,MAAM;CACrB;CAED,KACEC,YACkE;AAClE,MAAI,uBAAuB,WAAW,CACpC,QAAO,MAAM,KAAK,WAAW,qBAAqB,KAAK,OAAO,CAAC;AAGjE,MACE,kBAAkB,WAAW,IAC7B,uBAAuB,WAAW,MAAM,CAExC,QAAO,MAAM,KACX,IAAI,gBAAgB;GAClB,OAAO,WAAW,MAAM,qBACtB,KAAK,QACL,GAAI,KAAK,SAAS,CAAC,EAAE,QAAQ,KAAK,OAAQ,CAAC,IAAG,CAAE,EACjD;GACD,QAAQ,WAAW,UAAU,CAAE;GAC/B,QAAQ,WAAW;GACnB,iBAAiB,WAAW;EAC7B,GACF;AAGH,QAAM,IAAI,MACR,CAAC,0GAA0G,CAAC;CAE/G;CAGD,OAAO,sBACLC,gBAIAC,QACAC,QAEmC;AACnC,SAAO,iBAAiB,aAGtB,gBAAgB;GAAE;GAAQ;EAAQ,EAAC;CACtC;AACF"}
1
+ {"version":3,"file":"structured.js","names":[],"sources":["../../src/prompts/structured.ts"],"sourcesContent":["import { ChatPromptValueInterface } from \"../prompt_values.js\";\nimport { RunnableLike, Runnable, RunnableBinding } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { InputValues } from \"../utils/types/index.js\";\nimport {\n BaseMessagePromptTemplateLike,\n ChatPromptTemplate,\n ChatPromptTemplateInput,\n} from \"./chat.js\";\n\nfunction isWithStructuredOutput(x: unknown): x is {\n withStructuredOutput: (...arg: unknown[]) => Runnable;\n} {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"withStructuredOutput\" in x &&\n typeof x.withStructuredOutput === \"function\"\n );\n}\n\nfunction isRunnableBinding(x: unknown): x is RunnableBinding<unknown, unknown> {\n return (\n typeof x === \"object\" &&\n x != null &&\n \"lc_id\" in x &&\n Array.isArray(x.lc_id) &&\n x.lc_id.join(\"/\") === \"langchain_core/runnables/RunnableBinding\"\n );\n}\n\n/**\n * Interface for the input of a ChatPromptTemplate.\n */\nexport interface StructuredPromptInput<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any,\n> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n}\n\nexport class StructuredPrompt<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput extends InputValues = any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n PartialVariableName extends string = any,\n>\n extends ChatPromptTemplate<RunInput, PartialVariableName>\n implements StructuredPromptInput<RunInput, PartialVariableName>\n{\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>;\n\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\";\n\n lc_namespace = [\"langchain_core\", \"prompts\", \"structured\"];\n\n get lc_aliases(): Record<string, string> {\n return {\n ...super.lc_aliases,\n schema: \"schema_\",\n };\n }\n\n constructor(input: StructuredPromptInput<RunInput, PartialVariableName>) {\n super(input);\n this.schema = input.schema;\n this.method = input.method;\n }\n\n pipe<NewRunOutput>(\n coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>\n ): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig> {\n if (isWithStructuredOutput(coerceable)) {\n return super.pipe(coerceable.withStructuredOutput(this.schema));\n }\n\n if (\n isRunnableBinding(coerceable) &&\n isWithStructuredOutput(coerceable.bound)\n ) {\n return super.pipe(\n new RunnableBinding({\n bound: coerceable.bound.withStructuredOutput(\n this.schema,\n ...(this.method ? [{ method: this.method }] : [])\n ),\n kwargs: coerceable.kwargs ?? {},\n config: coerceable.config,\n configFactories: coerceable.configFactories,\n })\n );\n }\n\n throw new Error(\n `Structured prompts need to be piped to a language model that supports the \"withStructuredOutput()\" method.`\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n static fromMessagesAndSchema<RunInput extends InputValues = any>(\n promptMessages: (\n | ChatPromptTemplate<InputValues, string>\n | BaseMessagePromptTemplateLike\n )[],\n schema: StructuredPromptInput[\"schema\"],\n method?: \"jsonMode\" | \"jsonSchema\" | \"functionMode\"\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n ): ChatPromptTemplate<RunInput, any> {\n return StructuredPrompt.fromMessages<\n RunInput,\n StructuredPromptInput<RunInput>\n >(promptMessages, { schema, method });\n }\n}\n"],"mappings":";;;AAUA,SAAS,uBAAuB,GAE9B;AACA,QACE,OAAO,MAAM,YACb,KAAK,QACL,0BAA0B,KAC1B,OAAO,EAAE,yBAAyB;;AAItC,SAAS,kBAAkB,GAAoD;AAC7E,QACE,OAAO,MAAM,YACb,KAAK,QACL,WAAW,KACX,MAAM,QAAQ,EAAE,MAAM,IACtB,EAAE,MAAM,KAAK,IAAI,KAAK;;AAkB1B,IAAa,mBAAb,MAAa,yBAMH,mBAEV;CAEE;CAEA;CAEA,eAAe;EAAC;EAAkB;EAAW;EAAa;CAE1D,IAAI,aAAqC;AACvC,SAAO;GACL,GAAG,MAAM;GACT,QAAQ;GACT;;CAGH,YAAY,OAA6D;AACvE,QAAM,MAAM;AACZ,OAAK,SAAS,MAAM;AACpB,OAAK,SAAS,MAAM;;CAGtB,KACE,YACkE;AAClE,MAAI,uBAAuB,WAAW,CACpC,QAAO,MAAM,KAAK,WAAW,qBAAqB,KAAK,OAAO,CAAC;AAGjE,MACE,kBAAkB,WAAW,IAC7B,uBAAuB,WAAW,MAAM,CAExC,QAAO,MAAM,KACX,IAAI,gBAAgB;GAClB,OAAO,WAAW,MAAM,qBACtB,KAAK,QACL,GAAI,KAAK,SAAS,CAAC,EAAE,QAAQ,KAAK,QAAQ,CAAC,GAAG,EAAE,CACjD;GACD,QAAQ,WAAW,UAAU,EAAE;GAC/B,QAAQ,WAAW;GACnB,iBAAiB,WAAW;GAC7B,CAAC,CACH;AAGH,QAAM,IAAI,MACR,6GACD;;CAIH,OAAO,sBACL,gBAIA,QACA,QAEmC;AACnC,SAAO,iBAAiB,aAGtB,gBAAgB;GAAE;GAAQ;GAAQ,CAAC"}
@@ -1,7 +1,7 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_index = require('../errors/index.cjs');
3
- const mustache = require_rolldown_runtime.__toESM(require("mustache"));
4
-
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_errors_index = require("../errors/index.cjs");
3
+ let mustache = require("mustache");
4
+ mustache = require_runtime.__toESM(mustache);
5
5
  //#region src/prompts/template.ts
6
6
  function configureMustache() {
7
7
  mustache.default.escape = (text) => text;
@@ -10,7 +10,7 @@ const parseFString = (template) => {
10
10
  const chars = template.split("");
11
11
  const nodes = [];
12
12
  const nextBracket = (bracket, start) => {
13
- for (let i$1 = start; i$1 < chars.length; i$1 += 1) if (bracket.includes(chars[i$1])) return i$1;
13
+ for (let i = start; i < chars.length; i += 1) if (bracket.includes(chars[i])) return i;
14
14
  return -1;
15
15
  };
16
16
  let i = 0;
@@ -85,16 +85,12 @@ const mustacheTemplateToNodes = (template, context = []) => {
85
85
  };
86
86
  const parseMustache = (template) => {
87
87
  configureMustache();
88
- const parsed = mustache.default.parse(template);
89
- return mustacheTemplateToNodes(parsed);
88
+ return mustacheTemplateToNodes(mustache.default.parse(template));
90
89
  };
91
90
  const interpolateFString = (template, values) => {
92
91
  return parseFString(template).reduce((res, node) => {
93
92
  if (node.type === "variable") {
94
- if (node.name in values) {
95
- const stringValue = typeof values[node.name] === "string" ? values[node.name] : JSON.stringify(values[node.name]);
96
- return res + stringValue;
97
- }
93
+ if (node.name in values) return res + (typeof values[node.name] === "string" ? values[node.name] : JSON.stringify(values[node.name]));
98
94
  throw new Error(`(f-string) Missing value for input ${node.name}`);
99
95
  }
100
96
  return res + node.text;
@@ -116,22 +112,15 @@ const renderTemplate = (template, templateFormat, inputValues) => {
116
112
  try {
117
113
  return DEFAULT_FORMATTER_MAPPING[templateFormat](template, inputValues);
118
114
  } catch (e) {
119
- const error = require_index.addLangChainErrorFields(e, "INVALID_PROMPT_INPUT");
120
- throw error;
115
+ throw require_errors_index.addLangChainErrorFields(e, "INVALID_PROMPT_INPUT");
121
116
  }
122
117
  };
123
118
  const parseTemplate = (template, templateFormat) => DEFAULT_PARSER_MAPPING[templateFormat](template);
124
119
  const checkValidTemplate = (template, templateFormat, inputVariables) => {
125
- if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) {
126
- const validFormats = Object.keys(DEFAULT_FORMATTER_MAPPING);
127
- throw new Error(`Invalid template format. Got \`${templateFormat}\`;
128
- should be one of ${validFormats}`);
129
- }
120
+ if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) throw new Error(`Invalid template format. Got \`${templateFormat}\`;
121
+ should be one of ${Object.keys(DEFAULT_FORMATTER_MAPPING)}`);
130
122
  try {
131
- const dummyInputs = inputVariables.reduce((acc, v) => {
132
- acc[v] = "foo";
133
- return acc;
134
- }, {});
123
+ const dummyInputs = Object.fromEntries(inputVariables.map((v) => [v, "foo"]));
135
124
  if (Array.isArray(template)) template.forEach((message) => {
136
125
  if (message.type === "text" && "text" in message && typeof message.text === "string") renderTemplate(message.text, templateFormat, dummyInputs);
137
126
  else if (message.type === "image_url") {
@@ -147,7 +136,6 @@ const checkValidTemplate = (template, templateFormat, inputVariables) => {
147
136
  throw new Error(`Invalid prompt schema: ${e.message}`);
148
137
  }
149
138
  };
150
-
151
139
  //#endregion
152
140
  exports.DEFAULT_FORMATTER_MAPPING = DEFAULT_FORMATTER_MAPPING;
153
141
  exports.DEFAULT_PARSER_MAPPING = DEFAULT_PARSER_MAPPING;
@@ -158,4 +146,5 @@ exports.parseFString = parseFString;
158
146
  exports.parseMustache = parseMustache;
159
147
  exports.parseTemplate = parseTemplate;
160
148
  exports.renderTemplate = renderTemplate;
149
+
161
150
  //# sourceMappingURL=template.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"template.cjs","names":["template: string","nodes: ParsedTemplateNode[]","bracket: \"}\" | \"{\" | \"{}\"","start: number","i","template: mustache.TemplateSpans","context: string[]","values: InputValues","DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>","DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>","templateFormat: TemplateFormat","inputValues: InputValues","addLangChainErrorFields","template: MessageContent","inputVariables: string[]","dummyInputs: InputValues","e: any"],"sources":["../../src/prompts/template.ts"],"sourcesContent":["import mustache from \"mustache\";\nimport { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\nfunction configureMustache() {\n // Use unescaped HTML\n // https://github.com/janl/mustache.js?tab=readme-ov-file#variables\n mustache.escape = (text) => text;\n}\n\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode =\n | { type: \"literal\"; text: string }\n | { type: \"variable\"; name: string };\n\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\n\nexport const parseFString = (template: string): ParsedTemplateNode[] => {\n // Core logic replicated from internals of pythons built in Formatter class.\n // https://github.com/python/cpython/blob/135ec7cefbaffd516b77362ad2b2ad1025af462e/Objects/stringlib/unicode_format.h#L700-L706\n const chars = template.split(\"\");\n const nodes: ParsedTemplateNode[] = [];\n\n const nextBracket = (bracket: \"}\" | \"{\" | \"{}\", start: number) => {\n for (let i = start; i < chars.length; i += 1) {\n if (bracket.includes(chars[i])) {\n return i;\n }\n }\n return -1;\n };\n\n let i = 0;\n while (i < chars.length) {\n if (chars[i] === \"{\" && i + 1 < chars.length && chars[i + 1] === \"{\") {\n nodes.push({ type: \"literal\", text: \"{\" });\n i += 2;\n } else if (\n chars[i] === \"}\" &&\n i + 1 < chars.length &&\n chars[i + 1] === \"}\"\n ) {\n nodes.push({ type: \"literal\", text: \"}\" });\n i += 2;\n } else if (chars[i] === \"{\") {\n const j = nextBracket(\"}\", i);\n if (j < 0) {\n throw new Error(\"Unclosed '{' in template.\");\n }\n\n nodes.push({\n type: \"variable\",\n name: chars.slice(i + 1, j).join(\"\"),\n });\n i = j + 1;\n } else if (chars[i] === \"}\") {\n throw new Error(\"Single '}' in template.\");\n } else {\n const next = nextBracket(\"{}\", i);\n const text = (next < 0 ? chars.slice(i) : chars.slice(i, next)).join(\"\");\n nodes.push({ type: \"literal\", text });\n i = next < 0 ? chars.length : next;\n }\n }\n return nodes;\n};\n\n/**\n * Convert the result of mustache.parse into an array of ParsedTemplateNode,\n * to make it compatible with other LangChain string parsing template formats.\n *\n * @param {mustache.TemplateSpans} template The result of parsing a mustache template with the mustache.js library.\n * @param {string[]} context Array of section variable names for nested context\n * @returns {ParsedTemplateNode[]}\n */\nconst mustacheTemplateToNodes = (\n template: mustache.TemplateSpans,\n context: string[] = []\n): ParsedTemplateNode[] => {\n const nodes: ParsedTemplateNode[] = [];\n\n for (const temp of template) {\n if (temp[0] === \"name\") {\n const name = temp[1].includes(\".\") ? temp[1].split(\".\")[0] : temp[1];\n nodes.push({ type: \"variable\", name });\n } else if ([\"#\", \"&\", \"^\", \">\"].includes(temp[0])) {\n // # represents a section, \"&\" represents an unescaped variable.\n // These should both be considered variables.\n nodes.push({ type: \"variable\", name: temp[1] });\n\n // If this is a section with nested content, recursively process it\n if (temp[0] === \"#\" && temp.length > 4 && Array.isArray(temp[4])) {\n const newContext = [...context, temp[1]];\n const nestedNodes = mustacheTemplateToNodes(temp[4], newContext);\n nodes.push(...nestedNodes);\n }\n } else {\n nodes.push({ type: \"literal\", text: temp[1] });\n }\n }\n\n return nodes;\n};\n\nexport const parseMustache = (template: string) => {\n configureMustache();\n const parsed = mustache.parse(template);\n return mustacheTemplateToNodes(parsed);\n};\n\nexport const interpolateFString = (template: string, values: InputValues) => {\n return parseFString(template).reduce((res, node) => {\n if (node.type === \"variable\") {\n if (node.name in values) {\n const stringValue =\n typeof values[node.name] === \"string\"\n ? values[node.name]\n : JSON.stringify(values[node.name]);\n return res + stringValue;\n }\n throw new Error(`(f-string) Missing value for input ${node.name}`);\n }\n\n return res + node.text;\n }, \"\");\n};\n\nexport const interpolateMustache = (template: string, values: InputValues) => {\n configureMustache();\n return mustache.render(template, values);\n};\n\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\n\nexport const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator> = {\n \"f-string\": interpolateFString,\n mustache: interpolateMustache,\n};\n\nexport const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser> = {\n \"f-string\": parseFString,\n mustache: parseMustache,\n};\n\nexport const renderTemplate = (\n template: string,\n templateFormat: TemplateFormat,\n inputValues: InputValues\n) => {\n try {\n return DEFAULT_FORMATTER_MAPPING[templateFormat](template, inputValues);\n } catch (e) {\n const error = addLangChainErrorFields(e, \"INVALID_PROMPT_INPUT\");\n throw error;\n }\n};\n\nexport const parseTemplate = (\n template: string,\n templateFormat: TemplateFormat\n) => DEFAULT_PARSER_MAPPING[templateFormat](template);\n\nexport const checkValidTemplate = (\n template: MessageContent,\n templateFormat: TemplateFormat,\n inputVariables: string[]\n) => {\n if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) {\n const validFormats = Object.keys(DEFAULT_FORMATTER_MAPPING);\n throw new Error(`Invalid template format. Got \\`${templateFormat}\\`;\n should be one of ${validFormats}`);\n }\n try {\n const dummyInputs: InputValues = inputVariables.reduce((acc, v) => {\n acc[v] = \"foo\";\n return acc;\n }, {} as Record<string, string>);\n if (Array.isArray(template)) {\n template.forEach((message) => {\n if (\n message.type === \"text\" &&\n \"text\" in message &&\n typeof message.text === \"string\"\n ) {\n renderTemplate(message.text, templateFormat, dummyInputs);\n } else if (message.type === \"image_url\") {\n if (typeof message.image_url === \"string\") {\n renderTemplate(message.image_url, templateFormat, dummyInputs);\n } else if (\n typeof message.image_url === \"object\" &&\n message.image_url !== null &&\n \"url\" in message.image_url &&\n typeof message.image_url.url === \"string\"\n ) {\n const imageUrl = message.image_url.url;\n renderTemplate(imageUrl, templateFormat, dummyInputs);\n }\n } else {\n throw new Error(\n `Invalid message template received. ${JSON.stringify(\n message,\n null,\n 2\n )}`\n );\n }\n });\n } else {\n renderTemplate(template, templateFormat, dummyInputs);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n throw new Error(`Invalid prompt schema: ${e.message}`);\n }\n};\n"],"mappings":";;;;;AAKA,SAAS,oBAAoB;CAG3B,iBAAS,SAAS,CAAC,SAAS;AAC7B;AAqBD,MAAa,eAAe,CAACA,aAA2C;CAGtE,MAAM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["addLangChainErrorFields"],"sources":["../../src/prompts/template.ts"],"sourcesContent":["import mustache from \"mustache\";\nimport { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\nfunction configureMustache() {\n // Use unescaped HTML\n // https://github.com/janl/mustache.js?tab=readme-ov-file#variables\n mustache.escape = (text) => text;\n}\n\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode =\n | { type: \"literal\"; text: string }\n | { type: \"variable\"; name: string };\n\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\n\nexport const parseFString = (template: string): ParsedTemplateNode[] => {\n // Core logic replicated from internals of pythons built in Formatter class.\n // https://github.com/python/cpython/blob/135ec7cefbaffd516b77362ad2b2ad1025af462e/Objects/stringlib/unicode_format.h#L700-L706\n const chars = template.split(\"\");\n const nodes: ParsedTemplateNode[] = [];\n\n const nextBracket = (bracket: \"}\" | \"{\" | \"{}\", start: number) => {\n for (let i = start; i < chars.length; i += 1) {\n if (bracket.includes(chars[i])) {\n return i;\n }\n }\n return -1;\n };\n\n let i = 0;\n while (i < chars.length) {\n if (chars[i] === \"{\" && i + 1 < chars.length && chars[i + 1] === \"{\") {\n nodes.push({ type: \"literal\", text: \"{\" });\n i += 2;\n } else if (\n chars[i] === \"}\" &&\n i + 1 < chars.length &&\n chars[i + 1] === \"}\"\n ) {\n nodes.push({ type: \"literal\", text: \"}\" });\n i += 2;\n } else if (chars[i] === \"{\") {\n const j = nextBracket(\"}\", i);\n if (j < 0) {\n throw new Error(\"Unclosed '{' in template.\");\n }\n\n nodes.push({\n type: \"variable\",\n name: chars.slice(i + 1, j).join(\"\"),\n });\n i = j + 1;\n } else if (chars[i] === \"}\") {\n throw new Error(\"Single '}' in template.\");\n } else {\n const next = nextBracket(\"{}\", i);\n const text = (next < 0 ? chars.slice(i) : chars.slice(i, next)).join(\"\");\n nodes.push({ type: \"literal\", text });\n i = next < 0 ? chars.length : next;\n }\n }\n return nodes;\n};\n\n/**\n * Convert the result of mustache.parse into an array of ParsedTemplateNode,\n * to make it compatible with other LangChain string parsing template formats.\n *\n * @param {mustache.TemplateSpans} template The result of parsing a mustache template with the mustache.js library.\n * @param {string[]} context Array of section variable names for nested context\n * @returns {ParsedTemplateNode[]}\n */\nconst mustacheTemplateToNodes = (\n template: mustache.TemplateSpans,\n context: string[] = []\n): ParsedTemplateNode[] => {\n const nodes: ParsedTemplateNode[] = [];\n\n for (const temp of template) {\n if (temp[0] === \"name\") {\n const name = temp[1].includes(\".\") ? temp[1].split(\".\")[0] : temp[1];\n nodes.push({ type: \"variable\", name });\n } else if ([\"#\", \"&\", \"^\", \">\"].includes(temp[0])) {\n // # represents a section, \"&\" represents an unescaped variable.\n // These should both be considered variables.\n nodes.push({ type: \"variable\", name: temp[1] });\n\n // If this is a section with nested content, recursively process it\n if (temp[0] === \"#\" && temp.length > 4 && Array.isArray(temp[4])) {\n const newContext = [...context, temp[1]];\n const nestedNodes = mustacheTemplateToNodes(temp[4], newContext);\n nodes.push(...nestedNodes);\n }\n } else {\n nodes.push({ type: \"literal\", text: temp[1] });\n }\n }\n\n return nodes;\n};\n\nexport const parseMustache = (template: string) => {\n configureMustache();\n const parsed = mustache.parse(template);\n return mustacheTemplateToNodes(parsed);\n};\n\nexport const interpolateFString = (template: string, values: InputValues) => {\n return parseFString(template).reduce((res, node) => {\n if (node.type === \"variable\") {\n if (node.name in values) {\n const stringValue =\n typeof values[node.name] === \"string\"\n ? values[node.name]\n : JSON.stringify(values[node.name]);\n return res + stringValue;\n }\n throw new Error(`(f-string) Missing value for input ${node.name}`);\n }\n\n return res + node.text;\n }, \"\");\n};\n\nexport const interpolateMustache = (template: string, values: InputValues) => {\n configureMustache();\n return mustache.render(template, values);\n};\n\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\n\nexport const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator> = {\n \"f-string\": interpolateFString,\n mustache: interpolateMustache,\n};\n\nexport const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser> = {\n \"f-string\": parseFString,\n mustache: parseMustache,\n};\n\nexport const renderTemplate = (\n template: string,\n templateFormat: TemplateFormat,\n inputValues: InputValues\n) => {\n try {\n return DEFAULT_FORMATTER_MAPPING[templateFormat](template, inputValues);\n } catch (e) {\n const error = addLangChainErrorFields(e, \"INVALID_PROMPT_INPUT\");\n throw error;\n }\n};\n\nexport const parseTemplate = (\n template: string,\n templateFormat: TemplateFormat\n) => DEFAULT_PARSER_MAPPING[templateFormat](template);\n\nexport const checkValidTemplate = (\n template: MessageContent,\n templateFormat: TemplateFormat,\n inputVariables: string[]\n) => {\n if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) {\n const validFormats = Object.keys(DEFAULT_FORMATTER_MAPPING);\n throw new Error(`Invalid template format. Got \\`${templateFormat}\\`;\n should be one of ${validFormats}`);\n }\n try {\n // Build dummy inputs using Object.fromEntries to avoid prototype pollution\n // from dynamic property assignment with user-provided keys\n const dummyInputs: InputValues = Object.fromEntries(\n inputVariables.map((v) => [v, \"foo\"])\n );\n if (Array.isArray(template)) {\n template.forEach((message) => {\n if (\n message.type === \"text\" &&\n \"text\" in message &&\n typeof message.text === \"string\"\n ) {\n renderTemplate(message.text, templateFormat, dummyInputs);\n } else if (message.type === \"image_url\") {\n if (typeof message.image_url === \"string\") {\n renderTemplate(message.image_url, templateFormat, dummyInputs);\n } else if (\n typeof message.image_url === \"object\" &&\n message.image_url !== null &&\n \"url\" in message.image_url &&\n typeof message.image_url.url === \"string\"\n ) {\n const imageUrl = message.image_url.url;\n renderTemplate(imageUrl, templateFormat, dummyInputs);\n }\n } else {\n throw new Error(\n `Invalid message template received. ${JSON.stringify(\n message,\n null,\n 2\n )}`\n );\n }\n });\n } else {\n renderTemplate(template, templateFormat, dummyInputs);\n }\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n throw new Error(`Invalid prompt schema: ${e.message}`);\n }\n};\n"],"mappings":";;;;;AAKA,SAAS,oBAAoB;AAG3B,UAAA,QAAA,UAAmB,SAAS;;AAsB9B,MAAa,gBAAgB,aAA2C;CAGtE,MAAM,QAAQ,SAAS,MAAM,GAAG;CAChC,MAAM,QAA8B,EAAE;CAEtC,MAAM,eAAe,SAA2B,UAAkB;AAChE,OAAK,IAAI,IAAI,OAAO,IAAI,MAAM,QAAQ,KAAK,EACzC,KAAI,QAAQ,SAAS,MAAM,GAAG,CAC5B,QAAO;AAGX,SAAO;;CAGT,IAAI,IAAI;AACR,QAAO,IAAI,MAAM,OACf,KAAI,MAAM,OAAO,OAAO,IAAI,IAAI,MAAM,UAAU,MAAM,IAAI,OAAO,KAAK;AACpE,QAAM,KAAK;GAAE,MAAM;GAAW,MAAM;GAAK,CAAC;AAC1C,OAAK;YAEL,MAAM,OAAO,OACb,IAAI,IAAI,MAAM,UACd,MAAM,IAAI,OAAO,KACjB;AACA,QAAM,KAAK;GAAE,MAAM;GAAW,MAAM;GAAK,CAAC;AAC1C,OAAK;YACI,MAAM,OAAO,KAAK;EAC3B,MAAM,IAAI,YAAY,KAAK,EAAE;AAC7B,MAAI,IAAI,EACN,OAAM,IAAI,MAAM,4BAA4B;AAG9C,QAAM,KAAK;GACT,MAAM;GACN,MAAM,MAAM,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,GAAG;GACrC,CAAC;AACF,MAAI,IAAI;YACC,MAAM,OAAO,IACtB,OAAM,IAAI,MAAM,0BAA0B;MACrC;EACL,MAAM,OAAO,YAAY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,QAAM,IAAI,MAAM,0BAA0B,EAAE,UAAU"}
@@ -1,8 +1,6 @@
1
1
  import { MessageContent } from "../messages/base.cjs";
2
2
  import { InputValues } from "../utils/types/index.cjs";
3
-
4
3
  //#region src/prompts/template.d.ts
5
-
6
4
  /**
7
5
  * Type that specifies the format of a template.
8
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.cts","names":["MessageContent","InputValues","TemplateFormat","ParsedTemplateNode","ParsedFStringNode","parseFString","parseMustache","interpolateFString","interpolateMustache","Interpolator","Parser","DEFAULT_FORMATTER_MAPPING","Record","DEFAULT_PARSER_MAPPING","renderTemplate","parseTemplate","checkValidTemplate"],"sources":["../../src/prompts/template.d.ts"],"sourcesContent":["import { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode = {\n type: \"literal\";\n text: string;\n} | {\n type: \"variable\";\n name: string;\n};\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\nexport declare const parseFString: (template: string) => ParsedTemplateNode[];\nexport declare const parseMustache: (template: string) => ParsedTemplateNode[];\nexport declare const interpolateFString: (template: string, values: InputValues) => string;\nexport declare const interpolateMustache: (template: string, values: InputValues) => string;\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\nexport declare const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>;\nexport declare const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>;\nexport declare const renderTemplate: (template: string, templateFormat: TemplateFormat, inputValues: InputValues) => string;\nexport declare const parseTemplate: (template: string, templateFormat: TemplateFormat) => ParsedTemplateNode[];\nexport declare const checkValidTemplate: (template: MessageContent, templateFormat: TemplateFormat, inputVariables: string[]) => void;\nexport {};\n//# sourceMappingURL=template.d.ts.map"],"mappings":";;;;;;;AAKA;AAKYG,KALAD,cAAAA,GAKkB,UAAA,GAAA,UAAA;AAW9B;AACA;AACA;AACA;AACqBM,KAfTL,kBAAAA,GAe+E;EAMtFM,IAAAA,EAAAA,SAAY;EAKZC,IAAAA,EAAAA,MAAM;AACX,CAAA,GAAqBC;EAAkCT,IAAAA,EAAAA,UAAAA;EAAgBO,IAAAA,EAAAA,MAAAA;CAAvBG;AAAM;AACtD;;;AAA6CA,KAjBjCR,iBAAAA,GAAoBD,kBAiBaS;AAAM,cAhB9BP,YAgB8B,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAhBMF,kBAgBN,EAAA;AAC9BW,cAhBAR,aAgBmDJ,EAAAA,CAAAA,QAAAA,EAAAA,MAA6BD,EAAAA,GAhB3CE,kBAgBsD,EAAA;AAC3FY,cAhBAR,kBAgBkDL,EAAAA,CAAAA,QAAmBC,EAAAA,MAAAA,EAAAA,MAAAA,EAhBtBF,WAgBwC,EAAA,GAAA,MAAA;AACvFe,cAhBAR,mBAgB+BR,EAAAA,CAAAA,QAAAA,EAAAA,MAAgCE,EAAAA,MAAAA,EAhBfD,WAgB6B,EAAA,GAAA,MAAA;;;;;;KAV7FQ,YAAAA,8BAA0CR;;;;;KAK1CS,MAAAA,yBAA+BP;cACfQ,2BAA2BC,OAAOV,gBAAgBO;cAClDI,wBAAwBD,OAAOV,gBAAgBQ;cAC/CI,mDAAmDZ,6BAA6BD;cAChFc,kDAAkDb,mBAAmBC;cACrEa,+BAA+BhB,gCAAgCE"}
1
+ {"version":3,"file":"template.d.cts","names":[],"sources":["../../src/prompts/template.ts"],"mappings":";;;;;;KAcY,cAAA;;;;;KAMA,kBAAA;EACN,IAAA;EAAiB,IAAA;AAAA;EACjB,IAAA;EAAkB,IAAA;AAAA;;;;AAMxB;KAAY,iBAAA,GAAoB,kBAAA;AAAA,cAEnB,YAAA,GAAY,QAAA,aAAuB,kBAAA;AAAA,cAuFnC,aAAA,GAAa,QAAA,aAAoB,kBAAA;AAAA,cAMjC,kBAAA,GAAkB,QAAA,UAAoB,MAAA,EAAU,WAAA;AAAA,cAiBhD,mBAAA,GAAmB,QAAA,UAAoB,MAAA,EAAU,WAAA;;;;;AAvB9D;KAiCK,YAAA,IAAgB,QAAA,UAAkB,MAAA,EAAQ,WAAA;;;;AA3B/C;KAiCK,MAAA,IAAU,QAAA,aAAqB,kBAAA;AAAA,cAEvB,yBAAA,EAA2B,MAAA,CAAO,cAAA,EAAgB,YAAA;AAAA,cAKlD,sBAAA,EAAwB,MAAA,CAAO,cAAA,EAAgB,MAAA;AAAA,cAK/C,cAAA,GAAc,QAAA,UACT,cAAA,EACA,cAAA,EAAc,WAAA,EACjB,WAAA;AAAA,cAUF,aAAA,GAAa,QAAA,UACR,cAAA,EACA,cAAA,KAAc,kBAAA;AAAA,cAGnB,kBAAA,GAAkB,QAAA,EACnB,cAAA,EAAc,cAAA,EACR,cAAA,EAAc,cAAA"}
@@ -1,7 +1,5 @@
1
1
  import { MessageContent } from "../messages/base.js";
2
2
  import { InputValues } from "../utils/types/index.js";
3
- import "../messages/index.js";
4
-
5
3
  //#region src/prompts/template.d.ts
6
4
  /**
7
5
  * Type that specifies the format of a template.
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","names":["MessageContent","InputValues","TemplateFormat","ParsedTemplateNode","ParsedFStringNode","parseFString","parseMustache","interpolateFString","interpolateMustache","Interpolator","Parser","DEFAULT_FORMATTER_MAPPING","Record","DEFAULT_PARSER_MAPPING","renderTemplate","parseTemplate","checkValidTemplate"],"sources":["../../src/prompts/template.d.ts"],"sourcesContent":["import { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode = {\n type: \"literal\";\n text: string;\n} | {\n type: \"variable\";\n name: string;\n};\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\nexport declare const parseFString: (template: string) => ParsedTemplateNode[];\nexport declare const parseMustache: (template: string) => ParsedTemplateNode[];\nexport declare const interpolateFString: (template: string, values: InputValues) => string;\nexport declare const interpolateMustache: (template: string, values: InputValues) => string;\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\nexport declare const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>;\nexport declare const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>;\nexport declare const renderTemplate: (template: string, templateFormat: TemplateFormat, inputValues: InputValues) => string;\nexport declare const parseTemplate: (template: string, templateFormat: TemplateFormat) => ParsedTemplateNode[];\nexport declare const checkValidTemplate: (template: MessageContent, templateFormat: TemplateFormat, inputVariables: string[]) => void;\nexport {};\n//# sourceMappingURL=template.d.ts.map"],"mappings":";;;;;;;;AAKYE,KAAAA,cAAAA,GAAc,UAAA,GAAA,UAAA;AAK1B;AAWA;AACA;AACA;AACqBK,KAdTJ,kBAAAA,GAc8E;EACrEK,IAAAA,EAAAA,SAAAA;EAMhBC,IAAAA,EAAAA,MAAAA;AAAqD,CAAA,GAKrDC;EACgBC,IAAAA,EAAAA,UAAAA;EAAkCT,IAAAA,EAAAA,MAAAA;CAAgBO;;AAAjB;AACtD;;AAAoEC,KAjBxDN,iBAAAA,GAAoBD,kBAiBoCO;AAA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AO,cAAA,EAAgB,MAAA;AAAA,cAK/C,cAAA,GAAc,QAAA,UACT,cAAA,EACA,cAAA,EAAc,WAAA,EACjB,WAAA;AAAA,cAUF,aAAA,GAAa,QAAA,UACR,cAAA,EACA,cAAA,KAAc,kBAAA;AAAA,cAGnB,kBAAA,GAAkB,QAAA,EACnB,cAAA,EAAc,cAAA,EACR,cAAA,EAAc,cAAA"}
@@ -1,6 +1,5 @@
1
1
  import { addLangChainErrorFields } from "../errors/index.js";
2
2
  import mustache from "mustache";
3
-
4
3
  //#region src/prompts/template.ts
5
4
  function configureMustache() {
6
5
  mustache.escape = (text) => text;
@@ -9,7 +8,7 @@ const parseFString = (template) => {
9
8
  const chars = template.split("");
10
9
  const nodes = [];
11
10
  const nextBracket = (bracket, start) => {
12
- for (let i$1 = start; i$1 < chars.length; i$1 += 1) if (bracket.includes(chars[i$1])) return i$1;
11
+ for (let i = start; i < chars.length; i += 1) if (bracket.includes(chars[i])) return i;
13
12
  return -1;
14
13
  };
15
14
  let i = 0;
@@ -84,16 +83,12 @@ const mustacheTemplateToNodes = (template, context = []) => {
84
83
  };
85
84
  const parseMustache = (template) => {
86
85
  configureMustache();
87
- const parsed = mustache.parse(template);
88
- return mustacheTemplateToNodes(parsed);
86
+ return mustacheTemplateToNodes(mustache.parse(template));
89
87
  };
90
88
  const interpolateFString = (template, values) => {
91
89
  return parseFString(template).reduce((res, node) => {
92
90
  if (node.type === "variable") {
93
- if (node.name in values) {
94
- const stringValue = typeof values[node.name] === "string" ? values[node.name] : JSON.stringify(values[node.name]);
95
- return res + stringValue;
96
- }
91
+ if (node.name in values) return res + (typeof values[node.name] === "string" ? values[node.name] : JSON.stringify(values[node.name]));
97
92
  throw new Error(`(f-string) Missing value for input ${node.name}`);
98
93
  }
99
94
  return res + node.text;
@@ -115,22 +110,15 @@ const renderTemplate = (template, templateFormat, inputValues) => {
115
110
  try {
116
111
  return DEFAULT_FORMATTER_MAPPING[templateFormat](template, inputValues);
117
112
  } catch (e) {
118
- const error = addLangChainErrorFields(e, "INVALID_PROMPT_INPUT");
119
- throw error;
113
+ throw addLangChainErrorFields(e, "INVALID_PROMPT_INPUT");
120
114
  }
121
115
  };
122
116
  const parseTemplate = (template, templateFormat) => DEFAULT_PARSER_MAPPING[templateFormat](template);
123
117
  const checkValidTemplate = (template, templateFormat, inputVariables) => {
124
- if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) {
125
- const validFormats = Object.keys(DEFAULT_FORMATTER_MAPPING);
126
- throw new Error(`Invalid template format. Got \`${templateFormat}\`;
127
- should be one of ${validFormats}`);
128
- }
118
+ if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) throw new Error(`Invalid template format. Got \`${templateFormat}\`;
119
+ should be one of ${Object.keys(DEFAULT_FORMATTER_MAPPING)}`);
129
120
  try {
130
- const dummyInputs = inputVariables.reduce((acc, v) => {
131
- acc[v] = "foo";
132
- return acc;
133
- }, {});
121
+ const dummyInputs = Object.fromEntries(inputVariables.map((v) => [v, "foo"]));
134
122
  if (Array.isArray(template)) template.forEach((message) => {
135
123
  if (message.type === "text" && "text" in message && typeof message.text === "string") renderTemplate(message.text, templateFormat, dummyInputs);
136
124
  else if (message.type === "image_url") {
@@ -146,7 +134,7 @@ const checkValidTemplate = (template, templateFormat, inputVariables) => {
146
134
  throw new Error(`Invalid prompt schema: ${e.message}`);
147
135
  }
148
136
  };
149
-
150
137
  //#endregion
151
138
  export { DEFAULT_FORMATTER_MAPPING, DEFAULT_PARSER_MAPPING, checkValidTemplate, interpolateFString, interpolateMustache, parseFString, parseMustache, parseTemplate, renderTemplate };
139
+
152
140
  //# sourceMappingURL=template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"template.js","names":["template: string","nodes: ParsedTemplateNode[]","bracket: \"}\" | \"{\" | \"{}\"","start: number","i","template: mustache.TemplateSpans","context: string[]","values: InputValues","DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>","DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>","templateFormat: TemplateFormat","inputValues: InputValues","template: MessageContent","inputVariables: string[]","dummyInputs: InputValues","e: any"],"sources":["../../src/prompts/template.ts"],"sourcesContent":["import mustache from \"mustache\";\nimport { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\nfunction configureMustache() {\n // Use unescaped HTML\n // https://github.com/janl/mustache.js?tab=readme-ov-file#variables\n mustache.escape = (text) => text;\n}\n\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode =\n | { type: \"literal\"; text: string }\n | { type: \"variable\"; name: string };\n\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\n\nexport const parseFString = (template: string): ParsedTemplateNode[] => {\n // Core logic replicated from internals of pythons built in Formatter class.\n // https://github.com/python/cpython/blob/135ec7cefbaffd516b77362ad2b2ad1025af462e/Objects/stringlib/unicode_format.h#L700-L706\n const chars = template.split(\"\");\n const nodes: ParsedTemplateNode[] = [];\n\n const nextBracket = (bracket: \"}\" | \"{\" | \"{}\", start: number) => {\n for (let i = start; i < chars.length; i += 1) {\n if (bracket.includes(chars[i])) {\n return i;\n }\n }\n return -1;\n };\n\n let i = 0;\n while (i < chars.length) {\n if (chars[i] === \"{\" && i + 1 < chars.length && chars[i + 1] === \"{\") {\n nodes.push({ type: \"literal\", text: \"{\" });\n i += 2;\n } else if (\n chars[i] === \"}\" &&\n i + 1 < chars.length &&\n chars[i + 1] === \"}\"\n ) {\n nodes.push({ type: \"literal\", text: \"}\" });\n i += 2;\n } else if (chars[i] === \"{\") {\n const j = nextBracket(\"}\", i);\n if (j < 0) {\n throw new Error(\"Unclosed '{' in template.\");\n }\n\n nodes.push({\n type: \"variable\",\n name: chars.slice(i + 1, j).join(\"\"),\n });\n i = j + 1;\n } else if (chars[i] === \"}\") {\n throw new Error(\"Single '}' in template.\");\n } else {\n const next = nextBracket(\"{}\", i);\n const text = (next < 0 ? chars.slice(i) : chars.slice(i, next)).join(\"\");\n nodes.push({ type: \"literal\", text });\n i = next < 0 ? chars.length : next;\n }\n }\n return nodes;\n};\n\n/**\n * Convert the result of mustache.parse into an array of ParsedTemplateNode,\n * to make it compatible with other LangChain string parsing template formats.\n *\n * @param {mustache.TemplateSpans} template The result of parsing a mustache template with the mustache.js library.\n * @param {string[]} context Array of section variable names for nested context\n * @returns {ParsedTemplateNode[]}\n */\nconst mustacheTemplateToNodes = (\n template: mustache.TemplateSpans,\n context: string[] = []\n): ParsedTemplateNode[] => {\n const nodes: ParsedTemplateNode[] = [];\n\n for (const temp of template) {\n if (temp[0] === \"name\") {\n const name = temp[1].includes(\".\") ? temp[1].split(\".\")[0] : temp[1];\n nodes.push({ type: \"variable\", name });\n } else if ([\"#\", \"&\", \"^\", \">\"].includes(temp[0])) {\n // # represents a section, \"&\" represents an unescaped variable.\n // These should both be considered variables.\n nodes.push({ type: \"variable\", name: temp[1] });\n\n // If this is a section with nested content, recursively process it\n if (temp[0] === \"#\" && temp.length > 4 && Array.isArray(temp[4])) {\n const newContext = [...context, temp[1]];\n const nestedNodes = mustacheTemplateToNodes(temp[4], newContext);\n nodes.push(...nestedNodes);\n }\n } else {\n nodes.push({ type: \"literal\", text: temp[1] });\n }\n }\n\n return nodes;\n};\n\nexport const parseMustache = (template: string) => {\n configureMustache();\n const parsed = mustache.parse(template);\n return mustacheTemplateToNodes(parsed);\n};\n\nexport const interpolateFString = (template: string, values: InputValues) => {\n return parseFString(template).reduce((res, node) => {\n if (node.type === \"variable\") {\n if (node.name in values) {\n const stringValue =\n typeof values[node.name] === \"string\"\n ? values[node.name]\n : JSON.stringify(values[node.name]);\n return res + stringValue;\n }\n throw new Error(`(f-string) Missing value for input ${node.name}`);\n }\n\n return res + node.text;\n }, \"\");\n};\n\nexport const interpolateMustache = (template: string, values: InputValues) => {\n configureMustache();\n return mustache.render(template, values);\n};\n\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\n\nexport const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator> = {\n \"f-string\": interpolateFString,\n mustache: interpolateMustache,\n};\n\nexport const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser> = {\n \"f-string\": parseFString,\n mustache: parseMustache,\n};\n\nexport const renderTemplate = (\n template: string,\n templateFormat: TemplateFormat,\n inputValues: InputValues\n) => {\n try {\n return DEFAULT_FORMATTER_MAPPING[templateFormat](template, inputValues);\n } catch (e) {\n const error = addLangChainErrorFields(e, \"INVALID_PROMPT_INPUT\");\n throw error;\n }\n};\n\nexport const parseTemplate = (\n template: string,\n templateFormat: TemplateFormat\n) => DEFAULT_PARSER_MAPPING[templateFormat](template);\n\nexport const checkValidTemplate = (\n template: MessageContent,\n templateFormat: TemplateFormat,\n inputVariables: string[]\n) => {\n if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) {\n const validFormats = Object.keys(DEFAULT_FORMATTER_MAPPING);\n throw new Error(`Invalid template format. Got \\`${templateFormat}\\`;\n should be one of ${validFormats}`);\n }\n try {\n const dummyInputs: InputValues = inputVariables.reduce((acc, v) => {\n acc[v] = \"foo\";\n return acc;\n }, {} as Record<string, string>);\n if (Array.isArray(template)) {\n template.forEach((message) => {\n if (\n message.type === \"text\" &&\n \"text\" in message &&\n typeof message.text === \"string\"\n ) {\n renderTemplate(message.text, templateFormat, dummyInputs);\n } else if (message.type === \"image_url\") {\n if (typeof message.image_url === \"string\") {\n renderTemplate(message.image_url, templateFormat, dummyInputs);\n } else if (\n typeof message.image_url === \"object\" &&\n message.image_url !== null &&\n \"url\" in message.image_url &&\n typeof message.image_url.url === \"string\"\n ) {\n const imageUrl = message.image_url.url;\n renderTemplate(imageUrl, templateFormat, dummyInputs);\n }\n } else {\n throw new Error(\n `Invalid message template received. ${JSON.stringify(\n message,\n null,\n 2\n )}`\n );\n }\n });\n } else {\n renderTemplate(template, templateFormat, dummyInputs);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n throw new Error(`Invalid prompt schema: ${e.message}`);\n }\n};\n"],"mappings":";;;;AAKA,SAAS,oBAAoB;CAG3B,SAAS,SAAS,CAAC,SAAS;AAC7B;AAqBD,MAAa,eAAe,CAACA,aAA2C;CAGtE,MAAM,QAAQ,SAAS,MAAM,GAAG;CAChC,MAAMC,QAA8B,CAAE;CAEtC,MAAM,cAAc,CAACC,SAA2BC,UAAkB;AAChE,OAAK,IAAIC,MAAI,OAAOA,MAAI,MAAM,QAAQA,OAAK,EACzC,KAAI,QAAQ,SAAS,MAAMA,KAAG,CAC5B,QAAOA;AAGX,SAAO;CACR;CAED,IAAI,IAAI;AACR,QAAO,IAAI,MAAM,OACf,KAAI,MAAM,OAAO,OAAO,IAAI,IAAI,MAAM,UAAU,MAAM,IAAI,OAAO,KAAK;EACpE,MAAM,KAAK;GAAE,MAAM;GAAW,MAAM;EAAK,EAAC;EAC1C,KAAK;CACN,WACC,MAAM,OAAO,OACb,IAAI,IAAI,MAAM,UACd,MAAM,IAAI,OAAO,KACjB;EACA,MAAM,KAAK;GAAE,MAAM;GAAW,MAAM;EAAK,EAAC;EAC1C,KAAK;CACN,WAAU,MAAM,OAAO,KAAK;EAC3B,MAAM,IAAI,YAAY,KAAK,EAAE;AAC7B,MAAI,IAAI,EACN,OAAM,IAAI,MAAM;EAGlB,MAAM,KAAK;GACT,MAAM;GACN,MAAM,MAAM,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,GAAG;EACrC,EAAC;EACF,IAAI,IAAI;CACT,WAAU,MAAM,OAAO,IACtB,OAAM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gBAAgB,YAAY;aAE9D,OAAO,QAAQ,cAAc,YAC7B,QAAQ,cAAc,QACtB,SAAS,QAAQ,aACjB,OAAO,QAAQ,UAAU,QAAQ,UACjC;KACA,MAAM,WAAW,QAAQ,UAAU;KACnC,eAAe,UAAU,gBAAgB,YAAY;IACtD;SAED,OAAM,IAAI,MACR,CAAC,mCAAmC,EAAE,KAAK,UACzC,SACA,MACA,EACD,EAAE;EAGR,EAAC;OAEF,eAAe,UAAU,gBAAgB,YAAY;CAGxD,SAAQC,GAAQ;AACf,QAAM,IAAI,MAAM,CAAC,uBAAuB,EAAE,EAAE,SAAS;CACtD;AACF"}
1
+ {"version":3,"file":"template.js","names":[],"sources":["../../src/prompts/template.ts"],"sourcesContent":["import mustache from \"mustache\";\nimport { MessageContent } from \"../messages/index.js\";\nimport type { InputValues } from \"../utils/types/index.js\";\nimport { addLangChainErrorFields } from \"../errors/index.js\";\n\nfunction configureMustache() {\n // Use unescaped HTML\n // https://github.com/janl/mustache.js?tab=readme-ov-file#variables\n mustache.escape = (text) => text;\n}\n\n/**\n * Type that specifies the format of a template.\n */\nexport type TemplateFormat = \"f-string\" | \"mustache\";\n\n/**\n * Type that represents a node in a parsed format string. It can be either\n * a literal text or a variable name.\n */\nexport type ParsedTemplateNode =\n | { type: \"literal\"; text: string }\n | { type: \"variable\"; name: string };\n\n/**\n * Alias for `ParsedTemplateNode` since it is the same for\n * both f-string and mustache templates.\n */\nexport type ParsedFStringNode = ParsedTemplateNode;\n\nexport const parseFString = (template: string): ParsedTemplateNode[] => {\n // Core logic replicated from internals of pythons built in Formatter class.\n // https://github.com/python/cpython/blob/135ec7cefbaffd516b77362ad2b2ad1025af462e/Objects/stringlib/unicode_format.h#L700-L706\n const chars = template.split(\"\");\n const nodes: ParsedTemplateNode[] = [];\n\n const nextBracket = (bracket: \"}\" | \"{\" | \"{}\", start: number) => {\n for (let i = start; i < chars.length; i += 1) {\n if (bracket.includes(chars[i])) {\n return i;\n }\n }\n return -1;\n };\n\n let i = 0;\n while (i < chars.length) {\n if (chars[i] === \"{\" && i + 1 < chars.length && chars[i + 1] === \"{\") {\n nodes.push({ type: \"literal\", text: \"{\" });\n i += 2;\n } else if (\n chars[i] === \"}\" &&\n i + 1 < chars.length &&\n chars[i + 1] === \"}\"\n ) {\n nodes.push({ type: \"literal\", text: \"}\" });\n i += 2;\n } else if (chars[i] === \"{\") {\n const j = nextBracket(\"}\", i);\n if (j < 0) {\n throw new Error(\"Unclosed '{' in template.\");\n }\n\n nodes.push({\n type: \"variable\",\n name: chars.slice(i + 1, j).join(\"\"),\n });\n i = j + 1;\n } else if (chars[i] === \"}\") {\n throw new Error(\"Single '}' in template.\");\n } else {\n const next = nextBracket(\"{}\", i);\n const text = (next < 0 ? chars.slice(i) : chars.slice(i, next)).join(\"\");\n nodes.push({ type: \"literal\", text });\n i = next < 0 ? chars.length : next;\n }\n }\n return nodes;\n};\n\n/**\n * Convert the result of mustache.parse into an array of ParsedTemplateNode,\n * to make it compatible with other LangChain string parsing template formats.\n *\n * @param {mustache.TemplateSpans} template The result of parsing a mustache template with the mustache.js library.\n * @param {string[]} context Array of section variable names for nested context\n * @returns {ParsedTemplateNode[]}\n */\nconst mustacheTemplateToNodes = (\n template: mustache.TemplateSpans,\n context: string[] = []\n): ParsedTemplateNode[] => {\n const nodes: ParsedTemplateNode[] = [];\n\n for (const temp of template) {\n if (temp[0] === \"name\") {\n const name = temp[1].includes(\".\") ? temp[1].split(\".\")[0] : temp[1];\n nodes.push({ type: \"variable\", name });\n } else if ([\"#\", \"&\", \"^\", \">\"].includes(temp[0])) {\n // # represents a section, \"&\" represents an unescaped variable.\n // These should both be considered variables.\n nodes.push({ type: \"variable\", name: temp[1] });\n\n // If this is a section with nested content, recursively process it\n if (temp[0] === \"#\" && temp.length > 4 && Array.isArray(temp[4])) {\n const newContext = [...context, temp[1]];\n const nestedNodes = mustacheTemplateToNodes(temp[4], newContext);\n nodes.push(...nestedNodes);\n }\n } else {\n nodes.push({ type: \"literal\", text: temp[1] });\n }\n }\n\n return nodes;\n};\n\nexport const parseMustache = (template: string) => {\n configureMustache();\n const parsed = mustache.parse(template);\n return mustacheTemplateToNodes(parsed);\n};\n\nexport const interpolateFString = (template: string, values: InputValues) => {\n return parseFString(template).reduce((res, node) => {\n if (node.type === \"variable\") {\n if (node.name in values) {\n const stringValue =\n typeof values[node.name] === \"string\"\n ? values[node.name]\n : JSON.stringify(values[node.name]);\n return res + stringValue;\n }\n throw new Error(`(f-string) Missing value for input ${node.name}`);\n }\n\n return res + node.text;\n }, \"\");\n};\n\nexport const interpolateMustache = (template: string, values: InputValues) => {\n configureMustache();\n return mustache.render(template, values);\n};\n\n/**\n * Type that represents a function that takes a template string and a set\n * of input values, and returns a string where all variables in the\n * template have been replaced with their corresponding values.\n */\ntype Interpolator = (template: string, values: InputValues) => string;\n\n/**\n * Type that represents a function that takes a template string and\n * returns an array of `ParsedTemplateNode`.\n */\ntype Parser = (template: string) => ParsedTemplateNode[];\n\nexport const DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator> = {\n \"f-string\": interpolateFString,\n mustache: interpolateMustache,\n};\n\nexport const DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser> = {\n \"f-string\": parseFString,\n mustache: parseMustache,\n};\n\nexport const renderTemplate = (\n template: string,\n templateFormat: TemplateFormat,\n inputValues: InputValues\n) => {\n try {\n return DEFAULT_FORMATTER_MAPPING[templateFormat](template, inputValues);\n } catch (e) {\n const error = addLangChainErrorFields(e, \"INVALID_PROMPT_INPUT\");\n throw error;\n }\n};\n\nexport const parseTemplate = (\n template: string,\n templateFormat: TemplateFormat\n) => DEFAULT_PARSER_MAPPING[templateFormat](template);\n\nexport const checkValidTemplate = (\n template: MessageContent,\n templateFormat: TemplateFormat,\n inputVariables: string[]\n) => {\n if (!(templateFormat in DEFAULT_FORMATTER_MAPPING)) {\n const validFormats = Object.keys(DEFAULT_FORMATTER_MAPPING);\n throw new Error(`Invalid template format. Got \\`${templateFormat}\\`;\n should be one of ${validFormats}`);\n }\n try {\n // Build dummy inputs using Object.fromEntries to avoid prototype pollution\n // from dynamic property assignment with user-provided keys\n const dummyInputs: InputValues = Object.fromEntries(\n inputVariables.map((v) => [v, \"foo\"])\n );\n if (Array.isArray(template)) {\n template.forEach((message) => {\n if (\n message.type === \"text\" &&\n \"text\" in message &&\n typeof message.text === \"string\"\n ) {\n renderTemplate(message.text, templateFormat, dummyInputs);\n } else if (message.type === \"image_url\") {\n if (typeof message.image_url === \"string\") {\n renderTemplate(message.image_url, templateFormat, dummyInputs);\n } else if (\n typeof message.image_url === \"object\" &&\n message.image_url !== null &&\n \"url\" in message.image_url &&\n typeof message.image_url.url === \"string\"\n ) {\n const imageUrl = message.image_url.url;\n renderTemplate(imageUrl, templateFormat, dummyInputs);\n }\n } else {\n throw new Error(\n `Invalid message template received. ${JSON.stringify(\n message,\n null,\n 2\n )}`\n );\n }\n });\n } else {\n renderTemplate(template, templateFormat, dummyInputs);\n }\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n throw new Error(`Invalid prompt schema: ${e.message}`);\n }\n};\n"],"mappings":";;;AAKA,SAAS,oBAAoB;AAG3B,UAAS,UAAU,SAAS;;AAsB9B,MAAa,gBAAgB,aAA2C;CAGtE,MAAM,QAAQ,SAAS,MAAM,GAAG;CAChC,MAAM,QAA8B,EAAE;CAEtC,MAAM,eAAe,SAA2B,UAAkB;AAChE,OAAK,IAAI,IAAI,OAAO,IAAI,MAAM,QAAQ,KAAK,EACzC,KAAI,QAAQ,SAAS,MAAM,GAAG,CAC5B,QAAO;AAGX,SAAO;;CAGT,IAAI,IAAI;AACR,QAAO,IAAI,MAAM,OACf,KAAI,MAAM,OAAO,OAAO,IAAI,IAAI,MAAM,UAAU,MAAM,IAAI,OAAO,KAAK;AACpE,QAAM,KAAK;GAAE,MAAM;GAAW,MAAM;GAAK,CAAC;AAC1C,OAAK;YAEL,MAAM,OAAO,OACb,IAAI,IAAI,MAAM,UAC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AChD,QAAQ,SAAS;QACtB,OAAO,QAAQ,cAAc,SAC/B,gBAAe,QAAQ,WAAW,gBAAgB,YAAY;aAE9D,OAAO,QAAQ,cAAc,YAC7B,QAAQ,cAAc,QACtB,SAAS,QAAQ,aACjB,OAAO,QAAQ,UAAU,QAAQ,UACjC;KACA,MAAM,WAAW,QAAQ,UAAU;AACnC,oBAAe,UAAU,gBAAgB,YAAY;;SAGvD,OAAM,IAAI,MACR,sCAAsC,KAAK,UACzC,SACA,MACA,EACD,GACF;IAEH;MAEF,gBAAe,UAAU,gBAAgB,YAAY;UAGhD,GAAQ;AACf,QAAM,IAAI,MAAM,0BAA0B,EAAE,UAAU"}
@@ -1,8 +1,6 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  //#region src/retrievers/document_compressors/index.ts
4
- var document_compressors_exports = {};
5
- require_rolldown_runtime.__export(document_compressors_exports, { BaseDocumentCompressor: () => BaseDocumentCompressor });
3
+ var document_compressors_exports = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__exportAll({ BaseDocumentCompressor: () => BaseDocumentCompressor });
6
4
  /**
7
5
  * Base Document Compression class. All compressors should extend this class.
8
6
  */
@@ -11,13 +9,13 @@ var BaseDocumentCompressor = class {
11
9
  return x?.compressDocuments !== void 0;
12
10
  }
13
11
  };
14
-
15
12
  //#endregion
16
13
  exports.BaseDocumentCompressor = BaseDocumentCompressor;
17
- Object.defineProperty(exports, 'document_compressors_exports', {
18
- enumerable: true,
19
- get: function () {
20
- return document_compressors_exports;
21
- }
14
+ Object.defineProperty(exports, "document_compressors_exports", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return document_compressors_exports;
18
+ }
22
19
  });
20
+
23
21
  //# sourceMappingURL=index.cjs.map