langchain 1.0.0-alpha.4 → 1.0.0-alpha.6

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 (384) hide show
  1. package/dist/agents/ReactAgent.cjs +5 -5
  2. package/dist/agents/ReactAgent.cjs.map +1 -1
  3. package/dist/agents/ReactAgent.d.cts +1 -3
  4. package/dist/agents/ReactAgent.d.cts.map +1 -1
  5. package/dist/agents/ReactAgent.d.ts +1 -3
  6. package/dist/agents/ReactAgent.d.ts.map +1 -1
  7. package/dist/agents/ReactAgent.js +6 -6
  8. package/dist/agents/ReactAgent.js.map +1 -1
  9. package/dist/agents/RunnableCallable.cjs +5 -0
  10. package/dist/agents/RunnableCallable.cjs.map +1 -1
  11. package/dist/agents/RunnableCallable.d.cts +2 -0
  12. package/dist/agents/RunnableCallable.d.cts.map +1 -1
  13. package/dist/agents/RunnableCallable.d.ts +2 -0
  14. package/dist/agents/RunnableCallable.d.ts.map +1 -1
  15. package/dist/agents/RunnableCallable.js +5 -0
  16. package/dist/agents/RunnableCallable.js.map +1 -1
  17. package/dist/agents/annotation.cjs.map +1 -1
  18. package/dist/agents/annotation.d.cts +5 -7
  19. package/dist/agents/annotation.d.cts.map +1 -1
  20. package/dist/agents/annotation.d.ts +4 -6
  21. package/dist/agents/annotation.d.ts.map +1 -1
  22. package/dist/agents/annotation.js.map +1 -1
  23. package/dist/agents/createAgent.cjs +10 -0
  24. package/dist/agents/createAgent.cjs.map +1 -0
  25. package/dist/agents/createAgent.js +10 -0
  26. package/dist/agents/createAgent.js.map +1 -0
  27. package/dist/agents/index.cjs +23 -4
  28. package/dist/agents/index.cjs.map +1 -1
  29. package/dist/agents/index.d.cts +84 -21
  30. package/dist/agents/index.d.cts.map +1 -1
  31. package/dist/agents/index.d.ts +84 -21
  32. package/dist/agents/index.d.ts.map +1 -1
  33. package/dist/agents/index.js +23 -4
  34. package/dist/agents/index.js.map +1 -1
  35. package/dist/agents/middlewareAgent/ReactAgent.cjs +255 -0
  36. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -0
  37. package/dist/agents/middlewareAgent/ReactAgent.d.cts +67 -0
  38. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -0
  39. package/dist/agents/middlewareAgent/ReactAgent.d.ts +67 -0
  40. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -0
  41. package/dist/agents/middlewareAgent/ReactAgent.js +254 -0
  42. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -0
  43. package/dist/agents/middlewareAgent/annotation.cjs +39 -0
  44. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -0
  45. package/dist/agents/middlewareAgent/annotation.js +38 -0
  46. package/dist/agents/middlewareAgent/annotation.js.map +1 -0
  47. package/dist/agents/middlewareAgent/index.cjs +11 -0
  48. package/dist/agents/middlewareAgent/index.cjs.map +1 -0
  49. package/dist/agents/middlewareAgent/index.js +11 -0
  50. package/dist/agents/middlewareAgent/index.js.map +1 -0
  51. package/dist/agents/middlewareAgent/middleware/hitl.cjs +235 -0
  52. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
  53. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +199 -0
  54. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
  55. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +199 -0
  56. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
  57. package/dist/agents/middlewareAgent/middleware/hitl.js +234 -0
  58. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
  59. package/dist/agents/middlewareAgent/middleware/index.cjs +26 -0
  60. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
  61. package/dist/agents/middlewareAgent/middleware/index.d.cts +4 -0
  62. package/dist/agents/middlewareAgent/middleware/index.d.ts +4 -0
  63. package/dist/agents/middlewareAgent/middleware/index.js +17 -0
  64. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
  65. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs +182 -0
  66. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
  67. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts +152 -0
  68. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
  69. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts +152 -0
  70. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
  71. package/dist/agents/middlewareAgent/middleware/promptCaching.js +181 -0
  72. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
  73. package/dist/agents/middlewareAgent/middleware/summarization.cjs +262 -0
  74. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
  75. package/dist/agents/middlewareAgent/middleware/summarization.d.cts +89 -0
  76. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
  77. package/dist/agents/middlewareAgent/middleware/summarization.d.ts +89 -0
  78. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -0
  79. package/dist/agents/middlewareAgent/middleware/summarization.js +260 -0
  80. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
  81. package/dist/agents/middlewareAgent/middleware.cjs +47 -0
  82. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -0
  83. package/dist/agents/middlewareAgent/middleware.d.cts +46 -0
  84. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -0
  85. package/dist/agents/middlewareAgent/middleware.d.ts +46 -0
  86. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -0
  87. package/dist/agents/middlewareAgent/middleware.js +46 -0
  88. package/dist/agents/middlewareAgent/middleware.js.map +1 -0
  89. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +29 -0
  90. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -0
  91. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +29 -0
  92. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -0
  93. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +325 -0
  94. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -0
  95. package/dist/agents/middlewareAgent/nodes/AgentNode.js +324 -0
  96. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -0
  97. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +27 -0
  98. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -0
  99. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +27 -0
  100. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -0
  101. package/dist/agents/middlewareAgent/nodes/middleware.cjs +73 -0
  102. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -0
  103. package/dist/agents/middlewareAgent/nodes/middleware.js +73 -0
  104. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -0
  105. package/dist/agents/middlewareAgent/nodes/utils.cjs +74 -0
  106. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -0
  107. package/dist/agents/middlewareAgent/nodes/utils.js +70 -0
  108. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -0
  109. package/dist/agents/middlewareAgent/types.d.cts +380 -0
  110. package/dist/agents/middlewareAgent/types.d.cts.map +1 -0
  111. package/dist/agents/middlewareAgent/types.d.ts +380 -0
  112. package/dist/agents/middlewareAgent/types.d.ts.map +1 -0
  113. package/dist/agents/nodes/AgentNode.cjs +4 -4
  114. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  115. package/dist/agents/nodes/AgentNode.js +4 -4
  116. package/dist/agents/nodes/AgentNode.js.map +1 -1
  117. package/dist/agents/nodes/ToolNode.cjs +3 -3
  118. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  119. package/dist/agents/nodes/ToolNode.d.cts +4 -5
  120. package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
  121. package/dist/agents/nodes/ToolNode.d.ts +1 -2
  122. package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
  123. package/dist/agents/nodes/ToolNode.js +4 -4
  124. package/dist/agents/nodes/ToolNode.js.map +1 -1
  125. package/dist/agents/responses.cjs +1 -1
  126. package/dist/agents/responses.cjs.map +1 -1
  127. package/dist/agents/responses.d.cts.map +1 -1
  128. package/dist/agents/responses.d.ts.map +1 -1
  129. package/dist/agents/responses.js +1 -1
  130. package/dist/agents/responses.js.map +1 -1
  131. package/dist/agents/types.d.cts +5 -7
  132. package/dist/agents/types.d.cts.map +1 -1
  133. package/dist/agents/types.d.ts +1 -3
  134. package/dist/agents/types.d.ts.map +1 -1
  135. package/dist/agents/utils.cjs +6 -6
  136. package/dist/agents/utils.cjs.map +1 -1
  137. package/dist/agents/utils.js +7 -7
  138. package/dist/agents/utils.js.map +1 -1
  139. package/dist/agents/withAgentName.cjs.map +1 -1
  140. package/dist/agents/withAgentName.js.map +1 -1
  141. package/dist/chains/api/api_chain.d.cts +1 -1
  142. package/dist/chains/api/prompts.cjs.map +1 -1
  143. package/dist/chains/api/prompts.js.map +1 -1
  144. package/dist/chains/base.d.cts +1 -1
  145. package/dist/chains/combine_docs_chain.d.cts +1 -1
  146. package/dist/chains/combine_documents/stuff.d.cts +1 -1
  147. package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
  148. package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
  149. package/dist/chains/conversational_retrieval_chain.d.cts +1 -1
  150. package/dist/chains/graph_qa/cypher.d.cts +1 -1
  151. package/dist/chains/history_aware_retriever.d.cts +2 -2
  152. package/dist/chains/index.cjs +0 -3
  153. package/dist/chains/index.cjs.map +1 -1
  154. package/dist/chains/index.d.cts +1 -2
  155. package/dist/chains/index.d.ts +1 -2
  156. package/dist/chains/index.js +1 -3
  157. package/dist/chains/index.js.map +1 -1
  158. package/dist/chains/llm_chain.d.cts +3 -3
  159. package/dist/chains/openai_functions/base.d.cts +3 -3
  160. package/dist/chains/openai_functions/extraction.cjs.map +1 -1
  161. package/dist/chains/openai_functions/extraction.d.cts +1 -3
  162. package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
  163. package/dist/chains/openai_functions/extraction.d.ts +1 -3
  164. package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
  165. package/dist/chains/openai_functions/extraction.js.map +1 -1
  166. package/dist/chains/openai_functions/index.cjs +0 -5
  167. package/dist/chains/openai_functions/index.cjs.map +1 -1
  168. package/dist/chains/openai_functions/index.d.cts +1 -2
  169. package/dist/chains/openai_functions/index.d.ts +1 -2
  170. package/dist/chains/openai_functions/index.js +1 -4
  171. package/dist/chains/openai_functions/index.js.map +1 -1
  172. package/dist/chains/openai_functions/openapi.cjs +4 -4
  173. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  174. package/dist/chains/openai_functions/openapi.d.cts +2 -2
  175. package/dist/chains/openai_functions/openapi.js +4 -4
  176. package/dist/chains/openai_functions/openapi.js.map +1 -1
  177. package/dist/chains/openai_functions/tagging.cjs.map +1 -1
  178. package/dist/chains/openai_functions/tagging.d.cts +2 -4
  179. package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
  180. package/dist/chains/openai_functions/tagging.d.ts +1 -3
  181. package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
  182. package/dist/chains/openai_functions/tagging.js.map +1 -1
  183. package/dist/chains/query_constructor/index.cjs +4 -4
  184. package/dist/chains/query_constructor/index.cjs.map +1 -1
  185. package/dist/chains/query_constructor/index.d.cts +5 -3
  186. package/dist/chains/query_constructor/index.d.cts.map +1 -1
  187. package/dist/chains/query_constructor/index.d.ts +4 -2
  188. package/dist/chains/query_constructor/index.d.ts.map +1 -1
  189. package/dist/chains/query_constructor/index.js +1 -1
  190. package/dist/chains/query_constructor/index.js.map +1 -1
  191. package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
  192. package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
  193. package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
  194. package/dist/chains/question_answering/refine_prompts.js.map +1 -1
  195. package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
  196. package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
  197. package/dist/chains/retrieval.d.cts +1 -1
  198. package/dist/chains/router/llm_router.d.cts +1 -1
  199. package/dist/chains/router/multi_prompt.cjs +4 -4
  200. package/dist/chains/router/multi_prompt.cjs.map +1 -1
  201. package/dist/chains/router/multi_prompt.js +1 -1
  202. package/dist/chains/router/multi_prompt.js.map +1 -1
  203. package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
  204. package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
  205. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  206. package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
  207. package/dist/chains/sql_db/sql_db_chain.d.cts +2 -2
  208. package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
  209. package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
  210. package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
  211. package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
  212. package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
  213. package/dist/chains/summarization/stuff_prompts.js.map +1 -1
  214. package/dist/chat_models/universal.cjs +8 -5
  215. package/dist/chat_models/universal.cjs.map +1 -1
  216. package/dist/chat_models/universal.d.cts +4 -4
  217. package/dist/chat_models/universal.d.cts.map +1 -1
  218. package/dist/chat_models/universal.d.ts +2 -2
  219. package/dist/chat_models/universal.d.ts.map +1 -1
  220. package/dist/chat_models/universal.js +8 -5
  221. package/dist/chat_models/universal.js.map +1 -1
  222. package/dist/document_loaders/fs/directory.cjs.map +1 -1
  223. package/dist/document_loaders/fs/directory.d.cts +0 -1
  224. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  225. package/dist/document_loaders/fs/directory.d.ts +0 -1
  226. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  227. package/dist/document_loaders/fs/directory.js.map +1 -1
  228. package/dist/document_loaders/fs/json.cjs +7 -1
  229. package/dist/document_loaders/fs/json.cjs.map +1 -1
  230. package/dist/document_loaders/fs/json.js +7 -1
  231. package/dist/document_loaders/fs/json.js.map +1 -1
  232. package/dist/embeddings/cache_backed.cjs +1 -1
  233. package/dist/embeddings/cache_backed.cjs.map +1 -1
  234. package/dist/embeddings/cache_backed.d.cts +1 -1
  235. package/dist/embeddings/cache_backed.d.ts +1 -1
  236. package/dist/embeddings/cache_backed.js +2 -2
  237. package/dist/embeddings/cache_backed.js.map +1 -1
  238. package/dist/evaluation/agents/trajectory.d.cts +3 -3
  239. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  240. package/dist/evaluation/agents/trajectory.d.ts.map +1 -1
  241. package/dist/evaluation/comparison/pairwise.d.cts +1 -1
  242. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  243. package/dist/evaluation/criteria/criteria.d.cts +1 -1
  244. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  245. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  246. package/dist/evaluation/embedding_distance/base.cjs +2 -4
  247. package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
  248. package/dist/evaluation/embedding_distance/base.js +2 -3
  249. package/dist/evaluation/embedding_distance/base.js.map +1 -1
  250. package/dist/evaluation/loader.cjs +7 -12
  251. package/dist/evaluation/loader.cjs.map +1 -1
  252. package/dist/evaluation/loader.d.cts +8 -2
  253. package/dist/evaluation/loader.d.cts.map +1 -1
  254. package/dist/evaluation/loader.d.ts +8 -2
  255. package/dist/evaluation/loader.d.ts.map +1 -1
  256. package/dist/evaluation/loader.js +7 -12
  257. package/dist/evaluation/loader.js.map +1 -1
  258. package/dist/evaluation/qa/eval_chain.d.cts +1 -1
  259. package/dist/hub/base.cjs.map +1 -1
  260. package/dist/hub/base.js.map +1 -1
  261. package/dist/index.cjs +3 -0
  262. package/dist/index.cjs.map +1 -1
  263. package/dist/index.d.cts +5 -4
  264. package/dist/index.d.ts +3 -2
  265. package/dist/index.js +3 -1
  266. package/dist/index.js.map +1 -1
  267. package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
  268. package/dist/langchain-core/dist/messages/base.d.cts +24 -33
  269. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  270. package/dist/langchain-core/dist/messages/content/index.d.cts +1 -1
  271. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  272. package/dist/langchain-core/dist/messages/message.d.cts +598 -0
  273. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
  274. package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
  275. package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
  276. package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
  277. package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
  278. package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
  279. package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
  280. package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
  281. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  282. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +1 -1
  283. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  284. package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
  285. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
  286. package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
  287. package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
  288. package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
  289. package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
  290. package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
  291. package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
  292. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  293. package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
  294. package/dist/load/import_map.cjs +2 -13
  295. package/dist/load/import_map.cjs.map +1 -1
  296. package/dist/load/import_map.js +2 -13
  297. package/dist/load/import_map.js.map +1 -1
  298. package/dist/memory/prompt.cjs.map +1 -1
  299. package/dist/memory/prompt.d.cts.map +1 -1
  300. package/dist/memory/prompt.d.ts.map +1 -1
  301. package/dist/memory/prompt.js.map +1 -1
  302. package/dist/memory/summary.d.cts +1 -1
  303. package/dist/output_parsers/combining.cjs +1 -1
  304. package/dist/output_parsers/combining.cjs.map +1 -1
  305. package/dist/output_parsers/combining.js +1 -1
  306. package/dist/output_parsers/combining.js.map +1 -1
  307. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
  308. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
  309. package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
  310. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  311. package/dist/output_parsers/expression_type_handlers/base.js +1 -1
  312. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  313. package/dist/output_parsers/fix.d.cts +1 -1
  314. package/dist/output_parsers/http_response.d.cts +1 -1
  315. package/dist/output_parsers/regex.cjs.map +1 -1
  316. package/dist/output_parsers/regex.js.map +1 -1
  317. package/dist/output_parsers/structured.cjs +4 -4
  318. package/dist/output_parsers/structured.cjs.map +1 -1
  319. package/dist/output_parsers/structured.d.cts +2 -2
  320. package/dist/output_parsers/structured.d.cts.map +1 -1
  321. package/dist/output_parsers/structured.d.ts +1 -1
  322. package/dist/output_parsers/structured.d.ts.map +1 -1
  323. package/dist/output_parsers/structured.js +2 -2
  324. package/dist/output_parsers/structured.js.map +1 -1
  325. package/dist/retrievers/ensemble.cjs.map +1 -1
  326. package/dist/retrievers/ensemble.js.map +1 -1
  327. package/dist/storage/file_system.cjs +1 -1
  328. package/dist/storage/file_system.cjs.map +1 -1
  329. package/dist/storage/file_system.js +1 -1
  330. package/dist/storage/file_system.js.map +1 -1
  331. package/dist/tools/fs.cjs +5 -5
  332. package/dist/tools/fs.cjs.map +1 -1
  333. package/dist/tools/fs.d.cts +1 -1
  334. package/dist/tools/fs.d.cts.map +1 -1
  335. package/dist/tools/fs.d.ts +1 -1
  336. package/dist/tools/fs.d.ts.map +1 -1
  337. package/dist/tools/fs.js +1 -1
  338. package/dist/tools/fs.js.map +1 -1
  339. package/dist/tools/json.d.cts +1 -1
  340. package/dist/tools/retriever.cjs +2 -2
  341. package/dist/tools/retriever.cjs.map +1 -1
  342. package/dist/tools/retriever.d.cts +2 -2
  343. package/dist/tools/retriever.d.cts.map +1 -1
  344. package/dist/tools/retriever.d.ts +1 -1
  345. package/dist/tools/retriever.d.ts.map +1 -1
  346. package/dist/tools/retriever.js +1 -1
  347. package/dist/tools/retriever.js.map +1 -1
  348. package/dist/tools/sql.cjs +1 -2
  349. package/dist/tools/sql.cjs.map +1 -1
  350. package/dist/tools/sql.d.cts +1 -1
  351. package/dist/tools/sql.d.cts.map +1 -1
  352. package/dist/tools/sql.d.ts +1 -1
  353. package/dist/tools/sql.d.ts.map +1 -1
  354. package/dist/tools/sql.js +1 -2
  355. package/dist/tools/sql.js.map +1 -1
  356. package/dist/tools/vectorstore.d.cts +1 -1
  357. package/dist/tools/webbrowser.d.cts +1 -1
  358. package/dist/types/expression-parser.d.cts +2 -0
  359. package/dist/types/expression-parser.d.cts.map +1 -1
  360. package/dist/types/expression-parser.d.ts +2 -0
  361. package/dist/types/expression-parser.d.ts.map +1 -1
  362. package/dist/util/hub.cjs +1 -1
  363. package/dist/util/hub.js +1 -1
  364. package/dist/util/openapi.cjs +1 -1
  365. package/dist/util/openapi.cjs.map +1 -1
  366. package/dist/util/openapi.js +1 -1
  367. package/dist/util/openapi.js.map +1 -1
  368. package/package.json +21 -16
  369. package/dist/chains/openai_functions/structured_output.cjs +0 -107
  370. package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
  371. package/dist/chains/openai_functions/structured_output.d.cts +0 -38
  372. package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
  373. package/dist/chains/openai_functions/structured_output.d.ts +0 -38
  374. package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
  375. package/dist/chains/openai_functions/structured_output.js +0 -105
  376. package/dist/chains/openai_functions/structured_output.js.map +0 -1
  377. package/dist/chains/openai_moderation.cjs +0 -107
  378. package/dist/chains/openai_moderation.cjs.map +0 -1
  379. package/dist/chains/openai_moderation.d.cts +0 -74
  380. package/dist/chains/openai_moderation.d.cts.map +0 -1
  381. package/dist/chains/openai_moderation.d.ts +0 -74
  382. package/dist/chains/openai_moderation.d.ts.map +0 -1
  383. package/dist/chains/openai_moderation.js +0 -106
  384. package/dist/chains/openai_moderation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tagging.d.ts","names":["BaseChatModel","BaseFunctionCallOptions","AIMessageChunk","PromptTemplate","InteropZodObject","FunctionParameters","LLMChain","LLMChainInput","TaggingChainOptions","Omit","createTaggingChain","createTaggingChainFromZod"],"sources":["../../../src/chains/openai_functions/tagging.d.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { BaseFunctionCallOptions } from \"@langchain/core/language_models/base\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport { PromptTemplate } from \"@langchain/core/prompts\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport { FunctionParameters } from \"../../output_parsers/openai_functions.js\";\nimport { LLMChain, LLMChainInput } from \"../llm_chain.js\";\n/**\n * Type representing the options for creating a tagging chain.\n */\nexport type TaggingChainOptions = {\n prompt?: PromptTemplate;\n} & Omit<LLMChainInput<object>, \"prompt\" | \"llm\">;\n/**\n * Function that creates a tagging chain using the provided schema,\n * LLM, and options. It constructs the LLM with the necessary\n * functions, prompt, output parser, and tags.\n * @param schema The schema defining the structure of function parameters.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport declare function createTaggingChain(schema: FunctionParameters, llm: BaseChatModel<BaseFunctionCallOptions>, options?: TaggingChainOptions): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>>;\n/**\n * Function that creates a tagging chain from a Zod schema. It converts\n * the Zod schema to a JSON schema using the zodToJsonSchema function and\n * then calls createTaggingChain with the converted schema.\n * @param schema The Zod schema which extracted data should match.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport declare function createTaggingChainFromZod(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nschema: InteropZodObject, llm: BaseChatModel<BaseFunctionCallOptions>, options?: TaggingChainOptions): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>>;\n"],"mappings":";;;;;;;;;;;;AAUA;AAA+B,KAAnBQ,mBAAAA,GAAmB;EAAA,MAClBL,CAAAA,EAAAA,cAAAA;CAAc,GACvBM,IAAKF,CAAAA,aAAAA,CAAAA,MAAAA,CAAAA,EAAAA,QAAAA,GAAAA,KAAAA,CAAAA;;AAAD;AAcR;;;;;;;;;;AAA4J;AAcpII,iBAdAD,kBAAAA,CAcyB,MAAA,EAdEL,kBAcF,EAAA,GAAA,EAd2BL,aAc3B,CAdyCC,uBAczC,CAAA,EAAA,OAAA,CAAA,EAd6EO,mBAc7E,CAAA,EAdmGF,QAcnG,CAAA,MAAA,EAdoHN,aAcpH,CAdkIC,uBAclI,EAd2JC,cAc3J,CAAA,CAAA;;;;;;;;;;AAE8D;;;;iBAFvFS,yBAAAA;;QAEhBP,uBAAuBJ,cAAcC,oCAAoCO,sBAAsBF,iBAAiBN,cAAcC,yBAAyBC"}
1
+ {"version":3,"file":"tagging.d.ts","names":["BaseChatModel","BaseFunctionCallOptions","AIMessageChunk","PromptTemplate","InteropZodObject","FunctionParameters","LLMChain","LLMChainInput","TaggingChainOptions","Omit","createTaggingChain","createTaggingChainFromZod"],"sources":["../../../src/chains/openai_functions/tagging.d.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { BaseFunctionCallOptions } from \"@langchain/core/language_models/base\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport { PromptTemplate } from \"@langchain/core/prompts\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport { FunctionParameters } from \"../../output_parsers/openai_functions.js\";\nimport { LLMChain, LLMChainInput } from \"../llm_chain.js\";\n/**\n * Type representing the options for creating a tagging chain.\n */\nexport type TaggingChainOptions = {\n prompt?: PromptTemplate;\n} & Omit<LLMChainInput<object>, \"prompt\" | \"llm\">;\n/**\n * Function that creates a tagging chain using the provided schema,\n * LLM, and options. It constructs the LLM with the necessary\n * functions, prompt, output parser, and tags.\n * @param schema The schema defining the structure of function parameters.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport declare function createTaggingChain(schema: FunctionParameters, llm: BaseChatModel<BaseFunctionCallOptions>, options?: TaggingChainOptions): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>>;\n/**\n * Function that creates a tagging chain from a Zod schema. It converts\n * the Zod schema to a JSON schema using the zodToJsonSchema function and\n * then calls createTaggingChain with the converted schema.\n * @param schema The Zod schema which extracted data should match.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport declare function createTaggingChainFromZod(schema: InteropZodObject, llm: BaseChatModel<BaseFunctionCallOptions>, options?: TaggingChainOptions): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>>;\n"],"mappings":";;;;;;;;;;;;AAUA;AAA+B,KAAnBQ,mBAAAA,GAAmB;EAAA,MAClBL,CAAAA,EAAAA,cAAAA;CAAc,GACvBM,IAAKF,CAAAA,aAAAA,CAAAA,MAAAA,CAAAA,EAAAA,QAAAA,GAAAA,KAAAA,CAAAA;;AAAD;AAcR;;;;;;;;;;AAA4J;AAcpII,iBAdAD,kBAAAA,CAcyB,MAAA,EAdEL,kBAcF,EAAA,GAAA,EAd2BL,aAc3B,CAdyCC,uBAczC,CAAA,EAAA,OAAA,CAAA,EAd6EO,mBAc7E,CAAA,EAdmGF,QAcnG,CAAA,MAAA,EAdoHN,aAcpH,CAdkIC,uBAclI,EAd2JC,cAc3J,CAAA,CAAA;;;;;;;;;;AAAgH;;;;iBAAzIS,yBAAAA,SAAkCP,uBAAuBJ,cAAcC,oCAAoCO,sBAAsBF,iBAAiBN,cAAcC,yBAAyBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tagging.js","names":["schema: FunctionParameters","llm: BaseChatModel<BaseFunctionCallOptions>","options: TaggingChainOptions","schema: InteropZodObject","options?: TaggingChainOptions"],"sources":["../../../src/chains/openai_functions/tagging.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { BaseFunctionCallOptions } from \"@langchain/core/language_models/base\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport { PromptTemplate } from \"@langchain/core/prompts\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7ObjectType,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n FunctionParameters,\n JsonOutputFunctionsParser,\n} from \"../../output_parsers/openai_functions.js\";\nimport { LLMChain, LLMChainInput } from \"../llm_chain.js\";\n\n/**\n * Type representing the options for creating a tagging chain.\n */\nexport type TaggingChainOptions = {\n prompt?: PromptTemplate;\n} & Omit<LLMChainInput<object>, \"prompt\" | \"llm\">;\n\n/**\n * Function that returns an array of tagging functions. These functions\n * are used to extract relevant information from a passage.\n * @param schema The schema defining the structure of function parameters.\n * @returns An array of tagging functions.\n */\nfunction getTaggingFunctions(schema: FunctionParameters) {\n return [\n {\n name: \"information_extraction\",\n description: \"Extracts the relevant information from the passage.\",\n parameters: schema,\n },\n ];\n}\n\nconst TAGGING_TEMPLATE = `Extract the desired information from the following passage.\n\nPassage:\n{input}\n`;\n\n/**\n * Function that creates a tagging chain using the provided schema,\n * LLM, and options. It constructs the LLM with the necessary\n * functions, prompt, output parser, and tags.\n * @param schema The schema defining the structure of function parameters.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport function createTaggingChain(\n schema: FunctionParameters,\n llm: BaseChatModel<BaseFunctionCallOptions>,\n options: TaggingChainOptions = {}\n): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>> {\n const { prompt = PromptTemplate.fromTemplate(TAGGING_TEMPLATE), ...rest } =\n options;\n const functions = getTaggingFunctions(schema);\n const outputParser = new JsonOutputFunctionsParser();\n return new LLMChain({\n llm,\n prompt,\n llmKwargs: { functions },\n outputParser,\n tags: [\"openai_functions\", \"tagging\"],\n ...rest,\n });\n}\n\n/**\n * Function that creates a tagging chain from a Zod schema. It converts\n * the Zod schema to a JSON schema using the zodToJsonSchema function and\n * then calls createTaggingChain with the converted schema.\n * @param schema The Zod schema which extracted data should match.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport function createTaggingChainFromZod(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodObject,\n llm: BaseChatModel<BaseFunctionCallOptions>,\n options?: TaggingChainOptions\n): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>> {\n return createTaggingChain(\n toJsonSchema(schema) as JsonSchema7ObjectType,\n llm,\n options\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,SAAS,oBAAoBA,QAA4B;AACvD,QAAO,CACL;EACE,MAAM;EACN,aAAa;EACb,YAAY;CACb,CACF;AACF;AAED,MAAM,mBAAmB,CAAC;;;;AAI1B,CAAC;;;;;;;;;;;;;;AAeD,SAAgB,mBACdA,QACAC,KACAC,UAA+B,CAAE,GACyC;CAC1E,MAAM,EAAE,SAAS,eAAe,aAAa,iBAAiB,CAAE,GAAG,MAAM,GACvE;CACF,MAAM,YAAY,oBAAoB,OAAO;CAC7C,MAAM,eAAe,IAAI;AACzB,QAAO,IAAI,SAAS;EAClB;EACA;EACA,WAAW,EAAE,UAAW;EACxB;EACA,MAAM,CAAC,oBAAoB,SAAU;EACrC,GAAG;CACJ;AACF;;;;;;;;;;;;;;AAeD,SAAgB,0BAEdC,QACAF,KACAG,SAC0E;AAC1E,QAAO,mBACL,aAAa,OAAO,EACpB,KACA,QACD;AACF"}
1
+ {"version":3,"file":"tagging.js","names":["schema: FunctionParameters","llm: BaseChatModel<BaseFunctionCallOptions>","options: TaggingChainOptions","schema: InteropZodObject","options?: TaggingChainOptions"],"sources":["../../../src/chains/openai_functions/tagging.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { BaseFunctionCallOptions } from \"@langchain/core/language_models/base\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport { PromptTemplate } from \"@langchain/core/prompts\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7ObjectType,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n FunctionParameters,\n JsonOutputFunctionsParser,\n} from \"../../output_parsers/openai_functions.js\";\nimport { LLMChain, LLMChainInput } from \"../llm_chain.js\";\n\n/**\n * Type representing the options for creating a tagging chain.\n */\nexport type TaggingChainOptions = {\n prompt?: PromptTemplate;\n} & Omit<LLMChainInput<object>, \"prompt\" | \"llm\">;\n\n/**\n * Function that returns an array of tagging functions. These functions\n * are used to extract relevant information from a passage.\n * @param schema The schema defining the structure of function parameters.\n * @returns An array of tagging functions.\n */\nfunction getTaggingFunctions(schema: FunctionParameters) {\n return [\n {\n name: \"information_extraction\",\n description: \"Extracts the relevant information from the passage.\",\n parameters: schema,\n },\n ];\n}\n\nconst TAGGING_TEMPLATE = `Extract the desired information from the following passage.\n\nPassage:\n{input}\n`;\n\n/**\n * Function that creates a tagging chain using the provided schema,\n * LLM, and options. It constructs the LLM with the necessary\n * functions, prompt, output parser, and tags.\n * @param schema The schema defining the structure of function parameters.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport function createTaggingChain(\n schema: FunctionParameters,\n llm: BaseChatModel<BaseFunctionCallOptions>,\n options: TaggingChainOptions = {}\n): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>> {\n const { prompt = PromptTemplate.fromTemplate(TAGGING_TEMPLATE), ...rest } =\n options;\n const functions = getTaggingFunctions(schema);\n const outputParser = new JsonOutputFunctionsParser();\n return new LLMChain({\n llm,\n prompt,\n llmKwargs: { functions },\n outputParser,\n tags: [\"openai_functions\", \"tagging\"],\n ...rest,\n });\n}\n\n/**\n * Function that creates a tagging chain from a Zod schema. It converts\n * the Zod schema to a JSON schema using the zodToJsonSchema function and\n * then calls createTaggingChain with the converted schema.\n * @param schema The Zod schema which extracted data should match.\n * @param llm LLM to use in the chain. Must support function calling.\n * @param options Options for creating the tagging chain.\n * @returns A new instance of LLMChain configured for tagging.\n *\n * @deprecated\n * Switch to expression language: https://js.langchain.com/docs/expression_language/\n * Will be removed in 0.2.0\n */\nexport function createTaggingChainFromZod(\n schema: InteropZodObject,\n llm: BaseChatModel<BaseFunctionCallOptions>,\n options?: TaggingChainOptions\n): LLMChain<object, BaseChatModel<BaseFunctionCallOptions, AIMessageChunk>> {\n return createTaggingChain(\n toJsonSchema(schema) as JsonSchema7ObjectType,\n llm,\n options\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,SAAS,oBAAoBA,QAA4B;AACvD,QAAO,CACL;EACE,MAAM;EACN,aAAa;EACb,YAAY;CACb,CACF;AACF;AAED,MAAM,mBAAmB,CAAC;;;;AAI1B,CAAC;;;;;;;;;;;;;;AAeD,SAAgB,mBACdA,QACAC,KACAC,UAA+B,CAAE,GACyC;CAC1E,MAAM,EAAE,SAAS,eAAe,aAAa,iBAAiB,CAAE,GAAG,MAAM,GACvE;CACF,MAAM,YAAY,oBAAoB,OAAO;CAC7C,MAAM,eAAe,IAAI;AACzB,QAAO,IAAI,SAAS;EAClB;EACA;EACA,WAAW,EAAE,UAAW;EACxB;EACA,MAAM,CAAC,oBAAoB,SAAU;EACrC,GAAG;CACJ;AACF;;;;;;;;;;;;;;AAeD,SAAgB,0BACdC,QACAF,KACAG,SAC0E;AAC1E,QAAO,mBACL,aAAa,OAAO,EACpB,KACA,QACD;AACF"}
@@ -2,8 +2,8 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  const require_structured = require('../../output_parsers/structured.cjs');
3
3
  const require_parser = require('./parser.cjs');
4
4
  const require_prompt = require('./prompt.cjs');
5
+ const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
5
6
  const __langchain_core_prompts = require_rolldown_runtime.__toESM(require("@langchain/core/prompts"));
6
- const zod = require_rolldown_runtime.__toESM(require("zod"));
7
7
  const __langchain_core_structured_query = require_rolldown_runtime.__toESM(require("@langchain/core/structured_query"));
8
8
 
9
9
  //#region src/chains/query_constructor/index.ts
@@ -32,9 +32,9 @@ var AttributeInfo = class {
32
32
  this.description = description;
33
33
  }
34
34
  };
35
- const queryInputSchema = /* @__PURE__ */ zod.z.object({
36
- query: /* @__PURE__ */ zod.z.string().describe("text string to compare to document contents"),
37
- filter: /* @__PURE__ */ zod.z.string().optional().describe("logical condition statement for filtering documents")
35
+ const queryInputSchema = /* @__PURE__ */ zod_v3.z.object({
36
+ query: /* @__PURE__ */ zod_v3.z.string().describe("text string to compare to document contents"),
37
+ filter: /* @__PURE__ */ zod_v3.z.string().optional().describe("logical condition statement for filtering documents")
38
38
  });
39
39
  /**
40
40
  * A class that extends AsymmetricStructuredOutputParser to parse
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["name: string","type: string","description: string","z","AsymmetricStructuredOutputParser","fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }","QueryTransformer","StructuredQuery","allowedComparators: Comparator[]","allowedOperators: Operator[]","info: AttributeInfo[]","DEFAULT_EXAMPLES","documentContents: string","attributeInfo: AttributeInfo[]","allowedComparators?: Comparator[]","allowedOperators?: Operator[]","examples: InputValues[]","myAllowedComparators: Comparator[]","Comparators","myAllowedOperators: Operator[]","Operators","DEFAULT_SCHEMA","DEFAULT_PREFIX","DEFAULT_SUFFIX","FewShotPromptTemplate","EXAMPLE_PROMPT","opts: QueryConstructorRunnableOptions"],"sources":["../../../src/chains/query_constructor/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport {\n Example,\n interpolateFString,\n FewShotPromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n InferInteropZodOutput,\n InputValues,\n} from \"@langchain/core/utils/types\";\nimport {\n Comparator,\n Comparators,\n Operator,\n Operators,\n StructuredQuery,\n} from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n} from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport class AttributeInfo {\n constructor(\n public name: string,\n public type: string,\n public description: string\n ) {}\n}\n\nexport { QueryTransformer, type TraverseType };\nexport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n};\n\nconst queryInputSchema = /* #__PURE__ */ z.object({\n query: /* #__PURE__ */ z\n .string()\n .describe(\"text string to compare to document contents\"),\n filter: /* #__PURE__ */ z\n .string()\n .optional()\n .describe(\"logical condition statement for filtering documents\"),\n});\n\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<\n typeof queryInputSchema,\n StructuredQuery\n> {\n lc_namespace = [\"langchain\", \"chains\", \"query_constructor\"];\n\n queryTransformer: QueryTransformer;\n\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }) {\n super({ ...fields, inputSchema: queryInputSchema });\n\n const { allowedComparators, allowedOperators } = fields;\n this.queryTransformer = new QueryTransformer(\n allowedComparators,\n allowedOperators\n );\n }\n\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n async outputProcessor({\n query,\n filter,\n }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery> {\n let myQuery = query;\n if (myQuery.length === 0) {\n myQuery = \" \";\n }\n if (filter === \"NO_FILTER\" || filter === undefined) {\n return new StructuredQuery(query);\n } else {\n const parsedFilter = await this.queryTransformer.parse(filter);\n return new StructuredQuery(query, parsedFilter);\n }\n }\n\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(\n allowedComparators: Comparator[] = [],\n allowedOperators: Operator[] = []\n ) {\n return new StructuredQueryOutputParser({\n allowedComparators,\n allowedOperators,\n });\n }\n}\n\nexport function formatAttributeInfo(info: AttributeInfo[]) {\n const infoObj = info.reduce((acc, attr) => {\n acc[attr.name] = {\n type: attr.type,\n description: attr.description,\n };\n return acc;\n }, {} as { [name: string]: { type: string; description: string } });\n\n return JSON.stringify(infoObj, null, 2)\n .replaceAll(\"{\", \"{{\")\n .replaceAll(\"}\", \"}}\");\n}\n\nconst defaultExample = DEFAULT_EXAMPLES.map((EXAMPLE) => EXAMPLE as Example);\n\nfunction _getPrompt(\n documentContents: string,\n attributeInfo: AttributeInfo[],\n allowedComparators?: Comparator[],\n allowedOperators?: Operator[],\n examples: InputValues[] = defaultExample\n) {\n const myAllowedComparators: Comparator[] =\n allowedComparators ?? Object.values(Comparators);\n const myAllowedOperators: Operator[] =\n allowedOperators ?? Object.values(Operators);\n const attributeJSON = formatAttributeInfo(attributeInfo);\n const schema = interpolateFString(DEFAULT_SCHEMA, {\n allowed_comparators: myAllowedComparators.join(\" | \"),\n allowed_operators: myAllowedOperators.join(\" | \"),\n });\n const prefix = interpolateFString(DEFAULT_PREFIX, {\n schema,\n });\n const suffix = interpolateFString(DEFAULT_SUFFIX, {\n i: examples.length + 1,\n content: documentContents,\n attributes: attributeJSON,\n });\n\n const outputParser = StructuredQueryOutputParser.fromComponents(\n allowedComparators,\n allowedOperators\n );\n\n return new FewShotPromptTemplate({\n examples,\n examplePrompt: EXAMPLE_PROMPT,\n inputVariables: [\"query\"],\n suffix,\n prefix,\n outputParser,\n });\n}\n\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\n\nexport function loadQueryConstructorRunnable(\n opts: QueryConstructorRunnableOptions\n): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>> {\n const prompt = _getPrompt(\n opts.documentContents,\n opts.attributeInfo,\n opts.allowedComparators,\n opts.allowedOperators,\n opts.examples\n );\n const outputParser = StructuredQueryOutputParser.fromComponents(\n opts.allowedComparators,\n opts.allowedOperators\n );\n return prompt.pipe(opts.llm).pipe(outputParser);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,gBAAb,MAA2B;CACzB,YACSA,MACAC,MACAC,aACP;EAHO;EACA;EACA;CACL;AACL;AAWD,MAAM,mCAAmCC,MAAE,OAAO;CAChD,uBAAuBA,MACpB,QAAQ,CACR,SAAS,8CAA8C;CAC1D,wBAAwBA,MACrB,QAAQ,CACR,UAAU,CACV,SAAS,sDAAsD;AACnE,EAAC;;;;;AAMF,IAAa,8BAAb,MAAa,oCAAoCC,oDAG/C;CACA,eAAe;EAAC;EAAa;EAAU;CAAoB;CAE3D;CAEA,YAAYC,QAGT;EACD,MAAM;GAAE,GAAG;GAAQ,aAAa;EAAkB,EAAC;EAEnD,MAAM,EAAE,oBAAoB,kBAAkB,GAAG;EACjD,KAAK,mBAAmB,IAAIC,gCAC1B,oBACA;CAEH;;;;;;;CAQD,MAAM,gBAAgB,EACpB,OACA,QAC+C,EAA4B;EAC3E,IAAI,UAAU;AACd,MAAI,QAAQ,WAAW,GACrB,UAAU;AAEZ,MAAI,WAAW,eAAe,WAAW,OACvC,QAAO,IAAIC,kDAAgB;OACtB;GACL,MAAM,eAAe,MAAM,KAAK,iBAAiB,MAAM,OAAO;AAC9D,UAAO,IAAIA,kDAAgB,OAAO;EACnC;CACF;;;;;;;;CASD,OAAO,eACLC,qBAAmC,CAAE,GACrCC,mBAA+B,CAAE,GACjC;AACA,SAAO,IAAI,4BAA4B;GACrC;GACA;EACD;CACF;AACF;AAED,SAAgB,oBAAoBC,MAAuB;CACzD,MAAM,UAAU,KAAK,OAAO,CAAC,KAAK,SAAS;EACzC,IAAI,KAAK,QAAQ;GACf,MAAM,KAAK;GACX,aAAa,KAAK;EACnB;AACD,SAAO;CACR,GAAE,CAAE,EAA8D;AAEnE,QAAO,KAAK,UAAU,SAAS,MAAM,EAAE,CACpC,WAAW,KAAK,KAAK,CACrB,WAAW,KAAK,KAAK;AACzB;AAED,MAAM,iBAAiBC,gCAAiB,IAAI,CAAC,YAAY,QAAmB;AAE5E,SAAS,WACPC,kBACAC,eACAC,oBACAC,kBACAC,WAA0B,gBAC1B;CACA,MAAMC,uBACJ,sBAAsB,OAAO,OAAOC,8CAAY;CAClD,MAAMC,qBACJ,oBAAoB,OAAO,OAAOC,4CAAU;CAC9C,MAAM,gBAAgB,oBAAoB,cAAc;CACxD,MAAM,0DAA4BC,+BAAgB;EAChD,qBAAqB,qBAAqB,KAAK,MAAM;EACrD,mBAAmB,mBAAmB,KAAK,MAAM;CAClD,EAAC;CACF,MAAM,0DAA4BC,+BAAgB,EAChD,OACD,EAAC;CACF,MAAM,0DAA4BC,+BAAgB;EAChD,GAAG,SAAS,SAAS;EACrB,SAAS;EACT,YAAY;CACb,EAAC;CAEF,MAAM,eAAe,4BAA4B,eAC/C,oBACA,iBACD;AAED,QAAO,IAAIC,+CAAsB;EAC/B;EACA,eAAeC;EACf,gBAAgB,CAAC,OAAQ;EACzB;EACA;EACA;CACD;AACF;AAiBD,SAAgB,6BACdC,MACqE;CACrE,MAAM,SAAS,WACb,KAAK,kBACL,KAAK,eACL,KAAK,oBACL,KAAK,kBACL,KAAK,SACN;CACD,MAAM,eAAe,4BAA4B,eAC/C,KAAK,oBACL,KAAK,iBACN;AACD,QAAO,OAAO,KAAK,KAAK,IAAI,CAAC,KAAK,aAAa;AAChD"}
1
+ {"version":3,"file":"index.cjs","names":["name: string","type: string","description: string","z","AsymmetricStructuredOutputParser","fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }","QueryTransformer","StructuredQuery","allowedComparators: Comparator[]","allowedOperators: Operator[]","info: AttributeInfo[]","DEFAULT_EXAMPLES","documentContents: string","attributeInfo: AttributeInfo[]","allowedComparators?: Comparator[]","allowedOperators?: Operator[]","examples: InputValues[]","myAllowedComparators: Comparator[]","Comparators","myAllowedOperators: Operator[]","Operators","DEFAULT_SCHEMA","DEFAULT_PREFIX","DEFAULT_SUFFIX","FewShotPromptTemplate","EXAMPLE_PROMPT","opts: QueryConstructorRunnableOptions"],"sources":["../../../src/chains/query_constructor/index.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport {\n Example,\n interpolateFString,\n FewShotPromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n InferInteropZodOutput,\n InputValues,\n} from \"@langchain/core/utils/types\";\nimport {\n Comparator,\n Comparators,\n Operator,\n Operators,\n StructuredQuery,\n} from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n} from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport class AttributeInfo {\n constructor(\n public name: string,\n public type: string,\n public description: string\n ) {}\n}\n\nexport { QueryTransformer, type TraverseType };\nexport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n};\n\nconst queryInputSchema = /* #__PURE__ */ z.object({\n query: /* #__PURE__ */ z\n .string()\n .describe(\"text string to compare to document contents\"),\n filter: /* #__PURE__ */ z\n .string()\n .optional()\n .describe(\"logical condition statement for filtering documents\"),\n});\n\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<\n typeof queryInputSchema,\n StructuredQuery\n> {\n lc_namespace = [\"langchain\", \"chains\", \"query_constructor\"];\n\n queryTransformer: QueryTransformer;\n\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }) {\n super({ ...fields, inputSchema: queryInputSchema });\n\n const { allowedComparators, allowedOperators } = fields;\n this.queryTransformer = new QueryTransformer(\n allowedComparators,\n allowedOperators\n );\n }\n\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n async outputProcessor({\n query,\n filter,\n }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery> {\n let myQuery = query;\n if (myQuery.length === 0) {\n myQuery = \" \";\n }\n if (filter === \"NO_FILTER\" || filter === undefined) {\n return new StructuredQuery(query);\n } else {\n const parsedFilter = await this.queryTransformer.parse(filter);\n return new StructuredQuery(query, parsedFilter);\n }\n }\n\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(\n allowedComparators: Comparator[] = [],\n allowedOperators: Operator[] = []\n ) {\n return new StructuredQueryOutputParser({\n allowedComparators,\n allowedOperators,\n });\n }\n}\n\nexport function formatAttributeInfo(info: AttributeInfo[]) {\n const infoObj = info.reduce((acc, attr) => {\n acc[attr.name] = {\n type: attr.type,\n description: attr.description,\n };\n return acc;\n }, {} as { [name: string]: { type: string; description: string } });\n\n return JSON.stringify(infoObj, null, 2)\n .replaceAll(\"{\", \"{{\")\n .replaceAll(\"}\", \"}}\");\n}\n\nconst defaultExample = DEFAULT_EXAMPLES.map((EXAMPLE) => EXAMPLE as Example);\n\nfunction _getPrompt(\n documentContents: string,\n attributeInfo: AttributeInfo[],\n allowedComparators?: Comparator[],\n allowedOperators?: Operator[],\n examples: InputValues[] = defaultExample\n) {\n const myAllowedComparators: Comparator[] =\n allowedComparators ?? Object.values(Comparators);\n const myAllowedOperators: Operator[] =\n allowedOperators ?? Object.values(Operators);\n const attributeJSON = formatAttributeInfo(attributeInfo);\n const schema = interpolateFString(DEFAULT_SCHEMA, {\n allowed_comparators: myAllowedComparators.join(\" | \"),\n allowed_operators: myAllowedOperators.join(\" | \"),\n });\n const prefix = interpolateFString(DEFAULT_PREFIX, {\n schema,\n });\n const suffix = interpolateFString(DEFAULT_SUFFIX, {\n i: examples.length + 1,\n content: documentContents,\n attributes: attributeJSON,\n });\n\n const outputParser = StructuredQueryOutputParser.fromComponents(\n allowedComparators,\n allowedOperators\n );\n\n return new FewShotPromptTemplate({\n examples,\n examplePrompt: EXAMPLE_PROMPT,\n inputVariables: [\"query\"],\n suffix,\n prefix,\n outputParser,\n });\n}\n\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\n\nexport function loadQueryConstructorRunnable(\n opts: QueryConstructorRunnableOptions\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>> {\n const prompt = _getPrompt(\n opts.documentContents,\n opts.attributeInfo,\n opts.allowedComparators,\n opts.allowedOperators,\n opts.examples\n );\n const outputParser = StructuredQueryOutputParser.fromComponents(\n opts.allowedComparators,\n opts.allowedOperators\n );\n return prompt.pipe(opts.llm).pipe(outputParser);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,gBAAb,MAA2B;CACzB,YACSA,MACAC,MACAC,aACP;EAHO;EACA;EACA;CACL;AACL;AAWD,MAAM,mCAAmCC,SAAE,OAAO;CAChD,uBAAuBA,SACpB,QAAQ,CACR,SAAS,8CAA8C;CAC1D,wBAAwBA,SACrB,QAAQ,CACR,UAAU,CACV,SAAS,sDAAsD;AACnE,EAAC;;;;;AAMF,IAAa,8BAAb,MAAa,oCAAoCC,oDAG/C;CACA,eAAe;EAAC;EAAa;EAAU;CAAoB;CAE3D;CAEA,YAAYC,QAGT;EACD,MAAM;GAAE,GAAG;GAAQ,aAAa;EAAkB,EAAC;EAEnD,MAAM,EAAE,oBAAoB,kBAAkB,GAAG;EACjD,KAAK,mBAAmB,IAAIC,gCAC1B,oBACA;CAEH;;;;;;;CAQD,MAAM,gBAAgB,EACpB,OACA,QAC+C,EAA4B;EAC3E,IAAI,UAAU;AACd,MAAI,QAAQ,WAAW,GACrB,UAAU;AAEZ,MAAI,WAAW,eAAe,WAAW,OACvC,QAAO,IAAIC,kDAAgB;OACtB;GACL,MAAM,eAAe,MAAM,KAAK,iBAAiB,MAAM,OAAO;AAC9D,UAAO,IAAIA,kDAAgB,OAAO;EACnC;CACF;;;;;;;;CASD,OAAO,eACLC,qBAAmC,CAAE,GACrCC,mBAA+B,CAAE,GACjC;AACA,SAAO,IAAI,4BAA4B;GACrC;GACA;EACD;CACF;AACF;AAED,SAAgB,oBAAoBC,MAAuB;CACzD,MAAM,UAAU,KAAK,OAAO,CAAC,KAAK,SAAS;EACzC,IAAI,KAAK,QAAQ;GACf,MAAM,KAAK;GACX,aAAa,KAAK;EACnB;AACD,SAAO;CACR,GAAE,CAAE,EAA8D;AAEnE,QAAO,KAAK,UAAU,SAAS,MAAM,EAAE,CACpC,WAAW,KAAK,KAAK,CACrB,WAAW,KAAK,KAAK;AACzB;AAED,MAAM,iBAAiBC,gCAAiB,IAAI,CAAC,YAAY,QAAmB;AAE5E,SAAS,WACPC,kBACAC,eACAC,oBACAC,kBACAC,WAA0B,gBAC1B;CACA,MAAMC,uBACJ,sBAAsB,OAAO,OAAOC,8CAAY;CAClD,MAAMC,qBACJ,oBAAoB,OAAO,OAAOC,4CAAU;CAC9C,MAAM,gBAAgB,oBAAoB,cAAc;CACxD,MAAM,0DAA4BC,+BAAgB;EAChD,qBAAqB,qBAAqB,KAAK,MAAM;EACrD,mBAAmB,mBAAmB,KAAK,MAAM;CAClD,EAAC;CACF,MAAM,0DAA4BC,+BAAgB,EAChD,OACD,EAAC;CACF,MAAM,0DAA4BC,+BAAgB;EAChD,GAAG,SAAS,SAAS;EACrB,SAAS;EACT,YAAY;CACb,EAAC;CAEF,MAAM,eAAe,4BAA4B,eAC/C,oBACA,iBACD;AAED,QAAO,IAAIC,+CAAsB;EAC/B;EACA,eAAeC;EACf,gBAAgB,CAAC,OAAQ;EACzB;EACA;EACA;CACD;AACF;AAiBD,SAAgB,6BACdC,MAEqE;CACrE,MAAM,SAAS,WACb,KAAK,kBACL,KAAK,eACL,KAAK,oBACL,KAAK,kBACL,KAAK,SACN;CACD,MAAM,eAAe,4BAA4B,eAC/C,KAAK,oBACL,KAAK,iBACN;AACD,QAAO,OAAO,KAAK,KAAK,IAAI,CAAC,KAAK,aAAa;AAChD"}
@@ -2,9 +2,9 @@ import { QueryTransformer, TraverseType } from "./parser.cjs";
2
2
  import { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT } from "./prompt.cjs";
3
3
  import { AsymmetricStructuredOutputParser } from "../../output_parsers/structured.cjs";
4
4
  import { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
5
- import { Runnable, RunnableConfig } from "@langchain/core/runnables";
5
+ import { z } from "zod/v3";
6
6
  import { InferInteropZodOutput, InputValues } from "@langchain/core/utils/types";
7
- import { z } from "zod";
7
+ import { Runnable, RunnableConfig } from "@langchain/core/runnables";
8
8
  import { Comparator, Operator, StructuredQuery } from "@langchain/core/structured_query";
9
9
 
10
10
  //#region src/chains/query_constructor/index.d.ts
@@ -74,7 +74,9 @@ type QueryConstructorRunnableOptions = {
74
74
  };
75
75
  /** @deprecated */
76
76
  type QueryConstructorChainOptions = QueryConstructorRunnableOptions;
77
- declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;
77
+ declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ ): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;
78
80
  //#endregion
79
81
  export { AttributeInfo, DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, QueryConstructorChainOptions, QueryConstructorRunnableOptions, QueryTransformer, StructuredQueryOutputParser, type TraverseType, formatAttributeInfo, loadQueryConstructorRunnable };
80
82
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["z","BaseLanguageModelInterface","InferInteropZodOutput","InputValues","Comparator","Operator","StructuredQuery","Runnable","RunnableConfig","QueryTransformer","TraverseType","DEFAULT_EXAMPLES","DEFAULT_PREFIX","DEFAULT_SCHEMA","DEFAULT_SUFFIX","EXAMPLE_PROMPT","AsymmetricStructuredOutputParser","AttributeInfo","queryInputSchema","ZodString","ZodOptional","ZodTypeAny","ZodObject","StructuredQueryOutputParser","query","filter","Promise","formatAttributeInfo","QueryConstructorRunnableOptions","QueryConstructorChainOptions","loadQueryConstructorRunnable","Record"],"sources":["../../../src/chains/query_constructor/index.d.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { InferInteropZodOutput, InputValues } from \"@langchain/core/utils/types\";\nimport { Comparator, Operator, StructuredQuery } from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT } from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport declare class AttributeInfo {\n name: string;\n type: string;\n description: string;\n constructor(name: string, type: string, description: string);\n}\nexport { QueryTransformer, type TraverseType };\nexport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, };\ndeclare const queryInputSchema: z.ZodObject<{\n query: z.ZodString;\n filter: z.ZodOptional<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n query: string;\n filter?: string | undefined;\n}, {\n query: string;\n filter?: string | undefined;\n}>;\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport declare class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<typeof queryInputSchema, StructuredQuery> {\n lc_namespace: string[];\n queryTransformer: QueryTransformer;\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n });\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n outputProcessor({ query, filter }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery>;\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(allowedComparators?: Comparator[], allowedOperators?: Operator[]): StructuredQueryOutputParser;\n}\nexport declare function formatAttributeInfo(info: AttributeInfo[]): string;\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\nexport declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;\n"],"mappings":";;;;;;;;;;;;;AAaA;AAO6F;;AAElFA,cATUiB,aAAAA,CASRE;EAAS,IACInB,EAAEmB,MAAAA;EAAS,IAAzBnB,EAAEoB,MAAAA;EAAW,WACXC,EAAAA,MAAAA;EAAU,WAHUC,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,IAAAA,EAAAA,MAAAA,EAAAA,WAAAA,EAAAA,MAAAA;AAAS;cAA7BJ,gBAcmFA,EAdjElB,CAAAA,CAAEsB,SAc+DJ,CAAAA;EAAgB,KAAEZ,EAbxGN,CAAAA,CAAEmB,SAasGb;EAAe,MAE5GG,EAdVT,CAAAA,CAAEoB,WAcQX,CAdIT,CAAAA,CAAEmB,SAcNV,CAAAA;CAAgB,EAAA,OAEVL,EAfhBJ,CAAAA,CAAEqB,UAecjB,EAAAA;EAAU,KACZC,EAAAA,MAAAA;EAAQ,MAQZmB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAK,EAAA;EAAQ,KAAiCN,EAAAA,MAAAA;EAAgB,MAA7ChB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAqB,CAAA;;;;;AAbHc,cAApCO,2BAAAA,SAAoCP,gCAAAA,CAAAA,OAAwCE,gBAAxCF,EAA0DV,eAA1DU,CAAAA,CAAAA;EAAgC,YAAA,EAAA,MAAA,EAAA;EAuBjEW,gBAAAA,EArBFlB,gBAqB4BQ;EAItCW,WAAAA,CAAAA,MAAAA,EAAAA;IAA+B,kBAAA,EAvBfxB,UAuBe,EAAA;IAClCH,gBAAAA,EAvBiBI,QAuBjBJ,EAAAA;EAA0B,CAAA;EAEH;;;AAGD;AAG/B;AACA;EAAoD,eAAA,CAAA;IAAA,KAAA;IAAA;EAAA,CAAA,EAxBbC,qBAwBa,CAAA,OAxBgBgB,gBAwBhB,CAAA,CAAA,EAxBoCQ,OAwBpC,CAxB4CpB,eAwB5C,CAAA;EAAA;;;;;AAAiD;;6CAhBtDF,iCAAiCC,aAAakB;;iBAErEI,mBAAAA,OAA0BV;;;;KAItCW,+BAAAA;OACH3B;;iBAEUgB;aACJd;uBACUC;qBACFC;;;KAGXwB,4BAAAA,GAA+BD;iBACnBE,4BAAAA,OAAmCF,kCAAkCrB,cAAcD,iBAAiBE,eAAeuB"}
1
+ {"version":3,"file":"index.d.cts","names":["z","BaseLanguageModelInterface","InferInteropZodOutput","InputValues","Comparator","Operator","StructuredQuery","Runnable","RunnableConfig","QueryTransformer","TraverseType","DEFAULT_EXAMPLES","DEFAULT_PREFIX","DEFAULT_SCHEMA","DEFAULT_SUFFIX","EXAMPLE_PROMPT","AsymmetricStructuredOutputParser","AttributeInfo","queryInputSchema","ZodString","ZodOptional","ZodTypeAny","ZodObject","StructuredQueryOutputParser","query","filter","Promise","formatAttributeInfo","QueryConstructorRunnableOptions","QueryConstructorChainOptions","loadQueryConstructorRunnable","Record"],"sources":["../../../src/chains/query_constructor/index.d.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { InferInteropZodOutput, InputValues } from \"@langchain/core/utils/types\";\nimport { Comparator, Operator, StructuredQuery } from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT } from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport declare class AttributeInfo {\n name: string;\n type: string;\n description: string;\n constructor(name: string, type: string, description: string);\n}\nexport { QueryTransformer, type TraverseType };\nexport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, };\ndeclare const queryInputSchema: z.ZodObject<{\n query: z.ZodString;\n filter: z.ZodOptional<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n query: string;\n filter?: string | undefined;\n}, {\n query: string;\n filter?: string | undefined;\n}>;\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport declare class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<typeof queryInputSchema, StructuredQuery> {\n lc_namespace: string[];\n queryTransformer: QueryTransformer;\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n });\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n outputProcessor({ query, filter }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery>;\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(allowedComparators?: Comparator[], allowedOperators?: Operator[]): StructuredQueryOutputParser;\n}\nexport declare function formatAttributeInfo(info: AttributeInfo[]): string;\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\nexport declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;\n"],"mappings":";;;;;;;;;;;;;AAaA;AAO6F;;AAElFA,cATUiB,aAAAA,CASRE;EAAS,IACInB,EAAEmB,MAAAA;EAAS,IAAzBnB,EAAEoB,MAAAA;EAAW,WACXC,EAAAA,MAAAA;EAAU,WAHUC,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,IAAAA,EAAAA,MAAAA,EAAAA,WAAAA,EAAAA,MAAAA;AAAS;cAA7BJ,gBAcmFA,EAdjElB,CAAAA,CAAEsB,SAc+DJ,CAAAA;EAAgB,KAAEZ,EAbxGN,CAAAA,CAAEmB,SAasGb;EAAe,MAE5GG,EAdVT,CAAAA,CAAEoB,WAcQX,CAdIT,CAAAA,CAAEmB,SAcNV,CAAAA;CAAgB,EAAA,OAEVL,EAfhBJ,CAAAA,CAAEqB,UAecjB,EAAAA;EAAU,KACZC,EAAAA,MAAAA;EAAQ,MAQZmB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAK,EAAA;EAAQ,KAAiCN,EAAAA,MAAAA;EAAgB,MAA7ChB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAqB,CAAA;;;;;AAbHc,cAApCO,2BAAAA,SAAoCP,gCAAAA,CAAAA,OAAwCE,gBAAxCF,EAA0DV,eAA1DU,CAAAA,CAAAA;EAAgC,YAAA,EAAA,MAAA,EAAA;EAuBjEW,gBAAAA,EArBFlB,gBAqB4BQ;EAItCW,WAAAA,CAAAA,MAAAA,EAAAA;IAA+B,kBAAA,EAvBfxB,UAuBe,EAAA;IAClCH,gBAAAA,EAvBiBI,QAuBjBJ,EAAAA;EAA0B,CAAA;EAEH;;;AAGD;AAG/B;AACA;EAAoD,eAAA,CAAA;IAAA,KAAA;IAAA;EAAA,CAAA,EAxBbC,qBAwBa,CAAA,OAxBgBgB,gBAwBhB,CAAA,CAAA,EAxBoCQ,OAwBpC,CAxB4CpB,eAwB5C,CAAA;EAAA;;;;;AAEzC;;6CAlBoCF,iCAAiCC,aAAakB;;iBAErEI,mBAAAA,OAA0BV;;;;KAItCW,+BAAAA;OACH3B;;iBAEUgB;aACJd;uBACUC;qBACFC;;;KAGXwB,4BAAAA,GAA+BD;iBACnBE,4BAAAA,OAAmCF;;GAExDrB,cAAcD,iBAAiBE,eAAeuB"}
@@ -3,8 +3,8 @@ import { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMP
3
3
  import { AsymmetricStructuredOutputParser } from "../../output_parsers/structured.js";
4
4
  import { Runnable, RunnableConfig } from "@langchain/core/runnables";
5
5
  import { InferInteropZodOutput, InputValues } from "@langchain/core/utils/types";
6
+ import { z } from "zod/v3";
6
7
  import { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
7
- import { z } from "zod";
8
8
  import { Comparator, Operator, StructuredQuery } from "@langchain/core/structured_query";
9
9
 
10
10
  //#region src/chains/query_constructor/index.d.ts
@@ -74,7 +74,9 @@ type QueryConstructorRunnableOptions = {
74
74
  };
75
75
  /** @deprecated */
76
76
  type QueryConstructorChainOptions = QueryConstructorRunnableOptions;
77
- declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;
77
+ declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ ): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;
78
80
  //#endregion
79
81
  export { AttributeInfo, DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, QueryConstructorChainOptions, QueryConstructorRunnableOptions, QueryTransformer, StructuredQueryOutputParser, type TraverseType, formatAttributeInfo, loadQueryConstructorRunnable };
80
82
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["z","BaseLanguageModelInterface","InferInteropZodOutput","InputValues","Comparator","Operator","StructuredQuery","Runnable","RunnableConfig","QueryTransformer","TraverseType","DEFAULT_EXAMPLES","DEFAULT_PREFIX","DEFAULT_SCHEMA","DEFAULT_SUFFIX","EXAMPLE_PROMPT","AsymmetricStructuredOutputParser","AttributeInfo","queryInputSchema","ZodString","ZodOptional","ZodTypeAny","ZodObject","StructuredQueryOutputParser","query","filter","Promise","formatAttributeInfo","QueryConstructorRunnableOptions","QueryConstructorChainOptions","loadQueryConstructorRunnable","Record"],"sources":["../../../src/chains/query_constructor/index.d.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { InferInteropZodOutput, InputValues } from \"@langchain/core/utils/types\";\nimport { Comparator, Operator, StructuredQuery } from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT } from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport declare class AttributeInfo {\n name: string;\n type: string;\n description: string;\n constructor(name: string, type: string, description: string);\n}\nexport { QueryTransformer, type TraverseType };\nexport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, };\ndeclare const queryInputSchema: z.ZodObject<{\n query: z.ZodString;\n filter: z.ZodOptional<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n query: string;\n filter?: string | undefined;\n}, {\n query: string;\n filter?: string | undefined;\n}>;\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport declare class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<typeof queryInputSchema, StructuredQuery> {\n lc_namespace: string[];\n queryTransformer: QueryTransformer;\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n });\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n outputProcessor({ query, filter }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery>;\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(allowedComparators?: Comparator[], allowedOperators?: Operator[]): StructuredQueryOutputParser;\n}\nexport declare function formatAttributeInfo(info: AttributeInfo[]): string;\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\nexport declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;\n"],"mappings":";;;;;;;;;;;;;AAaA;AAO6F;;AAElFA,cATUiB,aAAAA,CASRE;EAAS,IACInB,EAAEmB,MAAAA;EAAS,IAAzBnB,EAAEoB,MAAAA;EAAW,WACXC,EAAAA,MAAAA;EAAU,WAHUC,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,IAAAA,EAAAA,MAAAA,EAAAA,WAAAA,EAAAA,MAAAA;AAAS;cAA7BJ,gBAcmFA,EAdjElB,CAAAA,CAAEsB,SAc+DJ,CAAAA;EAAgB,KAAEZ,EAbxGN,CAAAA,CAAEmB,SAasGb;EAAe,MAE5GG,EAdVT,CAAAA,CAAEoB,WAcQX,CAdIT,CAAAA,CAAEmB,SAcNV,CAAAA;CAAgB,EAAA,OAEVL,EAfhBJ,CAAAA,CAAEqB,UAecjB,EAAAA;EAAU,KACZC,EAAAA,MAAAA;EAAQ,MAQZmB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAK,EAAA;EAAQ,KAAiCN,EAAAA,MAAAA;EAAgB,MAA7ChB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAqB,CAAA;;;;;AAbHc,cAApCO,2BAAAA,SAAoCP,gCAAAA,CAAAA,OAAwCE,gBAAxCF,EAA0DV,eAA1DU,CAAAA,CAAAA;EAAgC,YAAA,EAAA,MAAA,EAAA;EAuBjEW,gBAAAA,EArBFlB,gBAqB4BQ;EAItCW,WAAAA,CAAAA,MAAAA,EAAAA;IAA+B,kBAAA,EAvBfxB,UAuBe,EAAA;IAClCH,gBAAAA,EAvBiBI,QAuBjBJ,EAAAA;EAA0B,CAAA;EAEH;;;AAGD;AAG/B;AACA;EAAoD,eAAA,CAAA;IAAA,KAAA;IAAA;EAAA,CAAA,EAxBbC,qBAwBa,CAAA,OAxBgBgB,gBAwBhB,CAAA,CAAA,EAxBoCQ,OAwBpC,CAxB4CpB,eAwB5C,CAAA;EAAA;;;;;AAAiD;;6CAhBtDF,iCAAiCC,aAAakB;;iBAErEI,mBAAAA,OAA0BV;;;;KAItCW,+BAAAA;OACH3B;;iBAEUgB;aACJd;uBACUC;qBACFC;;;KAGXwB,4BAAAA,GAA+BD;iBACnBE,4BAAAA,OAAmCF,kCAAkCrB,cAAcD,iBAAiBE,eAAeuB"}
1
+ {"version":3,"file":"index.d.ts","names":["z","BaseLanguageModelInterface","InferInteropZodOutput","InputValues","Comparator","Operator","StructuredQuery","Runnable","RunnableConfig","QueryTransformer","TraverseType","DEFAULT_EXAMPLES","DEFAULT_PREFIX","DEFAULT_SCHEMA","DEFAULT_SUFFIX","EXAMPLE_PROMPT","AsymmetricStructuredOutputParser","AttributeInfo","queryInputSchema","ZodString","ZodOptional","ZodTypeAny","ZodObject","StructuredQueryOutputParser","query","filter","Promise","formatAttributeInfo","QueryConstructorRunnableOptions","QueryConstructorChainOptions","loadQueryConstructorRunnable","Record"],"sources":["../../../src/chains/query_constructor/index.d.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { InferInteropZodOutput, InputValues } from \"@langchain/core/utils/types\";\nimport { Comparator, Operator, StructuredQuery } from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT } from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport declare class AttributeInfo {\n name: string;\n type: string;\n description: string;\n constructor(name: string, type: string, description: string);\n}\nexport { QueryTransformer, type TraverseType };\nexport { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, };\ndeclare const queryInputSchema: z.ZodObject<{\n query: z.ZodString;\n filter: z.ZodOptional<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n query: string;\n filter?: string | undefined;\n}, {\n query: string;\n filter?: string | undefined;\n}>;\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport declare class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<typeof queryInputSchema, StructuredQuery> {\n lc_namespace: string[];\n queryTransformer: QueryTransformer;\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n });\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n outputProcessor({ query, filter }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery>;\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(allowedComparators?: Comparator[], allowedOperators?: Operator[]): StructuredQueryOutputParser;\n}\nexport declare function formatAttributeInfo(info: AttributeInfo[]): string;\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\nexport declare function loadQueryConstructorRunnable(opts: QueryConstructorRunnableOptions\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>>;\n"],"mappings":";;;;;;;;;;;;;AAaA;AAO6F;;AAElFA,cATUiB,aAAAA,CASRE;EAAS,IACInB,EAAEmB,MAAAA;EAAS,IAAzBnB,EAAEoB,MAAAA;EAAW,WACXC,EAAAA,MAAAA;EAAU,WAHUC,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,IAAAA,EAAAA,MAAAA,EAAAA,WAAAA,EAAAA,MAAAA;AAAS;cAA7BJ,gBAcmFA,EAdjElB,CAAAA,CAAEsB,SAc+DJ,CAAAA;EAAgB,KAAEZ,EAbxGN,CAAAA,CAAEmB,SAasGb;EAAe,MAE5GG,EAdVT,CAAAA,CAAEoB,WAcQX,CAdIT,CAAAA,CAAEmB,SAcNV,CAAAA;CAAgB,EAAA,OAEVL,EAfhBJ,CAAAA,CAAEqB,UAecjB,EAAAA;EAAU,KACZC,EAAAA,MAAAA;EAAQ,MAQZmB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAK,EAAA;EAAQ,KAAiCN,EAAAA,MAAAA;EAAgB,MAA7ChB,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;CAAqB,CAAA;;;;;AAbHc,cAApCO,2BAAAA,SAAoCP,gCAAAA,CAAAA,OAAwCE,gBAAxCF,EAA0DV,eAA1DU,CAAAA,CAAAA;EAAgC,YAAA,EAAA,MAAA,EAAA;EAuBjEW,gBAAAA,EArBFlB,gBAqB4BQ;EAItCW,WAAAA,CAAAA,MAAAA,EAAAA;IAA+B,kBAAA,EAvBfxB,UAuBe,EAAA;IAClCH,gBAAAA,EAvBiBI,QAuBjBJ,EAAAA;EAA0B,CAAA;EAEH;;;AAGD;AAG/B;AACA;EAAoD,eAAA,CAAA;IAAA,KAAA;IAAA;EAAA,CAAA,EAxBbC,qBAwBa,CAAA,OAxBgBgB,gBAwBhB,CAAA,CAAA,EAxBoCQ,OAwBpC,CAxB4CpB,eAwB5C,CAAA;EAAA;;;;;AAEzC;;6CAlBoCF,iCAAiCC,aAAakB;;iBAErEI,mBAAAA,OAA0BV;;;;KAItCW,+BAAAA;OACH3B;;iBAEUgB;aACJd;uBACUC;qBACFC;;;KAGXwB,4BAAAA,GAA+BD;iBACnBE,4BAAAA,OAAmCF;;GAExDrB,cAAcD,iBAAiBE,eAAeuB"}
@@ -2,8 +2,8 @@ import { __export } from "../../_virtual/rolldown_runtime.js";
2
2
  import { AsymmetricStructuredOutputParser } from "../../output_parsers/structured.js";
3
3
  import { QueryTransformer } from "./parser.js";
4
4
  import { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT } from "./prompt.js";
5
+ import { z } from "zod/v3";
5
6
  import { FewShotPromptTemplate, interpolateFString } from "@langchain/core/prompts";
6
- import { z } from "zod";
7
7
  import { Comparators, Operators, StructuredQuery } from "@langchain/core/structured_query";
8
8
 
9
9
  //#region src/chains/query_constructor/index.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["name: string","type: string","description: string","fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }","allowedComparators: Comparator[]","allowedOperators: Operator[]","info: AttributeInfo[]","documentContents: string","attributeInfo: AttributeInfo[]","allowedComparators?: Comparator[]","allowedOperators?: Operator[]","examples: InputValues[]","myAllowedComparators: Comparator[]","myAllowedOperators: Operator[]","opts: QueryConstructorRunnableOptions"],"sources":["../../../src/chains/query_constructor/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport {\n Example,\n interpolateFString,\n FewShotPromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n InferInteropZodOutput,\n InputValues,\n} from \"@langchain/core/utils/types\";\nimport {\n Comparator,\n Comparators,\n Operator,\n Operators,\n StructuredQuery,\n} from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n} from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport class AttributeInfo {\n constructor(\n public name: string,\n public type: string,\n public description: string\n ) {}\n}\n\nexport { QueryTransformer, type TraverseType };\nexport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n};\n\nconst queryInputSchema = /* #__PURE__ */ z.object({\n query: /* #__PURE__ */ z\n .string()\n .describe(\"text string to compare to document contents\"),\n filter: /* #__PURE__ */ z\n .string()\n .optional()\n .describe(\"logical condition statement for filtering documents\"),\n});\n\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<\n typeof queryInputSchema,\n StructuredQuery\n> {\n lc_namespace = [\"langchain\", \"chains\", \"query_constructor\"];\n\n queryTransformer: QueryTransformer;\n\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }) {\n super({ ...fields, inputSchema: queryInputSchema });\n\n const { allowedComparators, allowedOperators } = fields;\n this.queryTransformer = new QueryTransformer(\n allowedComparators,\n allowedOperators\n );\n }\n\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n async outputProcessor({\n query,\n filter,\n }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery> {\n let myQuery = query;\n if (myQuery.length === 0) {\n myQuery = \" \";\n }\n if (filter === \"NO_FILTER\" || filter === undefined) {\n return new StructuredQuery(query);\n } else {\n const parsedFilter = await this.queryTransformer.parse(filter);\n return new StructuredQuery(query, parsedFilter);\n }\n }\n\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(\n allowedComparators: Comparator[] = [],\n allowedOperators: Operator[] = []\n ) {\n return new StructuredQueryOutputParser({\n allowedComparators,\n allowedOperators,\n });\n }\n}\n\nexport function formatAttributeInfo(info: AttributeInfo[]) {\n const infoObj = info.reduce((acc, attr) => {\n acc[attr.name] = {\n type: attr.type,\n description: attr.description,\n };\n return acc;\n }, {} as { [name: string]: { type: string; description: string } });\n\n return JSON.stringify(infoObj, null, 2)\n .replaceAll(\"{\", \"{{\")\n .replaceAll(\"}\", \"}}\");\n}\n\nconst defaultExample = DEFAULT_EXAMPLES.map((EXAMPLE) => EXAMPLE as Example);\n\nfunction _getPrompt(\n documentContents: string,\n attributeInfo: AttributeInfo[],\n allowedComparators?: Comparator[],\n allowedOperators?: Operator[],\n examples: InputValues[] = defaultExample\n) {\n const myAllowedComparators: Comparator[] =\n allowedComparators ?? Object.values(Comparators);\n const myAllowedOperators: Operator[] =\n allowedOperators ?? Object.values(Operators);\n const attributeJSON = formatAttributeInfo(attributeInfo);\n const schema = interpolateFString(DEFAULT_SCHEMA, {\n allowed_comparators: myAllowedComparators.join(\" | \"),\n allowed_operators: myAllowedOperators.join(\" | \"),\n });\n const prefix = interpolateFString(DEFAULT_PREFIX, {\n schema,\n });\n const suffix = interpolateFString(DEFAULT_SUFFIX, {\n i: examples.length + 1,\n content: documentContents,\n attributes: attributeJSON,\n });\n\n const outputParser = StructuredQueryOutputParser.fromComponents(\n allowedComparators,\n allowedOperators\n );\n\n return new FewShotPromptTemplate({\n examples,\n examplePrompt: EXAMPLE_PROMPT,\n inputVariables: [\"query\"],\n suffix,\n prefix,\n outputParser,\n });\n}\n\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\n\nexport function loadQueryConstructorRunnable(\n opts: QueryConstructorRunnableOptions\n): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>> {\n const prompt = _getPrompt(\n opts.documentContents,\n opts.attributeInfo,\n opts.allowedComparators,\n opts.allowedOperators,\n opts.examples\n );\n const outputParser = StructuredQueryOutputParser.fromComponents(\n opts.allowedComparators,\n opts.allowedOperators\n );\n return prompt.pipe(opts.llm).pipe(outputParser);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,gBAAb,MAA2B;CACzB,YACSA,MACAC,MACAC,aACP;EAHO;EACA;EACA;CACL;AACL;AAWD,MAAM,mCAAmC,EAAE,OAAO;CAChD,uBAAuB,EACpB,QAAQ,CACR,SAAS,8CAA8C;CAC1D,wBAAwB,EACrB,QAAQ,CACR,UAAU,CACV,SAAS,sDAAsD;AACnE,EAAC;;;;;AAMF,IAAa,8BAAb,MAAa,oCAAoC,iCAG/C;CACA,eAAe;EAAC;EAAa;EAAU;CAAoB;CAE3D;CAEA,YAAYC,QAGT;EACD,MAAM;GAAE,GAAG;GAAQ,aAAa;EAAkB,EAAC;EAEnD,MAAM,EAAE,oBAAoB,kBAAkB,GAAG;EACjD,KAAK,mBAAmB,IAAI,iBAC1B,oBACA;CAEH;;;;;;;CAQD,MAAM,gBAAgB,EACpB,OACA,QAC+C,EAA4B;EAC3E,IAAI,UAAU;AACd,MAAI,QAAQ,WAAW,GACrB,UAAU;AAEZ,MAAI,WAAW,eAAe,WAAW,OACvC,QAAO,IAAI,gBAAgB;OACtB;GACL,MAAM,eAAe,MAAM,KAAK,iBAAiB,MAAM,OAAO;AAC9D,UAAO,IAAI,gBAAgB,OAAO;EACnC;CACF;;;;;;;;CASD,OAAO,eACLC,qBAAmC,CAAE,GACrCC,mBAA+B,CAAE,GACjC;AACA,SAAO,IAAI,4BAA4B;GACrC;GACA;EACD;CACF;AACF;AAED,SAAgB,oBAAoBC,MAAuB;CACzD,MAAM,UAAU,KAAK,OAAO,CAAC,KAAK,SAAS;EACzC,IAAI,KAAK,QAAQ;GACf,MAAM,KAAK;GACX,aAAa,KAAK;EACnB;AACD,SAAO;CACR,GAAE,CAAE,EAA8D;AAEnE,QAAO,KAAK,UAAU,SAAS,MAAM,EAAE,CACpC,WAAW,KAAK,KAAK,CACrB,WAAW,KAAK,KAAK;AACzB;AAED,MAAM,iBAAiB,iBAAiB,IAAI,CAAC,YAAY,QAAmB;AAE5E,SAAS,WACPC,kBACAC,eACAC,oBACAC,kBACAC,WAA0B,gBAC1B;CACA,MAAMC,uBACJ,sBAAsB,OAAO,OAAO,YAAY;CAClD,MAAMC,qBACJ,oBAAoB,OAAO,OAAO,UAAU;CAC9C,MAAM,gBAAgB,oBAAoB,cAAc;CACxD,MAAM,SAAS,mBAAmB,gBAAgB;EAChD,qBAAqB,qBAAqB,KAAK,MAAM;EACrD,mBAAmB,mBAAmB,KAAK,MAAM;CAClD,EAAC;CACF,MAAM,SAAS,mBAAmB,gBAAgB,EAChD,OACD,EAAC;CACF,MAAM,SAAS,mBAAmB,gBAAgB;EAChD,GAAG,SAAS,SAAS;EACrB,SAAS;EACT,YAAY;CACb,EAAC;CAEF,MAAM,eAAe,4BAA4B,eAC/C,oBACA,iBACD;AAED,QAAO,IAAI,sBAAsB;EAC/B;EACA,eAAe;EACf,gBAAgB,CAAC,OAAQ;EACzB;EACA;EACA;CACD;AACF;AAiBD,SAAgB,6BACdC,MACqE;CACrE,MAAM,SAAS,WACb,KAAK,kBACL,KAAK,eACL,KAAK,oBACL,KAAK,kBACL,KAAK,SACN;CACD,MAAM,eAAe,4BAA4B,eAC/C,KAAK,oBACL,KAAK,iBACN;AACD,QAAO,OAAO,KAAK,KAAK,IAAI,CAAC,KAAK,aAAa;AAChD"}
1
+ {"version":3,"file":"index.js","names":["name: string","type: string","description: string","fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }","allowedComparators: Comparator[]","allowedOperators: Operator[]","info: AttributeInfo[]","documentContents: string","attributeInfo: AttributeInfo[]","allowedComparators?: Comparator[]","allowedOperators?: Operator[]","examples: InputValues[]","myAllowedComparators: Comparator[]","myAllowedOperators: Operator[]","opts: QueryConstructorRunnableOptions"],"sources":["../../../src/chains/query_constructor/index.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport {\n Example,\n interpolateFString,\n FewShotPromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n InferInteropZodOutput,\n InputValues,\n} from \"@langchain/core/utils/types\";\nimport {\n Comparator,\n Comparators,\n Operator,\n Operators,\n StructuredQuery,\n} from \"@langchain/core/structured_query\";\nimport { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { QueryTransformer, TraverseType } from \"./parser.js\";\nimport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n} from \"./prompt.js\";\nimport { AsymmetricStructuredOutputParser } from \"../../output_parsers/structured.js\";\n\n/**\n * A simple data structure that holds information about an attribute. It\n * is typically used to provide metadata about attributes in other classes\n * or data structures within the LangChain framework.\n */\nexport class AttributeInfo {\n constructor(\n public name: string,\n public type: string,\n public description: string\n ) {}\n}\n\nexport { QueryTransformer, type TraverseType };\nexport {\n DEFAULT_EXAMPLES,\n DEFAULT_PREFIX,\n DEFAULT_SCHEMA,\n DEFAULT_SUFFIX,\n EXAMPLE_PROMPT,\n};\n\nconst queryInputSchema = /* #__PURE__ */ z.object({\n query: /* #__PURE__ */ z\n .string()\n .describe(\"text string to compare to document contents\"),\n filter: /* #__PURE__ */ z\n .string()\n .optional()\n .describe(\"logical condition statement for filtering documents\"),\n});\n\n/**\n * A class that extends AsymmetricStructuredOutputParser to parse\n * structured query output.\n */\nexport class StructuredQueryOutputParser extends AsymmetricStructuredOutputParser<\n typeof queryInputSchema,\n StructuredQuery\n> {\n lc_namespace = [\"langchain\", \"chains\", \"query_constructor\"];\n\n queryTransformer: QueryTransformer;\n\n constructor(fields: {\n allowedComparators: Comparator[];\n allowedOperators: Operator[];\n }) {\n super({ ...fields, inputSchema: queryInputSchema });\n\n const { allowedComparators, allowedOperators } = fields;\n this.queryTransformer = new QueryTransformer(\n allowedComparators,\n allowedOperators\n );\n }\n\n /**\n * Processes the output of a structured query.\n * @param query The query string.\n * @param filter The filter condition.\n * @returns A Promise that resolves to a StructuredQuery instance.\n */\n async outputProcessor({\n query,\n filter,\n }: InferInteropZodOutput<typeof queryInputSchema>): Promise<StructuredQuery> {\n let myQuery = query;\n if (myQuery.length === 0) {\n myQuery = \" \";\n }\n if (filter === \"NO_FILTER\" || filter === undefined) {\n return new StructuredQuery(query);\n } else {\n const parsedFilter = await this.queryTransformer.parse(filter);\n return new StructuredQuery(query, parsedFilter);\n }\n }\n\n /**\n * Creates a new StructuredQueryOutputParser instance from the provided\n * components.\n * @param allowedComparators An array of allowed Comparator instances.\n * @param allowedOperators An array of allowed Operator instances.\n * @returns A new StructuredQueryOutputParser instance.\n */\n static fromComponents(\n allowedComparators: Comparator[] = [],\n allowedOperators: Operator[] = []\n ) {\n return new StructuredQueryOutputParser({\n allowedComparators,\n allowedOperators,\n });\n }\n}\n\nexport function formatAttributeInfo(info: AttributeInfo[]) {\n const infoObj = info.reduce((acc, attr) => {\n acc[attr.name] = {\n type: attr.type,\n description: attr.description,\n };\n return acc;\n }, {} as { [name: string]: { type: string; description: string } });\n\n return JSON.stringify(infoObj, null, 2)\n .replaceAll(\"{\", \"{{\")\n .replaceAll(\"}\", \"}}\");\n}\n\nconst defaultExample = DEFAULT_EXAMPLES.map((EXAMPLE) => EXAMPLE as Example);\n\nfunction _getPrompt(\n documentContents: string,\n attributeInfo: AttributeInfo[],\n allowedComparators?: Comparator[],\n allowedOperators?: Operator[],\n examples: InputValues[] = defaultExample\n) {\n const myAllowedComparators: Comparator[] =\n allowedComparators ?? Object.values(Comparators);\n const myAllowedOperators: Operator[] =\n allowedOperators ?? Object.values(Operators);\n const attributeJSON = formatAttributeInfo(attributeInfo);\n const schema = interpolateFString(DEFAULT_SCHEMA, {\n allowed_comparators: myAllowedComparators.join(\" | \"),\n allowed_operators: myAllowedOperators.join(\" | \"),\n });\n const prefix = interpolateFString(DEFAULT_PREFIX, {\n schema,\n });\n const suffix = interpolateFString(DEFAULT_SUFFIX, {\n i: examples.length + 1,\n content: documentContents,\n attributes: attributeJSON,\n });\n\n const outputParser = StructuredQueryOutputParser.fromComponents(\n allowedComparators,\n allowedOperators\n );\n\n return new FewShotPromptTemplate({\n examples,\n examplePrompt: EXAMPLE_PROMPT,\n inputVariables: [\"query\"],\n suffix,\n prefix,\n outputParser,\n });\n}\n\n/**\n * A type that represents options for the query constructor chain.\n */\nexport type QueryConstructorRunnableOptions = {\n llm: BaseLanguageModelInterface;\n documentContents: string;\n attributeInfo: AttributeInfo[];\n examples?: InputValues[];\n allowedComparators?: Comparator[];\n allowedOperators?: Operator[];\n};\n\n/** @deprecated */\nexport type QueryConstructorChainOptions = QueryConstructorRunnableOptions;\n\nexport function loadQueryConstructorRunnable(\n opts: QueryConstructorRunnableOptions\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Runnable<any, StructuredQuery, RunnableConfig<Record<string, any>>> {\n const prompt = _getPrompt(\n opts.documentContents,\n opts.attributeInfo,\n opts.allowedComparators,\n opts.allowedOperators,\n opts.examples\n );\n const outputParser = StructuredQueryOutputParser.fromComponents(\n opts.allowedComparators,\n opts.allowedOperators\n );\n return prompt.pipe(opts.llm).pipe(outputParser);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,gBAAb,MAA2B;CACzB,YACSA,MACAC,MACAC,aACP;EAHO;EACA;EACA;CACL;AACL;AAWD,MAAM,mCAAmC,EAAE,OAAO;CAChD,uBAAuB,EACpB,QAAQ,CACR,SAAS,8CAA8C;CAC1D,wBAAwB,EACrB,QAAQ,CACR,UAAU,CACV,SAAS,sDAAsD;AACnE,EAAC;;;;;AAMF,IAAa,8BAAb,MAAa,oCAAoC,iCAG/C;CACA,eAAe;EAAC;EAAa;EAAU;CAAoB;CAE3D;CAEA,YAAYC,QAGT;EACD,MAAM;GAAE,GAAG;GAAQ,aAAa;EAAkB,EAAC;EAEnD,MAAM,EAAE,oBAAoB,kBAAkB,GAAG;EACjD,KAAK,mBAAmB,IAAI,iBAC1B,oBACA;CAEH;;;;;;;CAQD,MAAM,gBAAgB,EACpB,OACA,QAC+C,EAA4B;EAC3E,IAAI,UAAU;AACd,MAAI,QAAQ,WAAW,GACrB,UAAU;AAEZ,MAAI,WAAW,eAAe,WAAW,OACvC,QAAO,IAAI,gBAAgB;OACtB;GACL,MAAM,eAAe,MAAM,KAAK,iBAAiB,MAAM,OAAO;AAC9D,UAAO,IAAI,gBAAgB,OAAO;EACnC;CACF;;;;;;;;CASD,OAAO,eACLC,qBAAmC,CAAE,GACrCC,mBAA+B,CAAE,GACjC;AACA,SAAO,IAAI,4BAA4B;GACrC;GACA;EACD;CACF;AACF;AAED,SAAgB,oBAAoBC,MAAuB;CACzD,MAAM,UAAU,KAAK,OAAO,CAAC,KAAK,SAAS;EACzC,IAAI,KAAK,QAAQ;GACf,MAAM,KAAK;GACX,aAAa,KAAK;EACnB;AACD,SAAO;CACR,GAAE,CAAE,EAA8D;AAEnE,QAAO,KAAK,UAAU,SAAS,MAAM,EAAE,CACpC,WAAW,KAAK,KAAK,CACrB,WAAW,KAAK,KAAK;AACzB;AAED,MAAM,iBAAiB,iBAAiB,IAAI,CAAC,YAAY,QAAmB;AAE5E,SAAS,WACPC,kBACAC,eACAC,oBACAC,kBACAC,WAA0B,gBAC1B;CACA,MAAMC,uBACJ,sBAAsB,OAAO,OAAO,YAAY;CAClD,MAAMC,qBACJ,oBAAoB,OAAO,OAAO,UAAU;CAC9C,MAAM,gBAAgB,oBAAoB,cAAc;CACxD,MAAM,SAAS,mBAAmB,gBAAgB;EAChD,qBAAqB,qBAAqB,KAAK,MAAM;EACrD,mBAAmB,mBAAmB,KAAK,MAAM;CAClD,EAAC;CACF,MAAM,SAAS,mBAAmB,gBAAgB,EAChD,OACD,EAAC;CACF,MAAM,SAAS,mBAAmB,gBAAgB;EAChD,GAAG,SAAS,SAAS;EACrB,SAAS;EACT,YAAY;CACb,EAAC;CAEF,MAAM,eAAe,4BAA4B,eAC/C,oBACA,iBACD;AAED,QAAO,IAAI,sBAAsB;EAC/B;EACA,eAAe;EACf,gBAAgB,CAAC,OAAQ;EACzB;EACA;EACA;CACD;AACF;AAiBD,SAAgB,6BACdC,MAEqE;CACrE,MAAM,SAAS,WACb,KAAK,kBACL,KAAK,eACL,KAAK,oBACL,KAAK,kBACL,KAAK,SACN;CACD,MAAM,eAAe,4BAA4B,eAC/C,KAAK,oBACL,KAAK,iBACN;AACD,QAAO,OAAO,KAAK,KAAK,IAAI,CAAC,KAAK,aAAa;AAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"map_reduce_prompts.cjs","names":["PromptTemplate","SystemMessagePromptTemplate","HumanMessagePromptTemplate","ChatPromptTemplate","ConditionalPromptSelector","isChatModel"],"sources":["../../../src/chains/question_answering/map_reduce_prompts.ts"],"sourcesContent":["/* eslint-disable spaced-comment */\nimport {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nconst qa_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n{context}\nQuestion: {question}\nRelevant text, if any:`;\nexport const DEFAULT_COMBINE_QA_PROMPT =\n /*#__PURE__*/\n PromptTemplate.fromTemplate(qa_template);\n\nconst system_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_QA_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const COMBINE_QA_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_COMBINE_QA_PROMPT, [\n [isChatModel, CHAT_QA_PROMPT],\n ]);\n\nconst combine_prompt = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n\nQUESTION: Which state/country's law governs the interpretation of the contract?\n=========\nContent: This Agreement is governed by English law and the parties submit to the exclusive jurisdiction of the English courts in relation to any dispute (contractual or non-contractual) concerning this Agreement save that either party may apply to any court for an injunction or other relief to protect its Intellectual Property Rights.\n\nContent: No Waiver. Failure or delay in exercising any right or remedy under this Agreement shall not constitute a waiver of such (or any other) right or remedy.\\n\\n11.7 Severability. The invalidity, illegality or unenforceability of any term (or part of a term) of this Agreement shall not affect the continuation in force of the remainder of the term (if any) and this Agreement.\\n\\n11.8 No Agency. Except as expressly stated otherwise, nothing in this Agreement shall create an agency, partnership or joint venture of any kind between the parties.\\n\\n11.9 No Third-Party Beneficiaries.\n\nContent: (b) if Google believes, in good faith, that the Distributor has violated or caused Google to violate any Anti-Bribery Laws (as defined in Clause 8.5) or that such a violation is reasonably likely to occur,\n=========\nFINAL ANSWER: This Agreement is governed by English law.\n\nQUESTION: What did the president say about Michael Jackson?\n=========\nContent: Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. \\n\\nGroups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.\n\nContent: And we won’t stop. \\n\\nWe have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. \\n\\nLet’s use this moment to reset. Let’s stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease. \\n\\nLet’s stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans. \\n\\nWe can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. \\n\\nI recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. \\n\\nThey were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. \\n\\nOfficer Mora was 27 years old. \\n\\nOfficer Rivera was 22. \\n\\nBoth Dominican Americans who’d grown up on the same streets they later chose to patrol as police officers. \\n\\nI spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves.\n\nContent: And a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \\n\\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world. \\n\\nAnd I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. \\n\\nTonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world. \\n\\nAmerica will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies. \\n\\nThese steps will help blunt gas prices here at home. And I know the news about what’s happening can seem alarming. \\n\\nBut I want you to know that we are going to be okay.\n\nContent: More support for patients and families. \\n\\nTo get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. \\n\\nIt’s based on DARPA—the Defense Department project that led to the Internet, GPS, and so much more. \\n\\nARPA-H will have a singular purpose—to drive breakthroughs in cancer, Alzheimer’s, diabetes, and more. \\n\\nA unity agenda for the nation. \\n\\nWe can do this. \\n\\nMy fellow Americans—tonight , we have gathered in a sacred space—the citadel of our democracy. \\n\\nIn this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation.\n=========\nFINAL ANSWER: The president did not mention Michael Jackson.\n\nQUESTION: {question}\n=========\n{summaries}\n=========\nFINAL ANSWER:`;\nexport const COMBINE_PROMPT =\n /*#__PURE__*/ PromptTemplate.fromTemplate(combine_prompt);\n\nconst system_combine_template = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n----------------\n{summaries}`;\nconst combine_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n system_combine_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_COMBINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(combine_messages);\n\nexport const COMBINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(COMBINE_PROMPT, [\n [isChatModel, CHAT_COMBINE_PROMPT],\n ]);\n"],"mappings":";;;;;AAYA,MAAM,cAAc,CAAC;;;;sBAIC,CAAC;AACvB,MAAa,4CAEXA,wCAAe,aAAa,YAAY;AAE1C,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACDC,qDAA4B,aAAa,gBAAgB,kBACzDC,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAM,iCAA+BC,4CAAmB,aAAa,SAAS;AAE9E,MAAa,6CACG,IAAIC,6DAA0B,2BAA2B,CACrE,CAACC,gDAAa,cAAe,CAC9B;AAEH,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BX,CAAC;AACd,MAAa,iCACGL,wCAAe,aAAa,eAAe;AAE3D,MAAM,0BAA0B,CAAC;;;WAGtB,CAAC;AACZ,MAAM,mBAAmB,iBACTC,qDAA4B,aACxC,wBACD,kBACaC,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAM,sCACUC,4CAAmB,aAAa,iBAAiB;AAEjE,MAAa,0CACG,IAAIC,6DAA0B,gBAAgB,CAC1D,CAACC,gDAAa,mBAAoB,CACnC"}
1
+ {"version":3,"file":"map_reduce_prompts.cjs","names":["PromptTemplate","SystemMessagePromptTemplate","HumanMessagePromptTemplate","ChatPromptTemplate","ConditionalPromptSelector","isChatModel"],"sources":["../../../src/chains/question_answering/map_reduce_prompts.ts"],"sourcesContent":["import {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nconst qa_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n{context}\nQuestion: {question}\nRelevant text, if any:`;\nexport const DEFAULT_COMBINE_QA_PROMPT =\n /*#__PURE__*/\n PromptTemplate.fromTemplate(qa_template);\n\nconst system_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_QA_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const COMBINE_QA_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_COMBINE_QA_PROMPT, [\n [isChatModel, CHAT_QA_PROMPT],\n ]);\n\nconst combine_prompt = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n\nQUESTION: Which state/country's law governs the interpretation of the contract?\n=========\nContent: This Agreement is governed by English law and the parties submit to the exclusive jurisdiction of the English courts in relation to any dispute (contractual or non-contractual) concerning this Agreement save that either party may apply to any court for an injunction or other relief to protect its Intellectual Property Rights.\n\nContent: No Waiver. Failure or delay in exercising any right or remedy under this Agreement shall not constitute a waiver of such (or any other) right or remedy.\\n\\n11.7 Severability. The invalidity, illegality or unenforceability of any term (or part of a term) of this Agreement shall not affect the continuation in force of the remainder of the term (if any) and this Agreement.\\n\\n11.8 No Agency. Except as expressly stated otherwise, nothing in this Agreement shall create an agency, partnership or joint venture of any kind between the parties.\\n\\n11.9 No Third-Party Beneficiaries.\n\nContent: (b) if Google believes, in good faith, that the Distributor has violated or caused Google to violate any Anti-Bribery Laws (as defined in Clause 8.5) or that such a violation is reasonably likely to occur,\n=========\nFINAL ANSWER: This Agreement is governed by English law.\n\nQUESTION: What did the president say about Michael Jackson?\n=========\nContent: Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. \\n\\nGroups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.\n\nContent: And we won’t stop. \\n\\nWe have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. \\n\\nLet’s use this moment to reset. Let’s stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease. \\n\\nLet’s stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans. \\n\\nWe can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. \\n\\nI recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. \\n\\nThey were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. \\n\\nOfficer Mora was 27 years old. \\n\\nOfficer Rivera was 22. \\n\\nBoth Dominican Americans who’d grown up on the same streets they later chose to patrol as police officers. \\n\\nI spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves.\n\nContent: And a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \\n\\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world. \\n\\nAnd I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. \\n\\nTonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world. \\n\\nAmerica will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies. \\n\\nThese steps will help blunt gas prices here at home. And I know the news about what’s happening can seem alarming. \\n\\nBut I want you to know that we are going to be okay.\n\nContent: More support for patients and families. \\n\\nTo get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. \\n\\nIt’s based on DARPA—the Defense Department project that led to the Internet, GPS, and so much more. \\n\\nARPA-H will have a singular purpose—to drive breakthroughs in cancer, Alzheimer’s, diabetes, and more. \\n\\nA unity agenda for the nation. \\n\\nWe can do this. \\n\\nMy fellow Americans—tonight , we have gathered in a sacred space—the citadel of our democracy. \\n\\nIn this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation.\n=========\nFINAL ANSWER: The president did not mention Michael Jackson.\n\nQUESTION: {question}\n=========\n{summaries}\n=========\nFINAL ANSWER:`;\nexport const COMBINE_PROMPT =\n /*#__PURE__*/ PromptTemplate.fromTemplate(combine_prompt);\n\nconst system_combine_template = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n----------------\n{summaries}`;\nconst combine_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n system_combine_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_COMBINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(combine_messages);\n\nexport const COMBINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(COMBINE_PROMPT, [\n [isChatModel, CHAT_COMBINE_PROMPT],\n ]);\n"],"mappings":";;;;;AAWA,MAAM,cAAc,CAAC;;;;sBAIC,CAAC;AACvB,MAAa,4CAEXA,wCAAe,aAAa,YAAY;AAE1C,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACDC,qDAA4B,aAAa,gBAAgB,kBACzDC,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAM,iCAA+BC,4CAAmB,aAAa,SAAS;AAE9E,MAAa,6CACG,IAAIC,6DAA0B,2BAA2B,CACrE,CAACC,gDAAa,cAAe,CAC9B;AAEH,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BX,CAAC;AACd,MAAa,iCACGL,wCAAe,aAAa,eAAe;AAE3D,MAAM,0BAA0B,CAAC;;;WAGtB,CAAC;AACZ,MAAM,mBAAmB,iBACTC,qDAA4B,aACxC,wBACD,kBACaC,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAM,sCACUC,4CAAmB,aAAa,iBAAiB;AAEjE,MAAa,0CACG,IAAIC,6DAA0B,gBAAgB,CAC1D,CAACC,gDAAa,mBAAoB,CACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"map_reduce_prompts.js","names":[],"sources":["../../../src/chains/question_answering/map_reduce_prompts.ts"],"sourcesContent":["/* eslint-disable spaced-comment */\nimport {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nconst qa_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n{context}\nQuestion: {question}\nRelevant text, if any:`;\nexport const DEFAULT_COMBINE_QA_PROMPT =\n /*#__PURE__*/\n PromptTemplate.fromTemplate(qa_template);\n\nconst system_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_QA_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const COMBINE_QA_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_COMBINE_QA_PROMPT, [\n [isChatModel, CHAT_QA_PROMPT],\n ]);\n\nconst combine_prompt = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n\nQUESTION: Which state/country's law governs the interpretation of the contract?\n=========\nContent: This Agreement is governed by English law and the parties submit to the exclusive jurisdiction of the English courts in relation to any dispute (contractual or non-contractual) concerning this Agreement save that either party may apply to any court for an injunction or other relief to protect its Intellectual Property Rights.\n\nContent: No Waiver. Failure or delay in exercising any right or remedy under this Agreement shall not constitute a waiver of such (or any other) right or remedy.\\n\\n11.7 Severability. The invalidity, illegality or unenforceability of any term (or part of a term) of this Agreement shall not affect the continuation in force of the remainder of the term (if any) and this Agreement.\\n\\n11.8 No Agency. Except as expressly stated otherwise, nothing in this Agreement shall create an agency, partnership or joint venture of any kind between the parties.\\n\\n11.9 No Third-Party Beneficiaries.\n\nContent: (b) if Google believes, in good faith, that the Distributor has violated or caused Google to violate any Anti-Bribery Laws (as defined in Clause 8.5) or that such a violation is reasonably likely to occur,\n=========\nFINAL ANSWER: This Agreement is governed by English law.\n\nQUESTION: What did the president say about Michael Jackson?\n=========\nContent: Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. \\n\\nGroups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.\n\nContent: And we won’t stop. \\n\\nWe have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. \\n\\nLet’s use this moment to reset. Let’s stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease. \\n\\nLet’s stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans. \\n\\nWe can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. \\n\\nI recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. \\n\\nThey were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. \\n\\nOfficer Mora was 27 years old. \\n\\nOfficer Rivera was 22. \\n\\nBoth Dominican Americans who’d grown up on the same streets they later chose to patrol as police officers. \\n\\nI spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves.\n\nContent: And a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \\n\\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world. \\n\\nAnd I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. \\n\\nTonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world. \\n\\nAmerica will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies. \\n\\nThese steps will help blunt gas prices here at home. And I know the news about what’s happening can seem alarming. \\n\\nBut I want you to know that we are going to be okay.\n\nContent: More support for patients and families. \\n\\nTo get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. \\n\\nIt’s based on DARPA—the Defense Department project that led to the Internet, GPS, and so much more. \\n\\nARPA-H will have a singular purpose—to drive breakthroughs in cancer, Alzheimer’s, diabetes, and more. \\n\\nA unity agenda for the nation. \\n\\nWe can do this. \\n\\nMy fellow Americans—tonight , we have gathered in a sacred space—the citadel of our democracy. \\n\\nIn this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation.\n=========\nFINAL ANSWER: The president did not mention Michael Jackson.\n\nQUESTION: {question}\n=========\n{summaries}\n=========\nFINAL ANSWER:`;\nexport const COMBINE_PROMPT =\n /*#__PURE__*/ PromptTemplate.fromTemplate(combine_prompt);\n\nconst system_combine_template = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n----------------\n{summaries}`;\nconst combine_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n system_combine_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_COMBINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(combine_messages);\n\nexport const COMBINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(COMBINE_PROMPT, [\n [isChatModel, CHAT_COMBINE_PROMPT],\n ]);\n"],"mappings":";;;;AAYA,MAAM,cAAc,CAAC;;;;sBAIC,CAAC;AACvB,MAAa,4CAEX,eAAe,aAAa,YAAY;AAE1C,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACD,4BAA4B,aAAa,gBAAgB,kBACzD,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAM,iCAA+B,mBAAmB,aAAa,SAAS;AAE9E,MAAa,6CACG,IAAI,0BAA0B,2BAA2B,CACrE,CAAC,aAAa,cAAe,CAC9B;AAEH,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BX,CAAC;AACd,MAAa,iCACG,eAAe,aAAa,eAAe;AAE3D,MAAM,0BAA0B,CAAC;;;WAGtB,CAAC;AACZ,MAAM,mBAAmB,iBACT,4BAA4B,aACxC,wBACD,kBACa,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAM,sCACU,mBAAmB,aAAa,iBAAiB;AAEjE,MAAa,0CACG,IAAI,0BAA0B,gBAAgB,CAC1D,CAAC,aAAa,mBAAoB,CACnC"}
1
+ {"version":3,"file":"map_reduce_prompts.js","names":[],"sources":["../../../src/chains/question_answering/map_reduce_prompts.ts"],"sourcesContent":["import {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nconst qa_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n{context}\nQuestion: {question}\nRelevant text, if any:`;\nexport const DEFAULT_COMBINE_QA_PROMPT =\n /*#__PURE__*/\n PromptTemplate.fromTemplate(qa_template);\n\nconst system_template = `Use the following portion of a long document to see if any of the text is relevant to answer the question. \nReturn any relevant text verbatim.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_QA_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const COMBINE_QA_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_COMBINE_QA_PROMPT, [\n [isChatModel, CHAT_QA_PROMPT],\n ]);\n\nconst combine_prompt = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n\nQUESTION: Which state/country's law governs the interpretation of the contract?\n=========\nContent: This Agreement is governed by English law and the parties submit to the exclusive jurisdiction of the English courts in relation to any dispute (contractual or non-contractual) concerning this Agreement save that either party may apply to any court for an injunction or other relief to protect its Intellectual Property Rights.\n\nContent: No Waiver. Failure or delay in exercising any right or remedy under this Agreement shall not constitute a waiver of such (or any other) right or remedy.\\n\\n11.7 Severability. The invalidity, illegality or unenforceability of any term (or part of a term) of this Agreement shall not affect the continuation in force of the remainder of the term (if any) and this Agreement.\\n\\n11.8 No Agency. Except as expressly stated otherwise, nothing in this Agreement shall create an agency, partnership or joint venture of any kind between the parties.\\n\\n11.9 No Third-Party Beneficiaries.\n\nContent: (b) if Google believes, in good faith, that the Distributor has violated or caused Google to violate any Anti-Bribery Laws (as defined in Clause 8.5) or that such a violation is reasonably likely to occur,\n=========\nFINAL ANSWER: This Agreement is governed by English law.\n\nQUESTION: What did the president say about Michael Jackson?\n=========\nContent: Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. \\n\\nGroups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.\n\nContent: And we won’t stop. \\n\\nWe have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. \\n\\nLet’s use this moment to reset. Let’s stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease. \\n\\nLet’s stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans. \\n\\nWe can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together. \\n\\nI recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. \\n\\nThey were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. \\n\\nOfficer Mora was 27 years old. \\n\\nOfficer Rivera was 22. \\n\\nBoth Dominican Americans who’d grown up on the same streets they later chose to patrol as police officers. \\n\\nI spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves.\n\nContent: And a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \\n\\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world. \\n\\nAnd I’m taking robust action to make sure the pain of our sanctions is targeted at Russia’s economy. And I will use every tool at our disposal to protect American businesses and consumers. \\n\\nTonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world. \\n\\nAmerica will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies. \\n\\nThese steps will help blunt gas prices here at home. And I know the news about what’s happening can seem alarming. \\n\\nBut I want you to know that we are going to be okay.\n\nContent: More support for patients and families. \\n\\nTo get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. \\n\\nIt’s based on DARPA—the Defense Department project that led to the Internet, GPS, and so much more. \\n\\nARPA-H will have a singular purpose—to drive breakthroughs in cancer, Alzheimer’s, diabetes, and more. \\n\\nA unity agenda for the nation. \\n\\nWe can do this. \\n\\nMy fellow Americans—tonight , we have gathered in a sacred space—the citadel of our democracy. \\n\\nIn this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation.\n=========\nFINAL ANSWER: The president did not mention Michael Jackson.\n\nQUESTION: {question}\n=========\n{summaries}\n=========\nFINAL ANSWER:`;\nexport const COMBINE_PROMPT =\n /*#__PURE__*/ PromptTemplate.fromTemplate(combine_prompt);\n\nconst system_combine_template = `Given the following extracted parts of a long document and a question, create a final answer. \nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\n----------------\n{summaries}`;\nconst combine_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n system_combine_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_COMBINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(combine_messages);\n\nexport const COMBINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(COMBINE_PROMPT, [\n [isChatModel, CHAT_COMBINE_PROMPT],\n ]);\n"],"mappings":";;;;AAWA,MAAM,cAAc,CAAC;;;;sBAIC,CAAC;AACvB,MAAa,4CAEX,eAAe,aAAa,YAAY;AAE1C,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACD,4BAA4B,aAAa,gBAAgB,kBACzD,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAM,iCAA+B,mBAAmB,aAAa,SAAS;AAE9E,MAAa,6CACG,IAAI,0BAA0B,2BAA2B,CACrE,CAAC,aAAa,cAAe,CAC9B;AAEH,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BX,CAAC;AACd,MAAa,iCACG,eAAe,aAAa,eAAe;AAE3D,MAAM,0BAA0B,CAAC;;;WAGtB,CAAC;AACZ,MAAM,mBAAmB,iBACT,4BAA4B,aACxC,wBACD,kBACa,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAM,sCACU,mBAAmB,aAAa,iBAAiB;AAEjE,MAAa,0CACG,IAAI,0BAA0B,gBAAgB,CAC1D,CAAC,aAAa,mBAAoB,CACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"refine_prompts.cjs","names":["PromptTemplate","HumanMessagePromptTemplate","AIMessagePromptTemplate","ChatPromptTemplate","ConditionalPromptSelector","isChatModel","SystemMessagePromptTemplate"],"sources":["../../../src/chains/question_answering/refine_prompts.ts"],"sourcesContent":["/* eslint-disable spaced-comment */\nimport {\n PromptTemplate,\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n AIMessagePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_REFINE_PROMPT_TMPL = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\nexport const DEFAULT_REFINE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"question\", \"existing_answer\", \"context\"],\n template: DEFAULT_REFINE_PROMPT_TMPL,\n});\n\nconst refineTemplate = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\n\nconst messages = [\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n /*#__PURE__*/ AIMessagePromptTemplate.fromTemplate(\"{existing_answer}\"),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(refineTemplate),\n];\n\nexport const CHAT_REFINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const REFINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_REFINE_PROMPT, [\n [isChatModel, CHAT_REFINE_PROMPT],\n ]);\n\nexport const DEFAULT_TEXT_QA_PROMPT_TMPL = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer the question: {question}`;\nexport const DEFAULT_TEXT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"context\", \"question\"],\n template: DEFAULT_TEXT_QA_PROMPT_TMPL,\n});\n\nconst chat_qa_prompt_template = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer any questions`;\nconst chat_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n chat_qa_prompt_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nexport const CHAT_QUESTION_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(chat_messages);\nexport const QUESTION_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_TEXT_QA_PROMPT, [\n [isChatModel, CHAT_QUESTION_PROMPT],\n ]);\n"],"mappings":";;;;;AAaA,MAAa,6BAA6B,CAAC;;;;;;;;wDAQa,CAAC;AACzD,MAAa,wCAAsC,IAAIA,wCAAe;CACpE,gBAAgB;EAAC;EAAY;EAAmB;CAAU;CAC1D,UAAU;AACX;AAED,MAAM,iBAAiB,CAAC;;;;;;;;wDAQgC,CAAC;AAEzD,MAAM,WAAW;iBACDC,oDAA2B,aAAa,aAAa;iBACrDC,iDAAwB,aAAa,oBAAoB;iBACzDD,oDAA2B,aAAa,eAAe;AACtE;AAED,MAAa,qCACGE,4CAAmB,aAAa,SAAS;AAEzD,MAAa,yCACG,IAAIC,6DAA0B,uBAAuB,CACjE,CAACC,gDAAa,kBAAmB,CAClC;AAEH,MAAa,8BAA8B,CAAC;;;;qFAIyC,CAAC;AACtF,MAAa,yCAAuC,IAAIL,wCAAe;CACrE,gBAAgB,CAAC,WAAW,UAAW;CACvC,UAAU;AACX;AAED,MAAM,0BAA0B,CAAC;;;;0EAIyC,CAAC;AAC3E,MAAM,gBAAgB,iBACNM,qDAA4B,aACxC,wBACD,kBACaL,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAa,uCACGE,4CAAmB,aAAa,cAAc;AAC9D,MAAa,2CACG,IAAIC,6DAA0B,wBAAwB,CAClE,CAACC,gDAAa,oBAAqB,CACpC"}
1
+ {"version":3,"file":"refine_prompts.cjs","names":["PromptTemplate","HumanMessagePromptTemplate","AIMessagePromptTemplate","ChatPromptTemplate","ConditionalPromptSelector","isChatModel","SystemMessagePromptTemplate"],"sources":["../../../src/chains/question_answering/refine_prompts.ts"],"sourcesContent":["import {\n PromptTemplate,\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n AIMessagePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_REFINE_PROMPT_TMPL = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\nexport const DEFAULT_REFINE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"question\", \"existing_answer\", \"context\"],\n template: DEFAULT_REFINE_PROMPT_TMPL,\n});\n\nconst refineTemplate = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\n\nconst messages = [\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n /*#__PURE__*/ AIMessagePromptTemplate.fromTemplate(\"{existing_answer}\"),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(refineTemplate),\n];\n\nexport const CHAT_REFINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const REFINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_REFINE_PROMPT, [\n [isChatModel, CHAT_REFINE_PROMPT],\n ]);\n\nexport const DEFAULT_TEXT_QA_PROMPT_TMPL = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer the question: {question}`;\nexport const DEFAULT_TEXT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"context\", \"question\"],\n template: DEFAULT_TEXT_QA_PROMPT_TMPL,\n});\n\nconst chat_qa_prompt_template = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer any questions`;\nconst chat_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n chat_qa_prompt_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nexport const CHAT_QUESTION_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(chat_messages);\nexport const QUESTION_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_TEXT_QA_PROMPT, [\n [isChatModel, CHAT_QUESTION_PROMPT],\n ]);\n"],"mappings":";;;;;AAYA,MAAa,6BAA6B,CAAC;;;;;;;;wDAQa,CAAC;AACzD,MAAa,wCAAsC,IAAIA,wCAAe;CACpE,gBAAgB;EAAC;EAAY;EAAmB;CAAU;CAC1D,UAAU;AACX;AAED,MAAM,iBAAiB,CAAC;;;;;;;;wDAQgC,CAAC;AAEzD,MAAM,WAAW;iBACDC,oDAA2B,aAAa,aAAa;iBACrDC,iDAAwB,aAAa,oBAAoB;iBACzDD,oDAA2B,aAAa,eAAe;AACtE;AAED,MAAa,qCACGE,4CAAmB,aAAa,SAAS;AAEzD,MAAa,yCACG,IAAIC,6DAA0B,uBAAuB,CACjE,CAACC,gDAAa,kBAAmB,CAClC;AAEH,MAAa,8BAA8B,CAAC;;;;qFAIyC,CAAC;AACtF,MAAa,yCAAuC,IAAIL,wCAAe;CACrE,gBAAgB,CAAC,WAAW,UAAW;CACvC,UAAU;AACX;AAED,MAAM,0BAA0B,CAAC;;;;0EAIyC,CAAC;AAC3E,MAAM,gBAAgB,iBACNM,qDAA4B,aACxC,wBACD,kBACaL,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAa,uCACGE,4CAAmB,aAAa,cAAc;AAC9D,MAAa,2CACG,IAAIC,6DAA0B,wBAAwB,CAClE,CAACC,gDAAa,oBAAqB,CACpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"refine_prompts.js","names":[],"sources":["../../../src/chains/question_answering/refine_prompts.ts"],"sourcesContent":["/* eslint-disable spaced-comment */\nimport {\n PromptTemplate,\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n AIMessagePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_REFINE_PROMPT_TMPL = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\nexport const DEFAULT_REFINE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"question\", \"existing_answer\", \"context\"],\n template: DEFAULT_REFINE_PROMPT_TMPL,\n});\n\nconst refineTemplate = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\n\nconst messages = [\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n /*#__PURE__*/ AIMessagePromptTemplate.fromTemplate(\"{existing_answer}\"),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(refineTemplate),\n];\n\nexport const CHAT_REFINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const REFINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_REFINE_PROMPT, [\n [isChatModel, CHAT_REFINE_PROMPT],\n ]);\n\nexport const DEFAULT_TEXT_QA_PROMPT_TMPL = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer the question: {question}`;\nexport const DEFAULT_TEXT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"context\", \"question\"],\n template: DEFAULT_TEXT_QA_PROMPT_TMPL,\n});\n\nconst chat_qa_prompt_template = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer any questions`;\nconst chat_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n chat_qa_prompt_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nexport const CHAT_QUESTION_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(chat_messages);\nexport const QUESTION_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_TEXT_QA_PROMPT, [\n [isChatModel, CHAT_QUESTION_PROMPT],\n ]);\n"],"mappings":";;;;AAaA,MAAa,6BAA6B,CAAC;;;;;;;;wDAQa,CAAC;AACzD,MAAa,wCAAsC,IAAI,eAAe;CACpE,gBAAgB;EAAC;EAAY;EAAmB;CAAU;CAC1D,UAAU;AACX;AAED,MAAM,iBAAiB,CAAC;;;;;;;;wDAQgC,CAAC;AAEzD,MAAM,WAAW;iBACD,2BAA2B,aAAa,aAAa;iBACrD,wBAAwB,aAAa,oBAAoB;iBACzD,2BAA2B,aAAa,eAAe;AACtE;AAED,MAAa,qCACG,mBAAmB,aAAa,SAAS;AAEzD,MAAa,yCACG,IAAI,0BAA0B,uBAAuB,CACjE,CAAC,aAAa,kBAAmB,CAClC;AAEH,MAAa,8BAA8B,CAAC;;;;qFAIyC,CAAC;AACtF,MAAa,yCAAuC,IAAI,eAAe;CACrE,gBAAgB,CAAC,WAAW,UAAW;CACvC,UAAU;AACX;AAED,MAAM,0BAA0B,CAAC;;;;0EAIyC,CAAC;AAC3E,MAAM,gBAAgB,iBACN,4BAA4B,aACxC,wBACD,kBACa,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAa,uCACG,mBAAmB,aAAa,cAAc;AAC9D,MAAa,2CACG,IAAI,0BAA0B,wBAAwB,CAClE,CAAC,aAAa,oBAAqB,CACpC"}
1
+ {"version":3,"file":"refine_prompts.js","names":[],"sources":["../../../src/chains/question_answering/refine_prompts.ts"],"sourcesContent":["import {\n PromptTemplate,\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n AIMessagePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_REFINE_PROMPT_TMPL = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\nexport const DEFAULT_REFINE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"question\", \"existing_answer\", \"context\"],\n template: DEFAULT_REFINE_PROMPT_TMPL,\n});\n\nconst refineTemplate = `The original question is as follows: {question}\nWe have provided an existing answer: {existing_answer}\nWe have the opportunity to refine the existing answer\n(only if needed) with some more context below.\n------------\n{context}\n------------\nGiven the new context, refine the original answer to better answer the question. \nIf the context isn't useful, return the original answer.`;\n\nconst messages = [\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n /*#__PURE__*/ AIMessagePromptTemplate.fromTemplate(\"{existing_answer}\"),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(refineTemplate),\n];\n\nexport const CHAT_REFINE_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const REFINE_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_REFINE_PROMPT, [\n [isChatModel, CHAT_REFINE_PROMPT],\n ]);\n\nexport const DEFAULT_TEXT_QA_PROMPT_TMPL = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer the question: {question}`;\nexport const DEFAULT_TEXT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"context\", \"question\"],\n template: DEFAULT_TEXT_QA_PROMPT_TMPL,\n});\n\nconst chat_qa_prompt_template = `Context information is below. \n---------------------\n{context}\n---------------------\nGiven the context information and no prior knowledge, answer any questions`;\nconst chat_messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(\n chat_qa_prompt_template\n ),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nexport const CHAT_QUESTION_PROMPT =\n /*#__PURE__*/ ChatPromptTemplate.fromMessages(chat_messages);\nexport const QUESTION_PROMPT_SELECTOR =\n /*#__PURE__*/ new ConditionalPromptSelector(DEFAULT_TEXT_QA_PROMPT, [\n [isChatModel, CHAT_QUESTION_PROMPT],\n ]);\n"],"mappings":";;;;AAYA,MAAa,6BAA6B,CAAC;;;;;;;;wDAQa,CAAC;AACzD,MAAa,wCAAsC,IAAI,eAAe;CACpE,gBAAgB;EAAC;EAAY;EAAmB;CAAU;CAC1D,UAAU;AACX;AAED,MAAM,iBAAiB,CAAC;;;;;;;;wDAQgC,CAAC;AAEzD,MAAM,WAAW;iBACD,2BAA2B,aAAa,aAAa;iBACrD,wBAAwB,aAAa,oBAAoB;iBACzD,2BAA2B,aAAa,eAAe;AACtE;AAED,MAAa,qCACG,mBAAmB,aAAa,SAAS;AAEzD,MAAa,yCACG,IAAI,0BAA0B,uBAAuB,CACjE,CAAC,aAAa,kBAAmB,CAClC;AAEH,MAAa,8BAA8B,CAAC;;;;qFAIyC,CAAC;AACtF,MAAa,yCAAuC,IAAI,eAAe;CACrE,gBAAgB,CAAC,WAAW,UAAW;CACvC,UAAU;AACX;AAED,MAAM,0BAA0B,CAAC;;;;0EAIyC,CAAC;AAC3E,MAAM,gBAAgB,iBACN,4BAA4B,aACxC,wBACD,kBACa,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAa,uCACG,mBAAmB,aAAa,cAAc;AAC9D,MAAa,2CACG,IAAI,0BAA0B,wBAAwB,CAClE,CAAC,aAAa,oBAAqB,CACpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"stuff_prompts.cjs","names":["PromptTemplate","SystemMessagePromptTemplate","HumanMessagePromptTemplate","ChatPromptTemplate","ConditionalPromptSelector","isChatModel"],"sources":["../../../src/chains/question_answering/stuff_prompts.ts"],"sourcesContent":["/* eslint-disable spaced-comment */\nimport {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template:\n \"Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.\\n\\n{context}\\n\\nQuestion: {question}\\nHelpful Answer:\",\n inputVariables: [\"context\", \"question\"],\n});\n\nconst system_template = `Use the following pieces of context to answer the users question. \nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const QA_PROMPT_SELECTOR = /*#__PURE__*/ new ConditionalPromptSelector(\n DEFAULT_QA_PROMPT,\n [[isChatModel, CHAT_PROMPT]]\n);\n"],"mappings":";;;;;AAYA,MAAa,oCAAkC,IAAIA,wCAAe;CAChE,UACE;CACF,gBAAgB,CAAC,WAAW,UAAW;AACxC;AAED,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACDC,qDAA4B,aAAa,gBAAgB,kBACzDC,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAM,8BAA4BC,4CAAmB,aAAa,SAAS;AAE3E,MAAa,qCAAmC,IAAIC,6DAClD,mBACA,CAAC,CAACC,gDAAa,WAAY,CAAC"}
1
+ {"version":3,"file":"stuff_prompts.cjs","names":["PromptTemplate","SystemMessagePromptTemplate","HumanMessagePromptTemplate","ChatPromptTemplate","ConditionalPromptSelector","isChatModel"],"sources":["../../../src/chains/question_answering/stuff_prompts.ts"],"sourcesContent":["import {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template:\n \"Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.\\n\\n{context}\\n\\nQuestion: {question}\\nHelpful Answer:\",\n inputVariables: [\"context\", \"question\"],\n});\n\nconst system_template = `Use the following pieces of context to answer the users question. \nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const QA_PROMPT_SELECTOR = /*#__PURE__*/ new ConditionalPromptSelector(\n DEFAULT_QA_PROMPT,\n [[isChatModel, CHAT_PROMPT]]\n);\n"],"mappings":";;;;;AAWA,MAAa,oCAAkC,IAAIA,wCAAe;CAChE,UACE;CACF,gBAAgB,CAAC,WAAW,UAAW;AACxC;AAED,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACDC,qDAA4B,aAAa,gBAAgB,kBACzDC,oDAA2B,aAAa,aAAa,AACpE;AACD,MAAM,8BAA4BC,4CAAmB,aAAa,SAAS;AAE3E,MAAa,qCAAmC,IAAIC,6DAClD,mBACA,CAAC,CAACC,gDAAa,WAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"stuff_prompts.js","names":[],"sources":["../../../src/chains/question_answering/stuff_prompts.ts"],"sourcesContent":["/* eslint-disable spaced-comment */\nimport {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template:\n \"Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.\\n\\n{context}\\n\\nQuestion: {question}\\nHelpful Answer:\",\n inputVariables: [\"context\", \"question\"],\n});\n\nconst system_template = `Use the following pieces of context to answer the users question. \nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const QA_PROMPT_SELECTOR = /*#__PURE__*/ new ConditionalPromptSelector(\n DEFAULT_QA_PROMPT,\n [[isChatModel, CHAT_PROMPT]]\n);\n"],"mappings":";;;;AAYA,MAAa,oCAAkC,IAAI,eAAe;CAChE,UACE;CACF,gBAAgB,CAAC,WAAW,UAAW;AACxC;AAED,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACD,4BAA4B,aAAa,gBAAgB,kBACzD,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAM,8BAA4B,mBAAmB,aAAa,SAAS;AAE3E,MAAa,qCAAmC,IAAI,0BAClD,mBACA,CAAC,CAAC,aAAa,WAAY,CAAC"}
1
+ {"version":3,"file":"stuff_prompts.js","names":[],"sources":["../../../src/chains/question_answering/stuff_prompts.ts"],"sourcesContent":["import {\n ChatPromptTemplate,\n SystemMessagePromptTemplate,\n HumanMessagePromptTemplate,\n PromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n ConditionalPromptSelector,\n isChatModel,\n} from \"@langchain/core/example_selectors\";\n\nexport const DEFAULT_QA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template:\n \"Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.\\n\\n{context}\\n\\nQuestion: {question}\\nHelpful Answer:\",\n inputVariables: [\"context\", \"question\"],\n});\n\nconst system_template = `Use the following pieces of context to answer the users question. \nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n{context}`;\nconst messages = [\n /*#__PURE__*/ SystemMessagePromptTemplate.fromTemplate(system_template),\n /*#__PURE__*/ HumanMessagePromptTemplate.fromTemplate(\"{question}\"),\n];\nconst CHAT_PROMPT = /*#__PURE__*/ ChatPromptTemplate.fromMessages(messages);\n\nexport const QA_PROMPT_SELECTOR = /*#__PURE__*/ new ConditionalPromptSelector(\n DEFAULT_QA_PROMPT,\n [[isChatModel, CHAT_PROMPT]]\n);\n"],"mappings":";;;;AAWA,MAAa,oCAAkC,IAAI,eAAe;CAChE,UACE;CACF,gBAAgB,CAAC,WAAW,UAAW;AACxC;AAED,MAAM,kBAAkB,CAAC;;;SAGhB,CAAC;AACV,MAAM,WAAW,iBACD,4BAA4B,aAAa,gBAAgB,kBACzD,2BAA2B,aAAa,aAAa,AACpE;AACD,MAAM,8BAA4B,mBAAmB,aAAa,SAAS;AAE3E,MAAa,qCAAmC,IAAI,0BAClD,mBACA,CAAC,CAAC,aAAa,WAAY,CAAC"}
@@ -1,6 +1,6 @@
1
+ import { BaseMessage } from "@langchain/core/messages";
1
2
  import { Runnable, RunnableInterface } from "@langchain/core/runnables";
2
3
  import { Document, DocumentInterface } from "@langchain/core/documents";
3
- import { BaseMessage } from "@langchain/core/messages";
4
4
  import { BaseRetrieverInterface } from "@langchain/core/retrievers";
5
5
 
6
6
  //#region src/chains/retrieval.d.ts
@@ -2,8 +2,8 @@ import { ChainInputs } from "../base.cjs";
2
2
  import { LLMChain } from "../llm_chain.cjs";
3
3
  import { RouterChain } from "./multi_route.cjs";
4
4
  import { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
5
- import { BasePromptTemplate } from "@langchain/core/prompts";
6
5
  import { ChainValues } from "@langchain/core/utils/types";
6
+ import { BasePromptTemplate } from "@langchain/core/prompts";
7
7
  import { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
8
8
 
9
9
  //#region src/chains/router/llm_router.d.ts
@@ -6,8 +6,8 @@ const require_llm_router = require('./llm_router.cjs');
6
6
  const require_multi_prompt_prompt = require('./multi_prompt_prompt.cjs');
7
7
  const require_utils = require('./utils.cjs');
8
8
  const require_router = require('../../output_parsers/router.cjs');
9
+ const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
9
10
  const __langchain_core_prompts = require_rolldown_runtime.__toESM(require("@langchain/core/prompts"));
10
- const zod = require_rolldown_runtime.__toESM(require("zod"));
11
11
 
12
12
  //#region src/chains/router/multi_prompt.ts
13
13
  /**
@@ -66,9 +66,9 @@ var MultiPromptChain = class MultiPromptChain extends require_multi_route.MultiR
66
66
  */
67
67
  static fromLLMAndPrompts(llm, { promptNames, promptDescriptions, promptTemplates, defaultChain, llmChainOpts, conversationChainOpts, multiRouteChainOpts }) {
68
68
  const destinations = require_utils.zipEntries(promptNames, promptDescriptions).map(([name, desc]) => `${name}: ${desc}`);
69
- const structuredOutputParserSchema = zod.z.object({
70
- destination: zod.z.string().optional().describe("name of the question answering system to use or \"DEFAULT\""),
71
- next_inputs: zod.z.object({ input: zod.z.string().describe("a potentially modified version of the original input") }).describe("input to be fed to the next model")
69
+ const structuredOutputParserSchema = zod_v3.z.object({
70
+ destination: zod_v3.z.string().optional().describe("name of the question answering system to use or \"DEFAULT\""),
71
+ next_inputs: zod_v3.z.object({ input: zod_v3.z.string().describe("a potentially modified version of the original input") }).describe("input to be fed to the next model")
72
72
  });
73
73
  const outputParser = new require_router.RouterOutputParser(structuredOutputParserSchema);
74
74
  const destinationsStr = destinations.join("\n");
@@ -1 +1 @@
1
- {"version":3,"file":"multi_prompt.cjs","names":["MultiRouteChain","llm: BaseLanguageModelInterface","promptNames: string[]","promptDescriptions: string[]","promptTemplates: string[] | PromptTemplate[]","defaultChain?: BaseChain","options?: Omit<MultiRouteChainInput, \"defaultChain\">","zipEntries","z","RouterOutputParser","STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE","PromptTemplate","LLMRouterChain","myPrompt: string | PromptTemplate","LLMChain","ConversationChain"],"sources":["../../../src/chains/router/multi_prompt.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { z } from \"zod\";\nimport { interpolateFString, PromptTemplate } from \"@langchain/core/prompts\";\nimport { MultiRouteChain, MultiRouteChainInput } from \"./multi_route.js\";\nimport { STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE } from \"./multi_prompt_prompt.js\";\nimport { BaseChain } from \"../../chains/base.js\";\nimport { LLMChain, LLMChainInput } from \"../../chains/llm_chain.js\";\nimport { LLMRouterChain } from \"./llm_router.js\";\nimport { ConversationChain } from \"../../chains/conversation.js\";\nimport { zipEntries } from \"./utils.js\";\nimport { RouterOutputParser } from \"../../output_parsers/router.js\";\n\n/**\n * A class that represents a multi-prompt chain in the LangChain\n * framework. It extends the MultiRouteChain class and provides additional\n * functionality specific to multi-prompt chains.\n * @example\n * ```typescript\n * const multiPromptChain = MultiPromptChain.fromLLMAndPrompts(\n * new ChatOpenAI({ model: \"gpt-4o-mini\" }),\n * {\n * promptNames: [\"physics\", \"math\", \"history\"],\n * promptDescriptions: [\n * \"Good for answering questions about physics\",\n * \"Good for answering math questions\",\n * \"Good for answering questions about history\",\n * ],\n * promptTemplates: [\n * `You are a very smart physics professor. Here is a question:\\n{input}\\n`,\n * `You are a very good mathematician. Here is a question:\\n{input}\\n`,\n * `You are a very smart history professor. Here is a question:\\n{input}\\n`,\n * ],\n * }\n * );\n * const result = await multiPromptChain.call({\n * input: \"What is the speed of light?\",\n * });\n * ```\n */\nexport class MultiPromptChain extends MultiRouteChain {\n /**\n * @deprecated Use `fromLLMAndPrompts` instead\n */\n static fromPrompts(\n llm: BaseLanguageModelInterface,\n promptNames: string[],\n promptDescriptions: string[],\n promptTemplates: string[] | PromptTemplate[],\n defaultChain?: BaseChain,\n options?: Omit<MultiRouteChainInput, \"defaultChain\">\n ) {\n return MultiPromptChain.fromLLMAndPrompts(llm, {\n promptNames,\n promptDescriptions,\n promptTemplates,\n defaultChain,\n multiRouteChainOpts: options,\n });\n }\n\n /**\n * A static method that creates an instance of MultiPromptChain from a\n * BaseLanguageModel and a set of prompts. It takes in optional parameters\n * for the default chain and additional options.\n * @param llm A BaseLanguageModel instance.\n * @param promptNames An array of prompt names.\n * @param promptDescriptions An array of prompt descriptions.\n * @param promptTemplates An array of prompt templates.\n * @param defaultChain An optional BaseChain instance to be used as the default chain.\n * @param llmChainOpts Optional parameters for the LLMChainInput, excluding 'llm' and 'prompt'.\n * @param conversationChainOpts Optional parameters for the LLMChainInput, excluding 'llm' and 'outputKey'.\n * @param multiRouteChainOpts Optional parameters for the MultiRouteChainInput, excluding 'defaultChain'.\n * @returns An instance of MultiPromptChain.\n */\n static fromLLMAndPrompts(\n llm: BaseLanguageModelInterface,\n {\n promptNames,\n promptDescriptions,\n promptTemplates,\n defaultChain,\n llmChainOpts,\n conversationChainOpts,\n multiRouteChainOpts,\n }: {\n promptNames: string[];\n promptDescriptions: string[];\n promptTemplates: string[] | PromptTemplate[];\n defaultChain?: BaseChain;\n llmChainOpts?: Omit<LLMChainInput, \"llm\" | \"prompt\">;\n conversationChainOpts?: Omit<LLMChainInput, \"llm\" | \"outputKey\">;\n multiRouteChainOpts?: Omit<MultiRouteChainInput, \"defaultChain\">;\n }\n ): MultiPromptChain {\n const destinations = zipEntries(promptNames, promptDescriptions).map(\n ([name, desc]) => `${name}: ${desc}`\n );\n\n const structuredOutputParserSchema = z.object({\n destination: z\n .string()\n .optional()\n .describe('name of the question answering system to use or \"DEFAULT\"'),\n next_inputs: z\n .object({\n input: z\n .string()\n .describe(\"a potentially modified version of the original input\"),\n })\n .describe(\"input to be fed to the next model\"),\n });\n\n const outputParser = new RouterOutputParser(structuredOutputParserSchema);\n\n const destinationsStr = destinations.join(\"\\n\");\n const routerTemplate = interpolateFString(\n STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE(\n outputParser.getFormatInstructions({ interpolationDepth: 4 })\n ),\n {\n destinations: destinationsStr,\n }\n );\n\n const routerPrompt = new PromptTemplate({\n template: routerTemplate,\n inputVariables: [\"input\"],\n outputParser,\n });\n\n const routerChain = LLMRouterChain.fromLLM(llm, routerPrompt);\n const destinationChains = zipEntries<[string, string | PromptTemplate]>(\n promptNames,\n promptTemplates\n ).reduce((acc, [name, template]) => {\n let myPrompt: string | PromptTemplate;\n if (typeof template === \"object\") {\n myPrompt = template;\n } else if (typeof template === \"string\") {\n myPrompt = new PromptTemplate({\n template: template as string,\n inputVariables: [\"input\"],\n });\n } else {\n throw new Error(\"Invalid prompt template\");\n }\n acc[name as string] = new LLMChain({\n ...llmChainOpts,\n llm,\n prompt: myPrompt,\n });\n return acc;\n }, {} as { [name: string]: LLMChain });\n\n const convChain = new ConversationChain({\n ...conversationChainOpts,\n llm,\n outputKey: \"text\",\n });\n\n return new MultiPromptChain({\n ...multiRouteChainOpts,\n routerChain,\n destinationChains,\n defaultChain: defaultChain ?? convChain,\n });\n }\n\n _chainType(): string {\n return \"multi_prompt_chain\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,mBAAb,MAAa,yBAAyBA,oCAAgB;;;;CAIpD,OAAO,YACLC,KACAC,aACAC,oBACAC,iBACAC,cACAC,SACA;AACA,SAAO,iBAAiB,kBAAkB,KAAK;GAC7C;GACA;GACA;GACA;GACA,qBAAqB;EACtB,EAAC;CACH;;;;;;;;;;;;;;;CAgBD,OAAO,kBACLL,KACA,EACE,aACA,oBACA,iBACA,cACA,cACA,uBACA,qBASD,EACiB;EAClB,MAAM,eAAeM,yBAAW,aAAa,mBAAmB,CAAC,IAC/D,CAAC,CAAC,MAAM,KAAK,KAAK,GAAG,KAAK,EAAE,EAAE,MAAM,CACrC;EAED,MAAM,+BAA+BC,MAAE,OAAO;GAC5C,aAAaA,MACV,QAAQ,CACR,UAAU,CACV,SAAS,8DAA4D;GACxE,aAAaA,MACV,OAAO,EACN,OAAOA,MACJ,QAAQ,CACR,SAAS,uDAAuD,CACpE,EAAC,CACD,SAAS,oCAAoC;EACjD,EAAC;EAEF,MAAM,eAAe,IAAIC,kCAAmB;EAE5C,MAAM,kBAAkB,aAAa,KAAK,KAAK;EAC/C,MAAM,kEACJC,oEACE,aAAa,sBAAsB,EAAE,oBAAoB,EAAG,EAAC,CAC9D,EACD,EACE,cAAc,gBACf,EACF;EAED,MAAM,eAAe,IAAIC,wCAAe;GACtC,UAAU;GACV,gBAAgB,CAAC,OAAQ;GACzB;EACD;EAED,MAAM,cAAcC,kCAAe,QAAQ,KAAK,aAAa;EAC7D,MAAM,oBAAoBL,yBACxB,aACA,gBACD,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,SAAS,KAAK;GAClC,IAAIM;AACJ,OAAI,OAAO,aAAa,UACtB,WAAW;YACF,OAAO,aAAa,UAC7B,WAAW,IAAIF,wCAAe;IAClB;IACV,gBAAgB,CAAC,OAAQ;GAC1B;OAED,OAAM,IAAI,MAAM;GAElB,IAAI,QAAkB,IAAIG,2BAAS;IACjC,GAAG;IACH;IACA,QAAQ;GACT;AACD,UAAO;EACR,GAAE,CAAE,EAAiC;EAEtC,MAAM,YAAY,IAAIC,uCAAkB;GACtC,GAAG;GACH;GACA,WAAW;EACZ;AAED,SAAO,IAAI,iBAAiB;GAC1B,GAAG;GACH;GACA;GACA,cAAc,gBAAgB;EAC/B;CACF;CAED,aAAqB;AACnB,SAAO;CACR;AACF"}
1
+ {"version":3,"file":"multi_prompt.cjs","names":["MultiRouteChain","llm: BaseLanguageModelInterface","promptNames: string[]","promptDescriptions: string[]","promptTemplates: string[] | PromptTemplate[]","defaultChain?: BaseChain","options?: Omit<MultiRouteChainInput, \"defaultChain\">","zipEntries","z","RouterOutputParser","STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE","PromptTemplate","LLMRouterChain","myPrompt: string | PromptTemplate","LLMChain","ConversationChain"],"sources":["../../../src/chains/router/multi_prompt.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { z } from \"zod/v3\";\nimport { interpolateFString, PromptTemplate } from \"@langchain/core/prompts\";\nimport { MultiRouteChain, MultiRouteChainInput } from \"./multi_route.js\";\nimport { STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE } from \"./multi_prompt_prompt.js\";\nimport { BaseChain } from \"../../chains/base.js\";\nimport { LLMChain, LLMChainInput } from \"../../chains/llm_chain.js\";\nimport { LLMRouterChain } from \"./llm_router.js\";\nimport { ConversationChain } from \"../../chains/conversation.js\";\nimport { zipEntries } from \"./utils.js\";\nimport { RouterOutputParser } from \"../../output_parsers/router.js\";\n\n/**\n * A class that represents a multi-prompt chain in the LangChain\n * framework. It extends the MultiRouteChain class and provides additional\n * functionality specific to multi-prompt chains.\n * @example\n * ```typescript\n * const multiPromptChain = MultiPromptChain.fromLLMAndPrompts(\n * new ChatOpenAI({ model: \"gpt-4o-mini\" }),\n * {\n * promptNames: [\"physics\", \"math\", \"history\"],\n * promptDescriptions: [\n * \"Good for answering questions about physics\",\n * \"Good for answering math questions\",\n * \"Good for answering questions about history\",\n * ],\n * promptTemplates: [\n * `You are a very smart physics professor. Here is a question:\\n{input}\\n`,\n * `You are a very good mathematician. Here is a question:\\n{input}\\n`,\n * `You are a very smart history professor. Here is a question:\\n{input}\\n`,\n * ],\n * }\n * );\n * const result = await multiPromptChain.call({\n * input: \"What is the speed of light?\",\n * });\n * ```\n */\nexport class MultiPromptChain extends MultiRouteChain {\n /**\n * @deprecated Use `fromLLMAndPrompts` instead\n */\n static fromPrompts(\n llm: BaseLanguageModelInterface,\n promptNames: string[],\n promptDescriptions: string[],\n promptTemplates: string[] | PromptTemplate[],\n defaultChain?: BaseChain,\n options?: Omit<MultiRouteChainInput, \"defaultChain\">\n ) {\n return MultiPromptChain.fromLLMAndPrompts(llm, {\n promptNames,\n promptDescriptions,\n promptTemplates,\n defaultChain,\n multiRouteChainOpts: options,\n });\n }\n\n /**\n * A static method that creates an instance of MultiPromptChain from a\n * BaseLanguageModel and a set of prompts. It takes in optional parameters\n * for the default chain and additional options.\n * @param llm A BaseLanguageModel instance.\n * @param promptNames An array of prompt names.\n * @param promptDescriptions An array of prompt descriptions.\n * @param promptTemplates An array of prompt templates.\n * @param defaultChain An optional BaseChain instance to be used as the default chain.\n * @param llmChainOpts Optional parameters for the LLMChainInput, excluding 'llm' and 'prompt'.\n * @param conversationChainOpts Optional parameters for the LLMChainInput, excluding 'llm' and 'outputKey'.\n * @param multiRouteChainOpts Optional parameters for the MultiRouteChainInput, excluding 'defaultChain'.\n * @returns An instance of MultiPromptChain.\n */\n static fromLLMAndPrompts(\n llm: BaseLanguageModelInterface,\n {\n promptNames,\n promptDescriptions,\n promptTemplates,\n defaultChain,\n llmChainOpts,\n conversationChainOpts,\n multiRouteChainOpts,\n }: {\n promptNames: string[];\n promptDescriptions: string[];\n promptTemplates: string[] | PromptTemplate[];\n defaultChain?: BaseChain;\n llmChainOpts?: Omit<LLMChainInput, \"llm\" | \"prompt\">;\n conversationChainOpts?: Omit<LLMChainInput, \"llm\" | \"outputKey\">;\n multiRouteChainOpts?: Omit<MultiRouteChainInput, \"defaultChain\">;\n }\n ): MultiPromptChain {\n const destinations = zipEntries(promptNames, promptDescriptions).map(\n ([name, desc]) => `${name}: ${desc}`\n );\n\n const structuredOutputParserSchema = z.object({\n destination: z\n .string()\n .optional()\n .describe('name of the question answering system to use or \"DEFAULT\"'),\n next_inputs: z\n .object({\n input: z\n .string()\n .describe(\"a potentially modified version of the original input\"),\n })\n .describe(\"input to be fed to the next model\"),\n });\n\n const outputParser = new RouterOutputParser(structuredOutputParserSchema);\n\n const destinationsStr = destinations.join(\"\\n\");\n const routerTemplate = interpolateFString(\n STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE(\n outputParser.getFormatInstructions({ interpolationDepth: 4 })\n ),\n {\n destinations: destinationsStr,\n }\n );\n\n const routerPrompt = new PromptTemplate({\n template: routerTemplate,\n inputVariables: [\"input\"],\n outputParser,\n });\n\n const routerChain = LLMRouterChain.fromLLM(llm, routerPrompt);\n const destinationChains = zipEntries<[string, string | PromptTemplate]>(\n promptNames,\n promptTemplates\n ).reduce((acc, [name, template]) => {\n let myPrompt: string | PromptTemplate;\n if (typeof template === \"object\") {\n myPrompt = template;\n } else if (typeof template === \"string\") {\n myPrompt = new PromptTemplate({\n template: template as string,\n inputVariables: [\"input\"],\n });\n } else {\n throw new Error(\"Invalid prompt template\");\n }\n acc[name as string] = new LLMChain({\n ...llmChainOpts,\n llm,\n prompt: myPrompt,\n });\n return acc;\n }, {} as { [name: string]: LLMChain });\n\n const convChain = new ConversationChain({\n ...conversationChainOpts,\n llm,\n outputKey: \"text\",\n });\n\n return new MultiPromptChain({\n ...multiRouteChainOpts,\n routerChain,\n destinationChains,\n defaultChain: defaultChain ?? convChain,\n });\n }\n\n _chainType(): string {\n return \"multi_prompt_chain\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,mBAAb,MAAa,yBAAyBA,oCAAgB;;;;CAIpD,OAAO,YACLC,KACAC,aACAC,oBACAC,iBACAC,cACAC,SACA;AACA,SAAO,iBAAiB,kBAAkB,KAAK;GAC7C;GACA;GACA;GACA;GACA,qBAAqB;EACtB,EAAC;CACH;;;;;;;;;;;;;;;CAgBD,OAAO,kBACLL,KACA,EACE,aACA,oBACA,iBACA,cACA,cACA,uBACA,qBASD,EACiB;EAClB,MAAM,eAAeM,yBAAW,aAAa,mBAAmB,CAAC,IAC/D,CAAC,CAAC,MAAM,KAAK,KAAK,GAAG,KAAK,EAAE,EAAE,MAAM,CACrC;EAED,MAAM,+BAA+BC,SAAE,OAAO;GAC5C,aAAaA,SACV,QAAQ,CACR,UAAU,CACV,SAAS,8DAA4D;GACxE,aAAaA,SACV,OAAO,EACN,OAAOA,SACJ,QAAQ,CACR,SAAS,uDAAuD,CACpE,EAAC,CACD,SAAS,oCAAoC;EACjD,EAAC;EAEF,MAAM,eAAe,IAAIC,kCAAmB;EAE5C,MAAM,kBAAkB,aAAa,KAAK,KAAK;EAC/C,MAAM,kEACJC,oEACE,aAAa,sBAAsB,EAAE,oBAAoB,EAAG,EAAC,CAC9D,EACD,EACE,cAAc,gBACf,EACF;EAED,MAAM,eAAe,IAAIC,wCAAe;GACtC,UAAU;GACV,gBAAgB,CAAC,OAAQ;GACzB;EACD;EAED,MAAM,cAAcC,kCAAe,QAAQ,KAAK,aAAa;EAC7D,MAAM,oBAAoBL,yBACxB,aACA,gBACD,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,SAAS,KAAK;GAClC,IAAIM;AACJ,OAAI,OAAO,aAAa,UACtB,WAAW;YACF,OAAO,aAAa,UAC7B,WAAW,IAAIF,wCAAe;IAClB;IACV,gBAAgB,CAAC,OAAQ;GAC1B;OAED,OAAM,IAAI,MAAM;GAElB,IAAI,QAAkB,IAAIG,2BAAS;IACjC,GAAG;IACH;IACA,QAAQ;GACT;AACD,UAAO;EACR,GAAE,CAAE,EAAiC;EAEtC,MAAM,YAAY,IAAIC,uCAAkB;GACtC,GAAG;GACH;GACA,WAAW;EACZ;AAED,SAAO,IAAI,iBAAiB;GAC1B,GAAG;GACH;GACA;GACA,cAAc,gBAAgB;EAC/B;CACF;CAED,aAAqB;AACnB,SAAO;CACR;AACF"}
@@ -5,8 +5,8 @@ import { LLMRouterChain } from "./llm_router.js";
5
5
  import { STRUCTURED_MULTI_PROMPT_ROUTER_TEMPLATE } from "./multi_prompt_prompt.js";
6
6
  import { zipEntries } from "./utils.js";
7
7
  import { RouterOutputParser } from "../../output_parsers/router.js";
8
+ import { z } from "zod/v3";
8
9
  import { PromptTemplate, interpolateFString } from "@langchain/core/prompts";
9
- import { z } from "zod";
10
10
 
11
11
  //#region src/chains/router/multi_prompt.ts
12
12
  /**