@langchain/core 1.2.13 → 1.2.16

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 (718) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/agents.d.cts +3 -4
  3. package/dist/agents.d.cts.map +1 -1
  4. package/dist/agents.d.ts +3 -4
  5. package/dist/agents.d.ts.map +1 -1
  6. package/dist/caches/index.d.cts +5 -6
  7. package/dist/caches/index.d.cts.map +1 -1
  8. package/dist/caches/index.d.ts +5 -6
  9. package/dist/caches/index.d.ts.map +1 -1
  10. package/dist/callbacks/base.d.cts +10 -11
  11. package/dist/callbacks/base.d.cts.map +1 -1
  12. package/dist/callbacks/base.d.ts +10 -11
  13. package/dist/callbacks/base.d.ts.map +1 -1
  14. package/dist/callbacks/dispatch/index.d.cts +1 -2
  15. package/dist/callbacks/dispatch/index.d.cts.map +1 -1
  16. package/dist/callbacks/dispatch/index.d.ts +1 -2
  17. package/dist/callbacks/dispatch/index.d.ts.map +1 -1
  18. package/dist/callbacks/dispatch/web.d.cts +1 -2
  19. package/dist/callbacks/dispatch/web.d.cts.map +1 -1
  20. package/dist/callbacks/dispatch/web.d.ts +1 -2
  21. package/dist/callbacks/dispatch/web.d.ts.map +1 -1
  22. package/dist/callbacks/manager.cjs +1 -1
  23. package/dist/callbacks/manager.cjs.map +1 -1
  24. package/dist/callbacks/manager.d.cts +12 -13
  25. package/dist/callbacks/manager.d.cts.map +1 -1
  26. package/dist/callbacks/manager.d.ts +12 -13
  27. package/dist/callbacks/manager.d.ts.map +1 -1
  28. package/dist/callbacks/manager.js +1 -1
  29. package/dist/callbacks/manager.js.map +1 -1
  30. package/dist/chat_history.d.cts +3 -4
  31. package/dist/chat_history.d.cts.map +1 -1
  32. package/dist/chat_history.d.ts +3 -4
  33. package/dist/chat_history.d.ts.map +1 -1
  34. package/dist/context.d.cts +2 -2
  35. package/dist/context.d.cts.map +1 -1
  36. package/dist/context.d.ts +2 -2
  37. package/dist/context.d.ts.map +1 -1
  38. package/dist/document_loaders/base.d.cts +2 -3
  39. package/dist/document_loaders/base.d.cts.map +1 -1
  40. package/dist/document_loaders/base.d.ts +2 -3
  41. package/dist/document_loaders/base.d.ts.map +1 -1
  42. package/dist/document_loaders/langsmith.d.cts +2 -3
  43. package/dist/document_loaders/langsmith.d.cts.map +1 -1
  44. package/dist/document_loaders/langsmith.d.ts +2 -3
  45. package/dist/document_loaders/langsmith.d.ts.map +1 -1
  46. package/dist/documents/document.d.cts +3 -4
  47. package/dist/documents/document.d.cts.map +1 -1
  48. package/dist/documents/document.d.ts +3 -4
  49. package/dist/documents/document.d.ts.map +1 -1
  50. package/dist/documents/transformers.d.cts +2 -3
  51. package/dist/documents/transformers.d.cts.map +1 -1
  52. package/dist/documents/transformers.d.ts +2 -3
  53. package/dist/documents/transformers.d.ts.map +1 -1
  54. package/dist/embeddings.d.cts +3 -4
  55. package/dist/embeddings.d.cts.map +1 -1
  56. package/dist/embeddings.d.ts +3 -4
  57. package/dist/embeddings.d.ts.map +1 -1
  58. package/dist/errors/index.cjs.map +1 -1
  59. package/dist/errors/index.d.cts +13 -19
  60. package/dist/errors/index.d.cts.map +1 -1
  61. package/dist/errors/index.d.ts +13 -19
  62. package/dist/errors/index.d.ts.map +1 -1
  63. package/dist/errors/index.js.map +1 -1
  64. package/dist/example_selectors/base.d.cts +1 -2
  65. package/dist/example_selectors/base.d.cts.map +1 -1
  66. package/dist/example_selectors/base.d.ts +1 -2
  67. package/dist/example_selectors/base.d.ts.map +1 -1
  68. package/dist/example_selectors/conditional.d.cts +5 -6
  69. package/dist/example_selectors/conditional.d.cts.map +1 -1
  70. package/dist/example_selectors/conditional.d.ts +5 -6
  71. package/dist/example_selectors/conditional.d.ts.map +1 -1
  72. package/dist/example_selectors/length_based.d.cts +2 -3
  73. package/dist/example_selectors/length_based.d.cts.map +1 -1
  74. package/dist/example_selectors/length_based.d.ts +2 -3
  75. package/dist/example_selectors/length_based.d.ts.map +1 -1
  76. package/dist/example_selectors/semantic_similarity.d.cts +2 -3
  77. package/dist/example_selectors/semantic_similarity.d.cts.map +1 -1
  78. package/dist/example_selectors/semantic_similarity.d.ts +2 -3
  79. package/dist/example_selectors/semantic_similarity.d.ts.map +1 -1
  80. package/dist/indexing/base.d.cts +9 -10
  81. package/dist/indexing/base.d.cts.map +1 -1
  82. package/dist/indexing/base.d.ts +9 -10
  83. package/dist/indexing/base.d.ts.map +1 -1
  84. package/dist/indexing/record_manager.d.cts +5 -6
  85. package/dist/indexing/record_manager.d.cts.map +1 -1
  86. package/dist/indexing/record_manager.d.ts +5 -6
  87. package/dist/indexing/record_manager.d.ts.map +1 -1
  88. package/dist/language_models/base.cjs +1 -1
  89. package/dist/language_models/base.cjs.map +1 -1
  90. package/dist/language_models/base.d.cts +24 -25
  91. package/dist/language_models/base.d.cts.map +1 -1
  92. package/dist/language_models/base.d.ts +24 -25
  93. package/dist/language_models/base.d.ts.map +1 -1
  94. package/dist/language_models/base.js +1 -1
  95. package/dist/language_models/base.js.map +1 -1
  96. package/dist/language_models/chat_models.d.cts +9 -10
  97. package/dist/language_models/chat_models.d.cts.map +1 -1
  98. package/dist/language_models/chat_models.d.ts +9 -10
  99. package/dist/language_models/chat_models.d.ts.map +1 -1
  100. package/dist/language_models/compat.d.cts +2 -3
  101. package/dist/language_models/compat.d.cts.map +1 -1
  102. package/dist/language_models/compat.d.ts +2 -3
  103. package/dist/language_models/compat.d.ts.map +1 -1
  104. package/dist/language_models/event.d.cts +15 -16
  105. package/dist/language_models/event.d.cts.map +1 -1
  106. package/dist/language_models/event.d.ts +15 -16
  107. package/dist/language_models/event.d.ts.map +1 -1
  108. package/dist/language_models/llms.d.cts +5 -6
  109. package/dist/language_models/llms.d.cts.map +1 -1
  110. package/dist/language_models/llms.d.ts +5 -6
  111. package/dist/language_models/llms.d.ts.map +1 -1
  112. package/dist/language_models/openai_completions_stream.d.cts +8 -9
  113. package/dist/language_models/openai_completions_stream.d.cts.map +1 -1
  114. package/dist/language_models/openai_completions_stream.d.ts +8 -9
  115. package/dist/language_models/openai_completions_stream.d.ts.map +1 -1
  116. package/dist/language_models/profile.cjs.map +1 -1
  117. package/dist/language_models/profile.d.cts +16 -2
  118. package/dist/language_models/profile.d.cts.map +1 -1
  119. package/dist/language_models/profile.d.ts +16 -2
  120. package/dist/language_models/profile.d.ts.map +1 -1
  121. package/dist/language_models/profile.js.map +1 -1
  122. package/dist/language_models/stream.d.cts +5 -6
  123. package/dist/language_models/stream.d.cts.map +1 -1
  124. package/dist/language_models/stream.d.ts +5 -6
  125. package/dist/language_models/stream.d.ts.map +1 -1
  126. package/dist/language_models/structured_output.d.cts +3 -4
  127. package/dist/language_models/structured_output.d.cts.map +1 -1
  128. package/dist/language_models/structured_output.d.ts +3 -4
  129. package/dist/language_models/structured_output.d.ts.map +1 -1
  130. package/dist/load/import_type.d.cts +2 -3
  131. package/dist/load/import_type.d.cts.map +1 -1
  132. package/dist/load/import_type.d.ts +2 -3
  133. package/dist/load/import_type.d.ts.map +1 -1
  134. package/dist/load/index.d.cts +2 -3
  135. package/dist/load/index.d.cts.map +1 -1
  136. package/dist/load/index.d.ts +2 -3
  137. package/dist/load/index.d.ts.map +1 -1
  138. package/dist/load/map_keys.d.cts +1 -2
  139. package/dist/load/map_keys.d.cts.map +1 -1
  140. package/dist/load/map_keys.d.ts +1 -2
  141. package/dist/load/map_keys.d.ts.map +1 -1
  142. package/dist/load/serializable.d.cts +9 -10
  143. package/dist/load/serializable.d.cts.map +1 -1
  144. package/dist/load/serializable.d.ts +9 -10
  145. package/dist/load/serializable.d.ts.map +1 -1
  146. package/dist/memory.d.cts +7 -8
  147. package/dist/memory.d.cts.map +1 -1
  148. package/dist/memory.d.ts +7 -8
  149. package/dist/memory.d.ts.map +1 -1
  150. package/dist/messages/ai.d.cts +6 -7
  151. package/dist/messages/ai.d.cts.map +1 -1
  152. package/dist/messages/ai.d.ts +6 -7
  153. package/dist/messages/ai.d.ts.map +1 -1
  154. package/dist/messages/base.d.cts +23 -24
  155. package/dist/messages/base.d.cts.map +1 -1
  156. package/dist/messages/base.d.ts +23 -24
  157. package/dist/messages/base.d.ts.map +1 -1
  158. package/dist/messages/chat.d.cts +5 -6
  159. package/dist/messages/chat.d.cts.map +1 -1
  160. package/dist/messages/chat.d.ts +5 -6
  161. package/dist/messages/chat.d.ts.map +1 -1
  162. package/dist/messages/content/base.d.cts +1 -2
  163. package/dist/messages/content/base.d.cts.map +1 -1
  164. package/dist/messages/content/base.d.ts +1 -2
  165. package/dist/messages/content/base.d.ts.map +1 -1
  166. package/dist/messages/content/data.d.cts +18 -19
  167. package/dist/messages/content/data.d.cts.map +1 -1
  168. package/dist/messages/content/data.d.ts +18 -19
  169. package/dist/messages/content/data.d.ts.map +1 -1
  170. package/dist/messages/content/index.d.cts +4 -5
  171. package/dist/messages/content/index.d.cts.map +1 -1
  172. package/dist/messages/content/index.d.ts +4 -5
  173. package/dist/messages/content/index.d.ts.map +1 -1
  174. package/dist/messages/content/multimodal.d.cts +2 -3
  175. package/dist/messages/content/multimodal.d.cts.map +1 -1
  176. package/dist/messages/content/multimodal.d.ts +2 -3
  177. package/dist/messages/content/multimodal.d.ts.map +1 -1
  178. package/dist/messages/content/tools.d.cts +2 -3
  179. package/dist/messages/content/tools.d.cts.map +1 -1
  180. package/dist/messages/content/tools.d.ts +2 -3
  181. package/dist/messages/content/tools.d.ts.map +1 -1
  182. package/dist/messages/format.d.cts +1 -2
  183. package/dist/messages/format.d.cts.map +1 -1
  184. package/dist/messages/format.d.ts +1 -2
  185. package/dist/messages/format.d.ts.map +1 -1
  186. package/dist/messages/function.d.cts +5 -6
  187. package/dist/messages/function.d.cts.map +1 -1
  188. package/dist/messages/function.d.ts +5 -6
  189. package/dist/messages/function.d.ts.map +1 -1
  190. package/dist/messages/human.d.cts +5 -6
  191. package/dist/messages/human.d.cts.map +1 -1
  192. package/dist/messages/human.d.ts +5 -6
  193. package/dist/messages/human.d.ts.map +1 -1
  194. package/dist/messages/message.d.cts +20 -21
  195. package/dist/messages/message.d.cts.map +1 -1
  196. package/dist/messages/message.d.ts +20 -21
  197. package/dist/messages/message.d.ts.map +1 -1
  198. package/dist/messages/metadata.d.cts +7 -8
  199. package/dist/messages/metadata.d.cts.map +1 -1
  200. package/dist/messages/metadata.d.ts +7 -8
  201. package/dist/messages/metadata.d.ts.map +1 -1
  202. package/dist/messages/modifier.d.cts +2 -3
  203. package/dist/messages/modifier.d.cts.map +1 -1
  204. package/dist/messages/modifier.d.ts +2 -3
  205. package/dist/messages/modifier.d.ts.map +1 -1
  206. package/dist/messages/system.d.cts +5 -6
  207. package/dist/messages/system.d.cts.map +1 -1
  208. package/dist/messages/system.d.ts +5 -6
  209. package/dist/messages/system.d.ts.map +1 -1
  210. package/dist/messages/tool.d.cts +11 -12
  211. package/dist/messages/tool.d.cts.map +1 -1
  212. package/dist/messages/tool.d.ts +11 -12
  213. package/dist/messages/tool.d.ts.map +1 -1
  214. package/dist/messages/transformers.d.cts +12 -13
  215. package/dist/messages/transformers.d.cts.map +1 -1
  216. package/dist/messages/transformers.d.ts +12 -13
  217. package/dist/messages/transformers.d.ts.map +1 -1
  218. package/dist/messages/utils.d.cts +13 -14
  219. package/dist/messages/utils.d.cts.map +1 -1
  220. package/dist/messages/utils.d.ts +13 -14
  221. package/dist/messages/utils.d.ts.map +1 -1
  222. package/dist/output_parsers/base.d.cts +4 -5
  223. package/dist/output_parsers/base.d.cts.map +1 -1
  224. package/dist/output_parsers/base.d.ts +4 -5
  225. package/dist/output_parsers/base.d.ts.map +1 -1
  226. package/dist/output_parsers/bytes.d.cts +1 -2
  227. package/dist/output_parsers/bytes.d.cts.map +1 -1
  228. package/dist/output_parsers/bytes.d.ts +1 -2
  229. package/dist/output_parsers/bytes.d.ts.map +1 -1
  230. package/dist/output_parsers/json.d.cts +2 -2
  231. package/dist/output_parsers/json.d.cts.map +1 -1
  232. package/dist/output_parsers/json.d.ts +2 -2
  233. package/dist/output_parsers/json.d.ts.map +1 -1
  234. package/dist/output_parsers/list.d.cts +5 -6
  235. package/dist/output_parsers/list.d.cts.map +1 -1
  236. package/dist/output_parsers/list.d.ts +5 -6
  237. package/dist/output_parsers/list.d.ts.map +1 -1
  238. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +4 -5
  239. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -1
  240. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +4 -5
  241. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -1
  242. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +12 -13
  243. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -1
  244. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +12 -13
  245. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -1
  246. package/dist/output_parsers/standard_schema.d.cts +1 -2
  247. package/dist/output_parsers/standard_schema.d.cts.map +1 -1
  248. package/dist/output_parsers/standard_schema.d.ts +1 -2
  249. package/dist/output_parsers/standard_schema.d.ts.map +1 -1
  250. package/dist/output_parsers/string.d.cts +1 -2
  251. package/dist/output_parsers/string.d.cts.map +1 -1
  252. package/dist/output_parsers/string.d.ts +1 -2
  253. package/dist/output_parsers/string.d.ts.map +1 -1
  254. package/dist/output_parsers/structured.d.cts +6 -7
  255. package/dist/output_parsers/structured.d.cts.map +1 -1
  256. package/dist/output_parsers/structured.d.ts +6 -7
  257. package/dist/output_parsers/structured.d.ts.map +1 -1
  258. package/dist/output_parsers/transform.d.cts +3 -4
  259. package/dist/output_parsers/transform.d.cts.map +1 -1
  260. package/dist/output_parsers/transform.d.ts +3 -4
  261. package/dist/output_parsers/transform.d.ts.map +1 -1
  262. package/dist/output_parsers/xml.d.cts +6 -7
  263. package/dist/output_parsers/xml.d.cts.map +1 -1
  264. package/dist/output_parsers/xml.d.ts +6 -7
  265. package/dist/output_parsers/xml.d.ts.map +1 -1
  266. package/dist/outputs.d.cts +9 -10
  267. package/dist/outputs.d.cts.map +1 -1
  268. package/dist/outputs.d.ts +9 -10
  269. package/dist/outputs.d.ts.map +1 -1
  270. package/dist/prompt_values.d.cts +10 -11
  271. package/dist/prompt_values.d.cts.map +1 -1
  272. package/dist/prompt_values.d.ts +10 -11
  273. package/dist/prompt_values.d.ts.map +1 -1
  274. package/dist/prompts/base.d.cts +4 -5
  275. package/dist/prompts/base.d.cts.map +1 -1
  276. package/dist/prompts/base.d.ts +4 -5
  277. package/dist/prompts/base.d.ts.map +1 -1
  278. package/dist/prompts/chat.d.cts +14 -15
  279. package/dist/prompts/chat.d.cts.map +1 -1
  280. package/dist/prompts/chat.d.ts +14 -15
  281. package/dist/prompts/chat.d.ts.map +1 -1
  282. package/dist/prompts/dict.d.cts +1 -2
  283. package/dist/prompts/dict.d.cts.map +1 -1
  284. package/dist/prompts/dict.d.ts +1 -2
  285. package/dist/prompts/dict.d.ts.map +1 -1
  286. package/dist/prompts/few_shot.d.cts +4 -5
  287. package/dist/prompts/few_shot.d.cts.map +1 -1
  288. package/dist/prompts/few_shot.d.ts +4 -5
  289. package/dist/prompts/few_shot.d.ts.map +1 -1
  290. package/dist/prompts/image.d.cts +2 -3
  291. package/dist/prompts/image.d.cts.map +1 -1
  292. package/dist/prompts/image.d.ts +2 -3
  293. package/dist/prompts/image.d.ts.map +1 -1
  294. package/dist/prompts/pipeline.d.cts +3 -4
  295. package/dist/prompts/pipeline.d.cts.map +1 -1
  296. package/dist/prompts/pipeline.d.ts +3 -4
  297. package/dist/prompts/pipeline.d.ts.map +1 -1
  298. package/dist/prompts/prompt.d.cts +4 -5
  299. package/dist/prompts/prompt.d.cts.map +1 -1
  300. package/dist/prompts/prompt.d.ts +4 -5
  301. package/dist/prompts/prompt.d.ts.map +1 -1
  302. package/dist/prompts/serde.d.cts +3 -4
  303. package/dist/prompts/serde.d.cts.map +1 -1
  304. package/dist/prompts/serde.d.ts +3 -4
  305. package/dist/prompts/serde.d.ts.map +1 -1
  306. package/dist/prompts/string.d.cts +1 -2
  307. package/dist/prompts/string.d.cts.map +1 -1
  308. package/dist/prompts/string.d.ts +1 -2
  309. package/dist/prompts/string.d.ts.map +1 -1
  310. package/dist/prompts/structured.d.cts +2 -3
  311. package/dist/prompts/structured.d.cts.map +1 -1
  312. package/dist/prompts/structured.d.ts +2 -3
  313. package/dist/prompts/structured.d.ts.map +1 -1
  314. package/dist/prompts/template.d.cts +12 -13
  315. package/dist/prompts/template.d.cts.map +1 -1
  316. package/dist/prompts/template.d.ts +12 -13
  317. package/dist/prompts/template.d.ts.map +1 -1
  318. package/dist/retrievers/document_compressors/index.d.cts +1 -2
  319. package/dist/retrievers/document_compressors/index.d.cts.map +1 -1
  320. package/dist/retrievers/document_compressors/index.d.ts +1 -2
  321. package/dist/retrievers/document_compressors/index.d.ts.map +1 -1
  322. package/dist/retrievers/index.d.cts +3 -4
  323. package/dist/retrievers/index.d.cts.map +1 -1
  324. package/dist/retrievers/index.d.ts +3 -4
  325. package/dist/retrievers/index.d.ts.map +1 -1
  326. package/dist/runnables/base.d.cts +23 -23
  327. package/dist/runnables/base.d.cts.map +1 -1
  328. package/dist/runnables/base.d.ts +23 -23
  329. package/dist/runnables/base.d.ts.map +1 -1
  330. package/dist/runnables/branch.d.cts +3 -4
  331. package/dist/runnables/branch.d.cts.map +1 -1
  332. package/dist/runnables/branch.d.ts +3 -4
  333. package/dist/runnables/branch.d.ts.map +1 -1
  334. package/dist/runnables/config.d.cts +6 -6
  335. package/dist/runnables/config.d.cts.map +1 -1
  336. package/dist/runnables/config.d.ts +6 -6
  337. package/dist/runnables/config.d.ts.map +1 -1
  338. package/dist/runnables/graph.d.cts +2 -2
  339. package/dist/runnables/graph.d.cts.map +1 -1
  340. package/dist/runnables/graph.d.ts +2 -2
  341. package/dist/runnables/graph.d.ts.map +1 -1
  342. package/dist/runnables/history.d.cts +2 -3
  343. package/dist/runnables/history.d.cts.map +1 -1
  344. package/dist/runnables/history.d.ts +2 -3
  345. package/dist/runnables/history.d.ts.map +1 -1
  346. package/dist/runnables/passthrough.d.cts +1 -2
  347. package/dist/runnables/passthrough.d.cts.map +1 -1
  348. package/dist/runnables/passthrough.d.ts +1 -2
  349. package/dist/runnables/passthrough.d.ts.map +1 -1
  350. package/dist/runnables/router.d.cts +2 -3
  351. package/dist/runnables/router.d.cts.map +1 -1
  352. package/dist/runnables/router.d.ts +2 -3
  353. package/dist/runnables/router.d.ts.map +1 -1
  354. package/dist/runnables/types.d.cts +6 -7
  355. package/dist/runnables/types.d.cts.map +1 -1
  356. package/dist/runnables/types.d.ts +6 -7
  357. package/dist/runnables/types.d.ts.map +1 -1
  358. package/dist/singletons/async_local_storage/context.d.cts +4 -5
  359. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  360. package/dist/singletons/async_local_storage/context.d.ts +4 -5
  361. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  362. package/dist/singletons/async_local_storage/globals.d.cts +2 -3
  363. package/dist/singletons/async_local_storage/globals.d.cts.map +1 -1
  364. package/dist/singletons/async_local_storage/globals.d.ts +2 -3
  365. package/dist/singletons/async_local_storage/globals.d.ts.map +1 -1
  366. package/dist/singletons/async_local_storage/index.d.cts +2 -2
  367. package/dist/singletons/async_local_storage/index.d.cts.map +1 -1
  368. package/dist/singletons/async_local_storage/index.d.ts +2 -2
  369. package/dist/singletons/async_local_storage/index.d.ts.map +1 -1
  370. package/dist/singletons/callbacks.d.cts +2 -3
  371. package/dist/singletons/callbacks.d.cts.map +1 -1
  372. package/dist/singletons/callbacks.d.ts +2 -3
  373. package/dist/singletons/callbacks.d.ts.map +1 -1
  374. package/dist/stores.d.cts +2 -3
  375. package/dist/stores.d.cts.map +1 -1
  376. package/dist/stores.d.ts +2 -3
  377. package/dist/stores.d.ts.map +1 -1
  378. package/dist/structured_query/base.d.cts +3 -4
  379. package/dist/structured_query/base.d.cts.map +1 -1
  380. package/dist/structured_query/base.d.ts +3 -4
  381. package/dist/structured_query/base.d.ts.map +1 -1
  382. package/dist/structured_query/functional.d.cts +2 -3
  383. package/dist/structured_query/functional.d.cts.map +1 -1
  384. package/dist/structured_query/functional.d.ts +2 -3
  385. package/dist/structured_query/functional.d.ts.map +1 -1
  386. package/dist/structured_query/ir.d.cts +23 -24
  387. package/dist/structured_query/ir.d.cts.map +1 -1
  388. package/dist/structured_query/ir.d.ts +23 -24
  389. package/dist/structured_query/ir.d.ts.map +1 -1
  390. package/dist/structured_query/utils.d.cts +7 -8
  391. package/dist/structured_query/utils.d.cts.map +1 -1
  392. package/dist/structured_query/utils.d.ts +7 -8
  393. package/dist/structured_query/utils.d.ts.map +1 -1
  394. package/dist/testing/fake_model_builder.d.cts +2 -3
  395. package/dist/testing/fake_model_builder.d.cts.map +1 -1
  396. package/dist/testing/fake_model_builder.d.ts +2 -3
  397. package/dist/testing/fake_model_builder.d.ts.map +1 -1
  398. package/dist/testing/index.d.cts +1 -0
  399. package/dist/testing/index.d.ts +1 -0
  400. package/dist/testing/matchers.d.cts +12 -13
  401. package/dist/testing/matchers.d.cts.map +1 -1
  402. package/dist/testing/matchers.d.ts +12 -13
  403. package/dist/testing/matchers.d.ts.map +1 -1
  404. package/dist/testing/vitest-expect.d.cts +8 -0
  405. package/dist/testing/vitest-expect.d.cts.map +1 -0
  406. package/dist/testing/vitest-expect.d.ts +8 -0
  407. package/dist/testing/vitest-expect.d.ts.map +1 -0
  408. package/dist/tools/index.d.cts +21 -21
  409. package/dist/tools/index.d.cts.map +1 -1
  410. package/dist/tools/index.d.ts +21 -21
  411. package/dist/tools/index.d.ts.map +1 -1
  412. package/dist/tools/types.d.cts +25 -26
  413. package/dist/tools/types.d.cts.map +1 -1
  414. package/dist/tools/types.d.ts +25 -26
  415. package/dist/tools/types.d.ts.map +1 -1
  416. package/dist/tools/utils.d.cts +1 -2
  417. package/dist/tools/utils.d.cts.map +1 -1
  418. package/dist/tools/utils.d.ts +1 -2
  419. package/dist/tools/utils.d.ts.map +1 -1
  420. package/dist/tracers/base.cjs +7 -4
  421. package/dist/tracers/base.cjs.map +1 -1
  422. package/dist/tracers/base.d.cts +7 -8
  423. package/dist/tracers/base.d.cts.map +1 -1
  424. package/dist/tracers/base.d.ts +7 -8
  425. package/dist/tracers/base.d.ts.map +1 -1
  426. package/dist/tracers/base.js +7 -4
  427. package/dist/tracers/base.js.map +1 -1
  428. package/dist/tracers/console.d.cts +1 -2
  429. package/dist/tracers/console.d.cts.map +1 -1
  430. package/dist/tracers/console.d.ts +1 -2
  431. package/dist/tracers/console.d.ts.map +1 -1
  432. package/dist/tracers/event_stream.d.cts +3 -4
  433. package/dist/tracers/event_stream.d.cts.map +1 -1
  434. package/dist/tracers/event_stream.d.ts +3 -4
  435. package/dist/tracers/event_stream.d.ts.map +1 -1
  436. package/dist/tracers/log_stream.d.cts +9 -9
  437. package/dist/tracers/log_stream.d.cts.map +1 -1
  438. package/dist/tracers/log_stream.d.ts +9 -9
  439. package/dist/tracers/log_stream.d.ts.map +1 -1
  440. package/dist/tracers/run_collector.d.cts +1 -2
  441. package/dist/tracers/run_collector.d.cts.map +1 -1
  442. package/dist/tracers/run_collector.d.ts +1 -2
  443. package/dist/tracers/run_collector.d.ts.map +1 -1
  444. package/dist/tracers/tracer_langchain.d.cts +6 -7
  445. package/dist/tracers/tracer_langchain.d.cts.map +1 -1
  446. package/dist/tracers/tracer_langchain.d.ts +6 -7
  447. package/dist/tracers/tracer_langchain.d.ts.map +1 -1
  448. package/dist/types/_internal.d.cts +1 -2
  449. package/dist/types/_internal.d.cts.map +1 -1
  450. package/dist/types/_internal.d.ts +1 -2
  451. package/dist/types/_internal.d.ts.map +1 -1
  452. package/dist/types/type-utils.d.cts +2 -3
  453. package/dist/types/type-utils.d.cts.map +1 -1
  454. package/dist/types/type-utils.d.ts +2 -3
  455. package/dist/types/type-utils.d.ts.map +1 -1
  456. package/dist/utils/async_caller.d.cts +6 -7
  457. package/dist/utils/async_caller.d.cts.map +1 -1
  458. package/dist/utils/async_caller.d.ts +6 -7
  459. package/dist/utils/async_caller.d.ts.map +1 -1
  460. package/dist/utils/chunk_array.d.cts +1 -2
  461. package/dist/utils/chunk_array.d.cts.map +1 -1
  462. package/dist/utils/chunk_array.d.ts +1 -2
  463. package/dist/utils/chunk_array.d.ts.map +1 -1
  464. package/dist/utils/context.d.cts +1 -2
  465. package/dist/utils/context.d.cts.map +1 -1
  466. package/dist/utils/context.d.ts +1 -2
  467. package/dist/utils/context.d.ts.map +1 -1
  468. package/dist/utils/env.d.cts +9 -10
  469. package/dist/utils/env.d.cts.map +1 -1
  470. package/dist/utils/env.d.ts +9 -10
  471. package/dist/utils/env.d.ts.map +1 -1
  472. package/dist/utils/event_source_parse.d.cts +6 -7
  473. package/dist/utils/event_source_parse.d.cts.map +1 -1
  474. package/dist/utils/event_source_parse.d.ts +6 -7
  475. package/dist/utils/event_source_parse.d.ts.map +1 -1
  476. package/dist/utils/fast-json-patch/src/core.d.cts +13 -14
  477. package/dist/utils/fast-json-patch/src/core.d.cts.map +1 -1
  478. package/dist/utils/fast-json-patch/src/core.d.ts +13 -14
  479. package/dist/utils/fast-json-patch/src/core.d.ts.map +1 -1
  480. package/dist/utils/fast-json-patch/src/duplex.d.cts +1 -2
  481. package/dist/utils/fast-json-patch/src/duplex.d.cts.map +1 -1
  482. package/dist/utils/fast-json-patch/src/duplex.d.ts +1 -2
  483. package/dist/utils/fast-json-patch/src/duplex.d.ts.map +1 -1
  484. package/dist/utils/format.d.cts +2 -3
  485. package/dist/utils/format.d.cts.map +1 -1
  486. package/dist/utils/format.d.ts +2 -3
  487. package/dist/utils/format.d.ts.map +1 -1
  488. package/dist/utils/function_calling.d.cts +3 -3
  489. package/dist/utils/function_calling.d.cts.map +1 -1
  490. package/dist/utils/function_calling.d.ts +3 -3
  491. package/dist/utils/function_calling.d.ts.map +1 -1
  492. package/dist/utils/gateway.d.cts +4 -5
  493. package/dist/utils/gateway.d.cts.map +1 -1
  494. package/dist/utils/gateway.d.ts +4 -5
  495. package/dist/utils/gateway.d.ts.map +1 -1
  496. package/dist/utils/hash.d.cts +2 -2
  497. package/dist/utils/hash.d.cts.map +1 -1
  498. package/dist/utils/hash.d.ts +2 -2
  499. package/dist/utils/hash.d.ts.map +1 -1
  500. package/dist/utils/js-sha256/hash.cjs +2 -2
  501. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  502. package/dist/utils/js-sha256/hash.d.cts +1 -2
  503. package/dist/utils/js-sha256/hash.d.cts.map +1 -1
  504. package/dist/utils/js-sha256/hash.d.ts +1 -2
  505. package/dist/utils/js-sha256/hash.d.ts.map +1 -1
  506. package/dist/utils/js-sha256/hash.js +2 -2
  507. package/dist/utils/js-sha256/hash.js.map +1 -1
  508. package/dist/utils/json.d.cts +2 -3
  509. package/dist/utils/json.d.cts.map +1 -1
  510. package/dist/utils/json.d.ts +2 -3
  511. package/dist/utils/json.d.ts.map +1 -1
  512. package/dist/utils/json_schema.d.cts +4 -4
  513. package/dist/utils/json_schema.d.cts.map +1 -1
  514. package/dist/utils/json_schema.d.ts +4 -4
  515. package/dist/utils/json_schema.d.ts.map +1 -1
  516. package/dist/utils/math.d.cts +6 -7
  517. package/dist/utils/math.d.cts.map +1 -1
  518. package/dist/utils/math.d.ts +6 -7
  519. package/dist/utils/math.d.ts.map +1 -1
  520. package/dist/utils/ml-distance/similarities.d.cts +1 -2
  521. package/dist/utils/ml-distance/similarities.d.cts.map +1 -1
  522. package/dist/utils/ml-distance/similarities.d.ts +1 -2
  523. package/dist/utils/ml-distance/similarities.d.ts.map +1 -1
  524. package/dist/utils/namespace.cjs.map +1 -1
  525. package/dist/utils/namespace.d.cts +2 -3
  526. package/dist/utils/namespace.d.cts.map +1 -1
  527. package/dist/utils/namespace.d.ts +2 -3
  528. package/dist/utils/namespace.d.ts.map +1 -1
  529. package/dist/utils/namespace.js.map +1 -1
  530. package/dist/utils/signal.d.cts +1 -2
  531. package/dist/utils/signal.d.cts.map +1 -1
  532. package/dist/utils/signal.d.ts +1 -2
  533. package/dist/utils/signal.d.ts.map +1 -1
  534. package/dist/utils/ssrf.d.cts +6 -7
  535. package/dist/utils/ssrf.d.cts.map +1 -1
  536. package/dist/utils/ssrf.d.ts +6 -7
  537. package/dist/utils/ssrf.d.ts.map +1 -1
  538. package/dist/utils/standard_schema.d.cts +4 -5
  539. package/dist/utils/standard_schema.d.cts.map +1 -1
  540. package/dist/utils/standard_schema.d.ts +4 -5
  541. package/dist/utils/standard_schema.d.ts.map +1 -1
  542. package/dist/utils/stream.d.cts +6 -6
  543. package/dist/utils/stream.d.cts.map +1 -1
  544. package/dist/utils/stream.d.ts +6 -6
  545. package/dist/utils/stream.d.ts.map +1 -1
  546. package/dist/utils/testing/chat_models.d.cts +8 -9
  547. package/dist/utils/testing/chat_models.d.cts.map +1 -1
  548. package/dist/utils/testing/chat_models.d.ts +8 -9
  549. package/dist/utils/testing/chat_models.d.ts.map +1 -1
  550. package/dist/utils/testing/embeddings.d.cts +2 -3
  551. package/dist/utils/testing/embeddings.d.cts.map +1 -1
  552. package/dist/utils/testing/embeddings.d.ts +2 -3
  553. package/dist/utils/testing/embeddings.d.ts.map +1 -1
  554. package/dist/utils/testing/llms.d.cts +2 -3
  555. package/dist/utils/testing/llms.d.cts.map +1 -1
  556. package/dist/utils/testing/llms.d.ts +2 -3
  557. package/dist/utils/testing/llms.d.ts.map +1 -1
  558. package/dist/utils/testing/message_history.d.cts +3 -4
  559. package/dist/utils/testing/message_history.d.cts.map +1 -1
  560. package/dist/utils/testing/message_history.d.ts +3 -4
  561. package/dist/utils/testing/message_history.d.ts.map +1 -1
  562. package/dist/utils/testing/openai_stream_fixtures.d.cts +6 -7
  563. package/dist/utils/testing/openai_stream_fixtures.d.cts.map +1 -1
  564. package/dist/utils/testing/openai_stream_fixtures.d.ts +6 -7
  565. package/dist/utils/testing/openai_stream_fixtures.d.ts.map +1 -1
  566. package/dist/utils/testing/output_parsers.d.cts +1 -2
  567. package/dist/utils/testing/output_parsers.d.cts.map +1 -1
  568. package/dist/utils/testing/output_parsers.d.ts +1 -2
  569. package/dist/utils/testing/output_parsers.d.ts.map +1 -1
  570. package/dist/utils/testing/retrievers.d.cts +1 -2
  571. package/dist/utils/testing/retrievers.d.cts.map +1 -1
  572. package/dist/utils/testing/retrievers.d.ts +1 -2
  573. package/dist/utils/testing/retrievers.d.ts.map +1 -1
  574. package/dist/utils/testing/runnables.d.cts +1 -2
  575. package/dist/utils/testing/runnables.d.cts.map +1 -1
  576. package/dist/utils/testing/runnables.d.ts +1 -2
  577. package/dist/utils/testing/runnables.d.ts.map +1 -1
  578. package/dist/utils/testing/stream.d.cts +10 -11
  579. package/dist/utils/testing/stream.d.cts.map +1 -1
  580. package/dist/utils/testing/stream.d.ts +10 -11
  581. package/dist/utils/testing/stream.d.ts.map +1 -1
  582. package/dist/utils/testing/tools.d.cts +2 -3
  583. package/dist/utils/testing/tools.d.cts.map +1 -1
  584. package/dist/utils/testing/tools.d.ts +2 -3
  585. package/dist/utils/testing/tools.d.ts.map +1 -1
  586. package/dist/utils/testing/tracers.d.cts +1 -2
  587. package/dist/utils/testing/tracers.d.cts.map +1 -1
  588. package/dist/utils/testing/tracers.d.ts +1 -2
  589. package/dist/utils/testing/tracers.d.ts.map +1 -1
  590. package/dist/utils/testing/vectorstores.d.cts +2 -3
  591. package/dist/utils/testing/vectorstores.d.cts.map +1 -1
  592. package/dist/utils/testing/vectorstores.d.ts +2 -3
  593. package/dist/utils/testing/vectorstores.d.ts.map +1 -1
  594. package/dist/utils/tiktoken.d.cts +2 -3
  595. package/dist/utils/tiktoken.d.cts.map +1 -1
  596. package/dist/utils/tiktoken.d.ts +2 -3
  597. package/dist/utils/tiktoken.d.ts.map +1 -1
  598. package/dist/utils/types/index.d.cts +5 -5
  599. package/dist/utils/types/index.d.cts.map +1 -1
  600. package/dist/utils/types/index.d.ts +5 -5
  601. package/dist/utils/types/index.d.ts.map +1 -1
  602. package/dist/utils/types/zod.d.cts +62 -63
  603. package/dist/utils/types/zod.d.cts.map +1 -1
  604. package/dist/utils/types/zod.d.ts +62 -63
  605. package/dist/utils/types/zod.d.ts.map +1 -1
  606. package/dist/utils/uuid/index.d.cts +12 -12
  607. package/dist/utils/uuid/index.d.cts.map +1 -1
  608. package/dist/utils/uuid/index.d.ts +12 -12
  609. package/dist/utils/uuid/index.d.ts.map +1 -1
  610. package/dist/utils/uuid/types.d.cts +6 -7
  611. package/dist/utils/uuid/types.d.cts.map +1 -1
  612. package/dist/utils/uuid/types.d.ts +6 -7
  613. package/dist/utils/uuid/types.d.ts.map +1 -1
  614. package/dist/utils/uuid/v35.d.cts +2 -3
  615. package/dist/utils/uuid/v35.d.cts.map +1 -1
  616. package/dist/utils/uuid/v35.d.ts +2 -3
  617. package/dist/utils/uuid/v35.d.ts.map +1 -1
  618. package/dist/utils/zod-to-json-schema/errorMessages.d.cts +1 -2
  619. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -1
  620. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +1 -2
  621. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -1
  622. package/dist/utils/zod-to-json-schema/parseTypes.d.cts +2 -3
  623. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -1
  624. package/dist/utils/zod-to-json-schema/parseTypes.d.ts +2 -3
  625. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -1
  626. package/dist/utils/zod-to-json-schema/parsers/any.d.cts +1 -2
  627. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -1
  628. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +1 -2
  629. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -1
  630. package/dist/utils/zod-to-json-schema/parsers/array.d.cts +1 -2
  631. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -1
  632. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +1 -2
  633. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -1
  634. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +1 -2
  635. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -1
  636. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +1 -2
  637. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -1
  638. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts +1 -2
  639. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -1
  640. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts +1 -2
  641. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -1
  642. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +1 -2
  643. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -1
  644. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +1 -2
  645. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -1
  646. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts +1 -2
  647. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -1
  648. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +1 -2
  649. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -1
  650. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +1 -2
  651. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -1
  652. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +1 -2
  653. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -1
  654. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +1 -2
  655. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -1
  656. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +1 -2
  657. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -1
  658. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +1 -2
  659. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -1
  660. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +1 -2
  661. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -1
  662. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts +1 -2
  663. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -1
  664. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +1 -2
  665. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -1
  666. package/dist/utils/zod-to-json-schema/parsers/never.d.cts +1 -2
  667. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -1
  668. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +1 -2
  669. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -1
  670. package/dist/utils/zod-to-json-schema/parsers/null.d.cts +1 -2
  671. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -1
  672. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +1 -2
  673. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -1
  674. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +1 -2
  675. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -1
  676. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +1 -2
  677. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -1
  678. package/dist/utils/zod-to-json-schema/parsers/number.d.cts +1 -2
  679. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -1
  680. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +1 -2
  681. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -1
  682. package/dist/utils/zod-to-json-schema/parsers/object.d.cts +1 -2
  683. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -1
  684. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +1 -2
  685. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -1
  686. package/dist/utils/zod-to-json-schema/parsers/record.d.cts +1 -2
  687. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -1
  688. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +1 -2
  689. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -1
  690. package/dist/utils/zod-to-json-schema/parsers/set.d.cts +1 -2
  691. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -1
  692. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +1 -2
  693. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -1
  694. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +1 -2
  695. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -1
  696. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +1 -2
  697. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -1
  698. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +1 -2
  699. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -1
  700. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +1 -2
  701. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -1
  702. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +1 -2
  703. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -1
  704. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +1 -2
  705. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -1
  706. package/dist/utils/zod-to-json-schema/parsers/union.d.cts +2 -3
  707. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -1
  708. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +2 -3
  709. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -1
  710. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +1 -2
  711. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -1
  712. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +1 -2
  713. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -1
  714. package/dist/vectorstores.d.cts +8 -9
  715. package/dist/vectorstores.d.cts.map +1 -1
  716. package/dist/vectorstores.d.ts +8 -9
  717. package/dist/vectorstores.d.ts.map +1 -1
  718. package/package.json +3 -3
@@ -14,8 +14,8 @@ import "../utils/json_schema.js";
14
14
  import { ModelProfile } from "./profile.js";
15
15
  import { TiktokenModel } from "js-tiktoken/lite";
16
16
  //#region src/language_models/base.d.ts
17
- declare const getModelNameForTiktoken: (modelName: string) => TiktokenModel;
18
- declare const getEmbeddingContextSize: (modelName?: string) => number;
17
+ export declare const getModelNameForTiktoken: (modelName: string) => TiktokenModel;
18
+ export declare const getEmbeddingContextSize: (modelName?: string) => number;
19
19
  /**
20
20
  * Get the context window size (max input tokens) for a given model.
21
21
  *
@@ -27,23 +27,23 @@ declare const getEmbeddingContextSize: (modelName?: string) => number;
27
27
  * @param modelName - The name of the model
28
28
  * @returns The context window size in tokens
29
29
  */
30
- declare const getModelContextSize: (modelName: string) => number;
30
+ export declare const getModelContextSize: (modelName: string) => number;
31
31
  /**
32
32
  * Whether or not the input matches the OpenAI tool definition.
33
33
  * @param {unknown} tool The input to check.
34
34
  * @returns {boolean} Whether the input is an OpenAI tool definition.
35
35
  */
36
- declare function isOpenAITool(tool: unknown): tool is ToolDefinition;
36
+ export declare function isOpenAITool(tool: unknown): tool is ToolDefinition;
37
37
  interface CalculateMaxTokenProps {
38
38
  prompt: string;
39
39
  modelName: TiktokenModel;
40
40
  }
41
- declare const calculateMaxTokens: ({ prompt, modelName }: CalculateMaxTokenProps) => Promise<number>;
42
- type SerializedLLM = {
41
+ export declare const calculateMaxTokens: ({ prompt, modelName }: CalculateMaxTokenProps) => Promise<number>;
42
+ export type SerializedLLM = {
43
43
  _model: string;
44
44
  _type: string;
45
45
  } & Record<string, any>;
46
- interface BaseLangChainParams {
46
+ export interface BaseLangChainParams {
47
47
  verbose?: boolean;
48
48
  callbacks?: Callbacks;
49
49
  tags?: string[];
@@ -52,7 +52,7 @@ interface BaseLangChainParams {
52
52
  /**
53
53
  * Base class for language models, chains, tools.
54
54
  */
55
- declare abstract class BaseLangChain<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> implements BaseLangChainParams {
55
+ export declare abstract class BaseLangChain<RunInput, RunOutput, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> implements BaseLangChainParams {
56
56
  /**
57
57
  * Whether to print out response text.
58
58
  */
@@ -71,14 +71,14 @@ declare abstract class BaseLangChain<RunInput, RunOutput, CallOptions extends Ru
71
71
  * A subclass of {@link BaseLanguageModel} should have a constructor that
72
72
  * takes in a parameter that extends this interface.
73
73
  */
74
- interface BaseLanguageModelParams extends AsyncCallerParams, BaseLangChainParams {
74
+ export interface BaseLanguageModelParams extends AsyncCallerParams, BaseLangChainParams {
75
75
  /**
76
76
  * @deprecated Use `callbacks` instead
77
77
  */
78
78
  callbackManager?: CallbackManager;
79
79
  cache?: BaseCache | boolean;
80
80
  }
81
- interface BaseLanguageModelTracingCallOptions {
81
+ export interface BaseLanguageModelTracingCallOptions {
82
82
  /**
83
83
  * Describes the format of structured outputs.
84
84
  * This should be provided if an output is considered to be structured
@@ -96,7 +96,7 @@ interface BaseLanguageModelTracingCallOptions {
96
96
  schema?: JsonSchema7Type;
97
97
  };
98
98
  }
99
- interface BaseLanguageModelCallOptions extends RunnableConfig, BaseLanguageModelTracingCallOptions {
99
+ export interface BaseLanguageModelCallOptions extends RunnableConfig, BaseLanguageModelTracingCallOptions {
100
100
  /**
101
101
  * Stop tokens to use for this call.
102
102
  * If not provided, the default stop tokens for the model will be used.
@@ -107,7 +107,7 @@ interface BaseLanguageModelCallOptions extends RunnableConfig, BaseLanguageModel
107
107
  */
108
108
  maxRetries?: number;
109
109
  }
110
- interface FunctionDefinition {
110
+ export interface FunctionDefinition {
111
111
  /**
112
112
  * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
113
113
  * underscores and dashes, with a maximum length of 64.
@@ -130,20 +130,20 @@ interface FunctionDefinition {
130
130
  */
131
131
  description?: string;
132
132
  }
133
- interface ToolDefinition {
133
+ export interface ToolDefinition {
134
134
  type: "function";
135
135
  function: FunctionDefinition;
136
136
  }
137
- type FunctionCallOption = {
137
+ export type FunctionCallOption = {
138
138
  name: string;
139
139
  };
140
- interface BaseFunctionCallOptions extends BaseLanguageModelCallOptions {
140
+ export interface BaseFunctionCallOptions extends BaseLanguageModelCallOptions {
141
141
  function_call?: FunctionCallOption;
142
142
  functions?: FunctionDefinition[];
143
143
  }
144
- type BaseLanguageModelInput = BasePromptValueInterface | string | BaseMessageLike[];
145
- type StructuredOutputType = InferInteropZodOutput<InteropZodObject>;
146
- type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> = {
144
+ export type BaseLanguageModelInput = BasePromptValueInterface | string | BaseMessageLike[];
145
+ export type StructuredOutputType = InferInteropZodOutput<InteropZodObject>;
146
+ export type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> = {
147
147
  name?: string;
148
148
  method?: "functionCalling" | "jsonMode" | "jsonSchema" | string;
149
149
  includeRaw?: IncludeRaw;
@@ -151,14 +151,14 @@ type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> = {
151
151
  strict?: boolean;
152
152
  };
153
153
  /** @deprecated Use StructuredOutputMethodOptions instead */
154
- type StructuredOutputMethodParams<RunOutput, IncludeRaw extends boolean = false> = {
154
+ export type StructuredOutputMethodParams<RunOutput, IncludeRaw extends boolean = false> = {
155
155
  /** @deprecated Pass schema in as the first argument */
156
156
  schema: InteropZodType<RunOutput> | Record<string, any>;
157
157
  name?: string;
158
158
  method?: "functionCalling" | "jsonMode";
159
159
  includeRaw?: IncludeRaw;
160
160
  };
161
- interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {
161
+ export interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {
162
162
  get callKeys(): string[];
163
163
  generatePrompt(promptValues: BasePromptValueInterface[], options?: string[] | Partial<CallOptions>, callbacks?: Callbacks): Promise<LLMResult>;
164
164
  _modelType(): string;
@@ -170,12 +170,12 @@ interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLa
170
170
  _identifyingParams(): Record<string, any>;
171
171
  serialize(): SerializedLLM;
172
172
  }
173
- type LanguageModelOutput = BaseMessage | string;
174
- type LanguageModelLike = RunnableInterface<BaseLanguageModelInput, LanguageModelOutput>;
173
+ export type LanguageModelOutput = BaseMessage | string;
174
+ export type LanguageModelLike = RunnableInterface<BaseLanguageModelInput, LanguageModelOutput>;
175
175
  /**
176
176
  * Base class for language models.
177
177
  */
178
- declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions> implements BaseLanguageModelParams, BaseLanguageModelInterface<RunOutput, CallOptions> {
178
+ export declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions> implements BaseLanguageModelParams, BaseLanguageModelInterface<RunOutput, CallOptions> {
179
179
  /**
180
180
  * Keys that the language model accepts as call options.
181
181
  */
@@ -268,11 +268,10 @@ declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends Ba
268
268
  * Shared interface for token usage
269
269
  * return type from LLM calls.
270
270
  */
271
- interface TokenUsage {
271
+ export interface TokenUsage {
272
272
  completionTokens?: number;
273
273
  promptTokens?: number;
274
274
  totalTokens?: number;
275
275
  }
276
276
  //#endregion
277
- export { BaseFunctionCallOptions, BaseLangChain, BaseLangChainParams, BaseLanguageModel, BaseLanguageModelCallOptions, BaseLanguageModelInput, BaseLanguageModelInterface, BaseLanguageModelParams, BaseLanguageModelTracingCallOptions, FunctionCallOption, FunctionDefinition, LanguageModelLike, LanguageModelOutput, SerializedLLM, StructuredOutputMethodOptions, StructuredOutputMethodParams, StructuredOutputType, TokenUsage, ToolDefinition, calculateMaxTokens, getEmbeddingContextSize, getModelContextSize, getModelNameForTiktoken, isOpenAITool };
278
277
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","names":[],"sources":["../../src/language_models/base.ts"],"mappings":";;;;;;;;;;;;;;;;cAgCa,0BAAuB,sBAAwB;cA4B/C,0BAAuB;;;;;;;;;;;;cAoBvB,sBAAmB;;;;;;iBAgGhB,aAAa,gBAAgB,QAAQ;UAgB3C;EACR;EACA,WAAW;;cAGA,uBAAkB,QAAA,aAG5B,2BAAsB;KAuBb;EACV;EACA;IAEE;UAEa;EACf;EACA,YAAY;EACZ;EACA,WAAW;;;;;uBAMS,cACpB,UACA,WACA,oBAAoB,iBAAiB,wBAE7B,SAAS,UAAU,WAAW,wBAC3B;;;;EAKX;EAEA,YAAY;EAEZ;EAEA,WAAW;MAEP;KAAoB;;EAOxB,YAAY,QAAQ;YASV,YAAY,aAAa;;;;;;;UAiBpB,gCACP,mBAAmB;;;;EAI3B,kBAAkB;EAElB,QAAQ;;UAGO;;;;;EAKf;;;;IAIE;MAAU;;;;;IAIV,SAAS;;;UAII,qCACP,gBAAgB;;;;;EAKxB;;;;EAIA;;UAGe;;;;;EAKf;;;;;;;;;;;EAYA,YAAY,0BAA0B;;;;;EAMtC;;UAGe;EACf;EACA,UAAU;;KAGA;EACV;;UAGe,gCAAgC;EAC/C,gBAAgB;EAChB,YAAY;;KAGF,yBACR,oCAEA;KAEQ,uBAAuB,sBAAsB;KAE7C,8BAA8B;EAEtC;EACA;EACA,aAAa;;EAEb;;;KAIQ,6BACV,WACA;;EAIA,QAAQ,eAAe,aAAa;EACpC;EACA;EACA,aAAa;;UAGE,2BAEf,iBACA,oBAAoB,+BA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;;;;EAehE,sBAEE,kBAAkB,sBAAsB,qBAExC,QACI,eAAe,aAEf,qBACJ,SAAS,yCAEP,SAAS,wBAAwB,aACjC,SACE;IAEE,KAAK;IACL,QAAQ;;;;;;YAQN,kCAER,QAAQ,sBAEP;;;;;;iBAUY;EACf;EACA;EACA"}
@@ -138,7 +138,7 @@ var BaseLangChain = class extends Runnable {
138
138
  this.callbacks = params.callbacks;
139
139
  this.tags = params.tags ?? [];
140
140
  this.metadata = params.metadata ?? {};
141
- this._addVersion("@langchain/core", "1.2.13");
141
+ this._addVersion("@langchain/core", "1.2.16");
142
142
  }
143
143
  _addVersion(pkg, version) {
144
144
  const existing = this.metadata?.versions;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":[],"sources":["../../src/language_models/base.ts"],"sourcesContent":["import type { Tiktoken, TiktokenModel } from \"js-tiktoken/lite\";\nimport type { ZodV3Like, ZodV4Like } from \"../utils/types/zod.js\";\n\nimport { type BaseCache, InMemoryCache } from \"../caches/index.js\";\nimport {\n type BasePromptValueInterface,\n StringPromptValue,\n ChatPromptValue,\n} from \"../prompt_values.js\";\nimport {\n type BaseMessage,\n type BaseMessageLike,\n type MessageContent,\n} from \"../messages/base.js\";\nimport { coerceMessageLikeToMessage } from \"../messages/utils.js\";\nimport { type LLMResult } from \"../outputs.js\";\nimport { CallbackManager, Callbacks } from \"../callbacks/manager.js\";\nimport { AsyncCaller, AsyncCallerParams } from \"../utils/async_caller.js\";\nimport { encodingForModel } from \"../utils/tiktoken.js\";\nimport { Runnable, type RunnableInterface } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { JSONSchema } from \"../utils/json_schema.js\";\nimport {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n} from \"../utils/types/zod.js\";\nimport { ModelProfile } from \"./profile.js\";\nimport { type SerializableSchema } from \"../utils/standard_schema.js\";\n\n// https://www.npmjs.com/package/js-tiktoken\n\nexport const getModelNameForTiktoken = (modelName: string): TiktokenModel => {\n if (modelName.startsWith(\"gpt-5\")) {\n return \"gpt-5\" as TiktokenModel;\n }\n\n if (modelName.startsWith(\"gpt-3.5-turbo-16k\")) {\n return \"gpt-3.5-turbo-16k\";\n }\n\n if (modelName.startsWith(\"gpt-3.5-turbo-\")) {\n return \"gpt-3.5-turbo\";\n }\n\n if (modelName.startsWith(\"gpt-4-32k\")) {\n return \"gpt-4-32k\";\n }\n\n if (modelName.startsWith(\"gpt-4-\")) {\n return \"gpt-4\";\n }\n\n if (modelName.startsWith(\"gpt-4o\")) {\n return \"gpt-4o\";\n }\n\n return modelName as TiktokenModel;\n};\n\nexport const getEmbeddingContextSize = (modelName?: string): number => {\n switch (modelName) {\n case \"text-embedding-ada-002\":\n return 8191;\n default:\n return 2046;\n }\n};\n\n/**\n * Get the context window size (max input tokens) for a given model.\n *\n * Context window sizes are sourced from official model documentation:\n * - OpenAI: https://platform.openai.com/docs/models\n * - Anthropic: https://docs.anthropic.com/claude/docs/models-overview\n * - Google: https://ai.google.dev/gemini/docs/models/gemini\n *\n * @param modelName - The name of the model\n * @returns The context window size in tokens\n */\nexport const getModelContextSize = (modelName: string): number => {\n const normalizedName = getModelNameForTiktoken(modelName) as string;\n\n switch (normalizedName) {\n // GPT-5 series\n case \"gpt-5\":\n case \"gpt-5-turbo\":\n case \"gpt-5-turbo-preview\":\n return 400000;\n\n // GPT-4o series\n case \"gpt-4o\":\n case \"gpt-4o-mini\":\n case \"gpt-4o-2024-05-13\":\n case \"gpt-4o-2024-08-06\":\n return 128000;\n\n // GPT-4 Turbo series\n case \"gpt-4-turbo\":\n case \"gpt-4-turbo-preview\":\n case \"gpt-4-turbo-2024-04-09\":\n case \"gpt-4-0125-preview\":\n case \"gpt-4-1106-preview\":\n return 128000;\n\n // GPT-4 series\n case \"gpt-4-32k\":\n case \"gpt-4-32k-0314\":\n case \"gpt-4-32k-0613\":\n return 32768;\n case \"gpt-4\":\n case \"gpt-4-0314\":\n case \"gpt-4-0613\":\n return 8192;\n\n // GPT-3.5 Turbo series\n case \"gpt-3.5-turbo-16k\":\n case \"gpt-3.5-turbo-16k-0613\":\n return 16384;\n case \"gpt-3.5-turbo\":\n case \"gpt-3.5-turbo-0301\":\n case \"gpt-3.5-turbo-0613\":\n case \"gpt-3.5-turbo-1106\":\n case \"gpt-3.5-turbo-0125\":\n return 4096;\n\n // Legacy GPT-3 models\n case \"text-davinci-003\":\n case \"text-davinci-002\":\n return 4097;\n case \"text-davinci-001\":\n return 2049;\n case \"text-curie-001\":\n case \"text-babbage-001\":\n case \"text-ada-001\":\n return 2048;\n\n // Code models\n case \"code-davinci-002\":\n case \"code-davinci-001\":\n return 8000;\n case \"code-cushman-001\":\n return 2048;\n\n // Claude models (Anthropic)\n case \"claude-3-5-sonnet-20241022\":\n case \"claude-3-5-sonnet-20240620\":\n case \"claude-3-opus-20240229\":\n case \"claude-3-sonnet-20240229\":\n case \"claude-3-haiku-20240307\":\n case \"claude-2.1\":\n return 200000;\n case \"claude-2.0\":\n case \"claude-instant-1.2\":\n return 100000;\n\n // Gemini models (Google)\n case \"gemini-1.5-pro\":\n case \"gemini-1.5-pro-latest\":\n case \"gemini-1.5-flash\":\n case \"gemini-1.5-flash-latest\":\n return 1000000; // 1M tokens\n case \"gemini-pro\":\n case \"gemini-pro-vision\":\n return 32768;\n\n default:\n return 4097;\n }\n};\n\n/**\n * Whether or not the input matches the OpenAI tool definition.\n * @param {unknown} tool The input to check.\n * @returns {boolean} Whether the input is an OpenAI tool definition.\n */\nexport function isOpenAITool(tool: unknown): tool is ToolDefinition {\n if (typeof tool !== \"object\" || !tool) return false;\n if (\n \"type\" in tool &&\n tool.type === \"function\" &&\n \"function\" in tool &&\n typeof tool.function === \"object\" &&\n tool.function &&\n \"name\" in tool.function &&\n \"parameters\" in tool.function\n ) {\n return true;\n }\n return false;\n}\n\ninterface CalculateMaxTokenProps {\n prompt: string;\n modelName: TiktokenModel;\n}\n\nexport const calculateMaxTokens = async ({\n prompt,\n modelName,\n}: CalculateMaxTokenProps) => {\n let numTokens;\n\n try {\n numTokens = (\n await encodingForModel(getModelNameForTiktoken(modelName))\n ).encode(prompt).length;\n } catch {\n console.warn(\n \"Failed to calculate number of tokens, falling back to approximate count\"\n );\n\n // fallback to approximate calculation if tiktoken is not available\n // each token is ~4 characters: https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them#\n numTokens = Math.ceil(prompt.length / 4);\n }\n\n const maxTokens = getModelContextSize(modelName);\n return maxTokens - numTokens;\n};\n\nconst getVerbosity = () => false;\n\nexport type SerializedLLM = {\n _model: string;\n _type: string;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport interface BaseLangChainParams {\n verbose?: boolean;\n callbacks?: Callbacks;\n tags?: string[];\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Base class for language models, chains, tools.\n */\nexport abstract class BaseLangChain<\n RunInput,\n RunOutput,\n CallOptions extends RunnableConfig = RunnableConfig,\n>\n extends Runnable<RunInput, RunOutput, CallOptions>\n implements BaseLangChainParams\n{\n /**\n * Whether to print out response text.\n */\n verbose: boolean;\n\n callbacks?: Callbacks;\n\n tags?: string[];\n\n metadata?: Record<string, unknown>;\n\n get lc_attributes(): { [key: string]: undefined } | undefined {\n return {\n callbacks: undefined,\n verbose: undefined,\n };\n }\n\n constructor(params: BaseLangChainParams) {\n super(params);\n this.verbose = params.verbose ?? getVerbosity();\n this.callbacks = params.callbacks;\n this.tags = params.tags ?? [];\n this.metadata = params.metadata ?? {};\n this._addVersion(\"@langchain/core\", __PKG_VERSION__);\n }\n\n protected _addVersion(pkg: string, version: string) {\n const existing = this.metadata?.versions;\n this.metadata = {\n ...this.metadata,\n versions: {\n ...(typeof existing === \"object\" && existing !== null ? existing : {}),\n [pkg]: version,\n },\n };\n }\n}\n\n/**\n * Base interface for language model parameters.\n * A subclass of {@link BaseLanguageModel} should have a constructor that\n * takes in a parameter that extends this interface.\n */\nexport interface BaseLanguageModelParams\n extends AsyncCallerParams, BaseLangChainParams {\n /**\n * @deprecated Use `callbacks` instead\n */\n callbackManager?: CallbackManager;\n\n cache?: BaseCache | boolean;\n}\n\nexport interface BaseLanguageModelTracingCallOptions {\n /**\n * Describes the format of structured outputs.\n * This should be provided if an output is considered to be structured\n */\n ls_structured_output_format?: {\n /**\n * An object containing the method used for structured output (e.g., \"jsonMode\").\n */\n kwargs: { method: string };\n /**\n * The JSON schema describing the expected output structure.\n */\n schema?: JSONSchema;\n };\n}\n\nexport interface BaseLanguageModelCallOptions\n extends RunnableConfig, BaseLanguageModelTracingCallOptions {\n /**\n * Stop tokens to use for this call.\n * If not provided, the default stop tokens for the model will be used.\n */\n stop?: string[];\n /**\n * Overrides the model's configured `maxRetries` for this call only.\n */\n maxRetries?: number;\n}\n\nexport interface FunctionDefinition {\n /**\n * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain\n * underscores and dashes, with a maximum length of 64.\n */\n name: string;\n\n /**\n * The parameters the functions accepts, described as a JSON Schema object. See the\n * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for\n * examples, and the\n * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for\n * documentation about the format.\n *\n * To describe a function that accepts no parameters, provide the value\n * `{\"type\": \"object\", \"properties\": {}}`.\n */\n parameters: Record<string, unknown> | JSONSchema;\n\n /**\n * A description of what the function does, used by the model to choose when and\n * how to call the function.\n */\n description?: string;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: FunctionDefinition;\n}\n\nexport type FunctionCallOption = {\n name: string;\n};\n\nexport interface BaseFunctionCallOptions extends BaseLanguageModelCallOptions {\n function_call?: FunctionCallOption;\n functions?: FunctionDefinition[];\n}\n\nexport type BaseLanguageModelInput =\n | BasePromptValueInterface\n | string\n | BaseMessageLike[];\n\nexport type StructuredOutputType = InferInteropZodOutput<InteropZodObject>;\n\nexport type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> =\n {\n name?: string;\n method?: \"functionCalling\" | \"jsonMode\" | \"jsonSchema\" | string;\n includeRaw?: IncludeRaw;\n /** Whether to use strict mode. Currently only supported by OpenAI models. */\n strict?: boolean;\n };\n\n/** @deprecated Use StructuredOutputMethodOptions instead */\nexport type StructuredOutputMethodParams<\n RunOutput,\n IncludeRaw extends boolean = false,\n> = {\n /** @deprecated Pass schema in as the first argument */\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<RunOutput> | Record<string, any>;\n name?: string;\n method?: \"functionCalling\" | \"jsonMode\";\n includeRaw?: IncludeRaw;\n};\n\nexport interface BaseLanguageModelInterface<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n CallOptions extends BaseLanguageModelCallOptions =\n BaseLanguageModelCallOptions,\n> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {\n get callKeys(): string[];\n\n generatePrompt(\n promptValues: BasePromptValueInterface[],\n options?: string[] | Partial<CallOptions>,\n callbacks?: Callbacks\n ): Promise<LLMResult>;\n\n _modelType(): string;\n\n _llmType(): string;\n\n getNumTokens(content: MessageContent): Promise<number>;\n\n /**\n * Get the identifying parameters of the LLM.\n */\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n _identifyingParams(): Record<string, any>;\n\n serialize(): SerializedLLM;\n}\n\nexport type LanguageModelOutput = BaseMessage | string;\n\nexport type LanguageModelLike = RunnableInterface<\n BaseLanguageModelInput,\n LanguageModelOutput\n>;\n\n/**\n * Base class for language models.\n */\nexport abstract class BaseLanguageModel<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n CallOptions extends BaseLanguageModelCallOptions =\n BaseLanguageModelCallOptions,\n>\n extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions>\n implements\n BaseLanguageModelParams,\n BaseLanguageModelInterface<RunOutput, CallOptions>\n{\n /**\n * Keys that the language model accepts as call options.\n */\n get callKeys(): string[] {\n return [\"stop\", \"timeout\", \"signal\", \"tags\", \"metadata\", \"callbacks\"];\n }\n\n /**\n * The async caller should be used by subclasses to make any async calls,\n * which will thus benefit from the concurrency and retry logic.\n */\n caller: AsyncCaller;\n\n cache?: BaseCache;\n\n constructor({\n callbacks,\n callbackManager,\n ...params\n }: BaseLanguageModelParams) {\n const { cache, ...rest } = params;\n super({\n callbacks: callbacks ?? callbackManager,\n ...rest,\n });\n if (typeof cache === \"object\") {\n this.cache = cache;\n } else if (cache) {\n this.cache = InMemoryCache.global();\n } else {\n this.cache = undefined;\n }\n this.caller = new AsyncCaller(params ?? {});\n }\n\n abstract generatePrompt(\n promptValues: BasePromptValueInterface[],\n options?: string[] | CallOptions,\n callbacks?: Callbacks\n ): Promise<LLMResult>;\n\n abstract _modelType(): string;\n\n abstract _llmType(): string;\n\n private _encoding?: Tiktoken;\n\n /**\n * Get the number of tokens in the content.\n * @param content The content to get the number of tokens for.\n * @returns The number of tokens in the content.\n */\n async getNumTokens(content: MessageContent) {\n // Extract text content from MessageContent\n let textContent: string;\n if (typeof content === \"string\") {\n textContent = content;\n } else {\n /**\n * Content is an array of ContentBlock\n *\n * ToDo(@christian-bromann): This is a temporary fix to get the number of tokens for the content.\n * We need to find a better way to do this.\n * @see https://github.com/langchain-ai/langchainjs/pull/8341#pullrequestreview-2933713116\n */\n textContent = content\n .map((item) => {\n if (typeof item === \"string\") return item;\n if (item.type === \"text\" && \"text\" in item) return item.text;\n return \"\";\n })\n .join(\"\");\n }\n\n // fallback to approximate calculation if tiktoken is not available\n let numTokens = Math.ceil(textContent.length / 4);\n\n if (!this._encoding) {\n try {\n this._encoding = await encodingForModel(\n \"modelName\" in this\n ? getModelNameForTiktoken(this.modelName as string)\n : \"gpt2\"\n );\n } catch (error) {\n console.warn(\n \"Failed to calculate number of tokens, falling back to approximate count\",\n error\n );\n }\n }\n\n if (this._encoding) {\n try {\n numTokens = this._encoding.encode(textContent).length;\n } catch (error) {\n console.warn(\n \"Failed to calculate number of tokens, falling back to approximate count\",\n error\n );\n }\n }\n\n return numTokens;\n }\n\n protected static _convertInputToPromptValue(\n input: BaseLanguageModelInput\n ): BasePromptValueInterface {\n if (typeof input === \"string\") {\n return new StringPromptValue(input);\n } else if (Array.isArray(input)) {\n return new ChatPromptValue(input.map(coerceMessageLikeToMessage));\n } else {\n return input;\n }\n }\n\n /**\n * Get the identifying parameters of the LLM.\n */\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n _identifyingParams(): Record<string, any> {\n return {};\n }\n\n /**\n * Create a unique cache key for a specific call to a specific language model.\n * @param callOptions Call options for the model\n * @returns A unique cache key.\n */\n _getSerializedCacheKeyParametersForCall(\n // TODO: Fix when we remove the RunnableLambda backwards compatibility shim.\n {\n config,\n ...callOptions\n }: CallOptions & { config?: RunnableConfig }\n ): string {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const params: Record<string, any> = {\n ...this._identifyingParams(),\n ...callOptions,\n _type: this._llmType(),\n _model: this._modelType(),\n };\n const filteredEntries = Object.entries(params).filter(\n ([_, value]) => value !== undefined\n );\n const serializedEntries = filteredEntries\n .map(([key, value]) => `${key}:${JSON.stringify(value)}`)\n .sort()\n .join(\",\");\n return serializedEntries;\n }\n\n /**\n * @deprecated\n * Return a json-like object representing this LLM.\n */\n serialize(): SerializedLLM {\n return {\n ...this._identifyingParams(),\n _type: this._llmType(),\n _model: this._modelType(),\n };\n }\n\n /**\n * @deprecated\n * Load an LLM from a json-like object describing it.\n */\n static async deserialize(_data: SerializedLLM): Promise<BaseLanguageModel> {\n throw new Error(\"Use .toJSON() instead\");\n }\n\n /**\n * Return profiling information for the model.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile {\n return {};\n }\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema: SerializableSchema<RunOutput>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema: SerializableSchema<RunOutput>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV3Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV3Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV4Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV4Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n /**\n * Model wrapper that returns outputs formatted to match the given schema.\n *\n * @template {BaseLanguageModelInput} RunInput The input type for the Runnable, expected to be the same input for the LLM.\n * @template {Record<string, any>} RunOutput The output type for the Runnable, expected to be a Zod schema object for structured output validation.\n *\n * @param {InteropZodType<RunOutput>} schema The schema for the structured output. Either as a Zod schema or a valid JSON schema object.\n * If a Zod schema is passed, the returned attributes will be validated, whereas with JSON schema they will not be.\n * @param {string} name The name of the function to call.\n * @param {\"functionCalling\" | \"jsonMode\"} [method=functionCalling] The method to use for getting the structured output. Defaults to \"functionCalling\".\n * @param {boolean | undefined} [includeRaw=false] Whether to include the raw output in the result. Defaults to false.\n * @returns {Runnable<RunInput, RunOutput> | Runnable<RunInput, { raw: BaseMessage; parsed: RunOutput }>} A new runnable that calls the LLM with structured output.\n */\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | InteropZodType<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n {\n raw: BaseMessage;\n parsed: RunOutput;\n }\n >;\n\n /**\n * Filter out large/inappropriate fields from invocation params for tracing metadata.\n * Removes fields like tools, functions, messages, response_format that can be large.\n */\n protected _filterInvocationParamsForTracing(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n params: Record<string, any>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n ): Record<string, any> {\n const { tools, functions, messages, response_format, ...rest } = params;\n return rest;\n }\n}\n\n/**\n * Shared interface for token usage\n * return type from LLM calls.\n */\nexport interface TokenUsage {\n completionTokens?: number;\n promptTokens?: number;\n totalTokens?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAa,2BAA2B,cAAqC;CAC3E,IAAI,UAAU,WAAW,OAAO,GAC9B,OAAO;CAGT,IAAI,UAAU,WAAW,mBAAmB,GAC1C,OAAO;CAGT,IAAI,UAAU,WAAW,gBAAgB,GACvC,OAAO;CAGT,IAAI,UAAU,WAAW,WAAW,GAClC,OAAO;CAGT,IAAI,UAAU,WAAW,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ACe;CACzB;;;;;CAMA,YAA2B;EACzB,OAAO;GACL,GAAG,KAAK,mBAAmB;GAC3B,OAAO,KAAK,SAAS;GACrB,QAAQ,KAAK,WAAW;EAC1B;CACF;;;;;CAMA,aAAa,YAAY,OAAkD;EACzE,MAAM,IAAI,MAAM,uBAAuB;CACzC;;;;;;CAOA,IAAI,UAAwB;EAC1B,OAAO,CAAC;CACV;;;;;CAkGA,kCAEE,QAEqB;EACrB,MAAM,EAAE,OAAO,WAAW,UAAU,iBAAiB,GAAG,SAAS;EACjE,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../src/language_models/base.ts"],"sourcesContent":["import type { Tiktoken, TiktokenModel } from \"js-tiktoken/lite\";\nimport type { ZodV3Like, ZodV4Like } from \"../utils/types/zod.js\";\n\nimport { type BaseCache, InMemoryCache } from \"../caches/index.js\";\nimport {\n type BasePromptValueInterface,\n StringPromptValue,\n ChatPromptValue,\n} from \"../prompt_values.js\";\nimport {\n type BaseMessage,\n type BaseMessageLike,\n type MessageContent,\n} from \"../messages/base.js\";\nimport { coerceMessageLikeToMessage } from \"../messages/utils.js\";\nimport { type LLMResult } from \"../outputs.js\";\nimport { CallbackManager, Callbacks } from \"../callbacks/manager.js\";\nimport { AsyncCaller, AsyncCallerParams } from \"../utils/async_caller.js\";\nimport { encodingForModel } from \"../utils/tiktoken.js\";\nimport { Runnable, type RunnableInterface } from \"../runnables/base.js\";\nimport { RunnableConfig } from \"../runnables/config.js\";\nimport { JSONSchema } from \"../utils/json_schema.js\";\nimport {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n} from \"../utils/types/zod.js\";\nimport { ModelProfile } from \"./profile.js\";\nimport { type SerializableSchema } from \"../utils/standard_schema.js\";\n\n// https://www.npmjs.com/package/js-tiktoken\n\nexport const getModelNameForTiktoken = (modelName: string): TiktokenModel => {\n if (modelName.startsWith(\"gpt-5\")) {\n return \"gpt-5\" as TiktokenModel;\n }\n\n if (modelName.startsWith(\"gpt-3.5-turbo-16k\")) {\n return \"gpt-3.5-turbo-16k\";\n }\n\n if (modelName.startsWith(\"gpt-3.5-turbo-\")) {\n return \"gpt-3.5-turbo\";\n }\n\n if (modelName.startsWith(\"gpt-4-32k\")) {\n return \"gpt-4-32k\";\n }\n\n if (modelName.startsWith(\"gpt-4-\")) {\n return \"gpt-4\";\n }\n\n if (modelName.startsWith(\"gpt-4o\")) {\n return \"gpt-4o\";\n }\n\n return modelName as TiktokenModel;\n};\n\nexport const getEmbeddingContextSize = (modelName?: string): number => {\n switch (modelName) {\n case \"text-embedding-ada-002\":\n return 8191;\n default:\n return 2046;\n }\n};\n\n/**\n * Get the context window size (max input tokens) for a given model.\n *\n * Context window sizes are sourced from official model documentation:\n * - OpenAI: https://platform.openai.com/docs/models\n * - Anthropic: https://docs.anthropic.com/claude/docs/models-overview\n * - Google: https://ai.google.dev/gemini/docs/models/gemini\n *\n * @param modelName - The name of the model\n * @returns The context window size in tokens\n */\nexport const getModelContextSize = (modelName: string): number => {\n const normalizedName = getModelNameForTiktoken(modelName) as string;\n\n switch (normalizedName) {\n // GPT-5 series\n case \"gpt-5\":\n case \"gpt-5-turbo\":\n case \"gpt-5-turbo-preview\":\n return 400000;\n\n // GPT-4o series\n case \"gpt-4o\":\n case \"gpt-4o-mini\":\n case \"gpt-4o-2024-05-13\":\n case \"gpt-4o-2024-08-06\":\n return 128000;\n\n // GPT-4 Turbo series\n case \"gpt-4-turbo\":\n case \"gpt-4-turbo-preview\":\n case \"gpt-4-turbo-2024-04-09\":\n case \"gpt-4-0125-preview\":\n case \"gpt-4-1106-preview\":\n return 128000;\n\n // GPT-4 series\n case \"gpt-4-32k\":\n case \"gpt-4-32k-0314\":\n case \"gpt-4-32k-0613\":\n return 32768;\n case \"gpt-4\":\n case \"gpt-4-0314\":\n case \"gpt-4-0613\":\n return 8192;\n\n // GPT-3.5 Turbo series\n case \"gpt-3.5-turbo-16k\":\n case \"gpt-3.5-turbo-16k-0613\":\n return 16384;\n case \"gpt-3.5-turbo\":\n case \"gpt-3.5-turbo-0301\":\n case \"gpt-3.5-turbo-0613\":\n case \"gpt-3.5-turbo-1106\":\n case \"gpt-3.5-turbo-0125\":\n return 4096;\n\n // Legacy GPT-3 models\n case \"text-davinci-003\":\n case \"text-davinci-002\":\n return 4097;\n case \"text-davinci-001\":\n return 2049;\n case \"text-curie-001\":\n case \"text-babbage-001\":\n case \"text-ada-001\":\n return 2048;\n\n // Code models\n case \"code-davinci-002\":\n case \"code-davinci-001\":\n return 8000;\n case \"code-cushman-001\":\n return 2048;\n\n // Claude models (Anthropic)\n case \"claude-3-5-sonnet-20241022\":\n case \"claude-3-5-sonnet-20240620\":\n case \"claude-3-opus-20240229\":\n case \"claude-3-sonnet-20240229\":\n case \"claude-3-haiku-20240307\":\n case \"claude-2.1\":\n return 200000;\n case \"claude-2.0\":\n case \"claude-instant-1.2\":\n return 100000;\n\n // Gemini models (Google)\n case \"gemini-1.5-pro\":\n case \"gemini-1.5-pro-latest\":\n case \"gemini-1.5-flash\":\n case \"gemini-1.5-flash-latest\":\n return 1000000; // 1M tokens\n case \"gemini-pro\":\n case \"gemini-pro-vision\":\n return 32768;\n\n default:\n return 4097;\n }\n};\n\n/**\n * Whether or not the input matches the OpenAI tool definition.\n * @param {unknown} tool The input to check.\n * @returns {boolean} Whether the input is an OpenAI tool definition.\n */\nexport function isOpenAITool(tool: unknown): tool is ToolDefinition {\n if (typeof tool !== \"object\" || !tool) return false;\n if (\n \"type\" in tool &&\n tool.type === \"function\" &&\n \"function\" in tool &&\n typeof tool.function === \"object\" &&\n tool.function &&\n \"name\" in tool.function &&\n \"parameters\" in tool.function\n ) {\n return true;\n }\n return false;\n}\n\ninterface CalculateMaxTokenProps {\n prompt: string;\n modelName: TiktokenModel;\n}\n\nexport const calculateMaxTokens = async ({\n prompt,\n modelName,\n}: CalculateMaxTokenProps) => {\n let numTokens;\n\n try {\n numTokens = (\n await encodingForModel(getModelNameForTiktoken(modelName))\n ).encode(prompt).length;\n } catch {\n console.warn(\n \"Failed to calculate number of tokens, falling back to approximate count\"\n );\n\n // fallback to approximate calculation if tiktoken is not available\n // each token is ~4 characters: https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them#\n numTokens = Math.ceil(prompt.length / 4);\n }\n\n const maxTokens = getModelContextSize(modelName);\n return maxTokens - numTokens;\n};\n\nconst getVerbosity = () => false;\n\nexport type SerializedLLM = {\n _model: string;\n _type: string;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport interface BaseLangChainParams {\n verbose?: boolean;\n callbacks?: Callbacks;\n tags?: string[];\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Base class for language models, chains, tools.\n */\nexport abstract class BaseLangChain<\n RunInput,\n RunOutput,\n CallOptions extends RunnableConfig = RunnableConfig,\n>\n extends Runnable<RunInput, RunOutput, CallOptions>\n implements BaseLangChainParams\n{\n /**\n * Whether to print out response text.\n */\n verbose: boolean;\n\n callbacks?: Callbacks;\n\n tags?: string[];\n\n metadata?: Record<string, unknown>;\n\n get lc_attributes(): { [key: string]: undefined } | undefined {\n return {\n callbacks: undefined,\n verbose: undefined,\n };\n }\n\n constructor(params: BaseLangChainParams) {\n super(params);\n this.verbose = params.verbose ?? getVerbosity();\n this.callbacks = params.callbacks;\n this.tags = params.tags ?? [];\n this.metadata = params.metadata ?? {};\n this._addVersion(\"@langchain/core\", __PKG_VERSION__);\n }\n\n protected _addVersion(pkg: string, version: string) {\n const existing = this.metadata?.versions;\n this.metadata = {\n ...this.metadata,\n versions: {\n ...(typeof existing === \"object\" && existing !== null ? existing : {}),\n [pkg]: version,\n },\n };\n }\n}\n\n/**\n * Base interface for language model parameters.\n * A subclass of {@link BaseLanguageModel} should have a constructor that\n * takes in a parameter that extends this interface.\n */\nexport interface BaseLanguageModelParams\n extends AsyncCallerParams, BaseLangChainParams {\n /**\n * @deprecated Use `callbacks` instead\n */\n callbackManager?: CallbackManager;\n\n cache?: BaseCache | boolean;\n}\n\nexport interface BaseLanguageModelTracingCallOptions {\n /**\n * Describes the format of structured outputs.\n * This should be provided if an output is considered to be structured\n */\n ls_structured_output_format?: {\n /**\n * An object containing the method used for structured output (e.g., \"jsonMode\").\n */\n kwargs: { method: string };\n /**\n * The JSON schema describing the expected output structure.\n */\n schema?: JSONSchema;\n };\n}\n\nexport interface BaseLanguageModelCallOptions\n extends RunnableConfig, BaseLanguageModelTracingCallOptions {\n /**\n * Stop tokens to use for this call.\n * If not provided, the default stop tokens for the model will be used.\n */\n stop?: string[];\n /**\n * Overrides the model's configured `maxRetries` for this call only.\n */\n maxRetries?: number;\n}\n\nexport interface FunctionDefinition {\n /**\n * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain\n * underscores and dashes, with a maximum length of 64.\n */\n name: string;\n\n /**\n * The parameters the functions accepts, described as a JSON Schema object. See the\n * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for\n * examples, and the\n * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for\n * documentation about the format.\n *\n * To describe a function that accepts no parameters, provide the value\n * `{\"type\": \"object\", \"properties\": {}}`.\n */\n parameters: Record<string, unknown> | JSONSchema;\n\n /**\n * A description of what the function does, used by the model to choose when and\n * how to call the function.\n */\n description?: string;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: FunctionDefinition;\n}\n\nexport type FunctionCallOption = {\n name: string;\n};\n\nexport interface BaseFunctionCallOptions extends BaseLanguageModelCallOptions {\n function_call?: FunctionCallOption;\n functions?: FunctionDefinition[];\n}\n\nexport type BaseLanguageModelInput =\n | BasePromptValueInterface\n | string\n | BaseMessageLike[];\n\nexport type StructuredOutputType = InferInteropZodOutput<InteropZodObject>;\n\nexport type StructuredOutputMethodOptions<IncludeRaw extends boolean = false> =\n {\n name?: string;\n method?: \"functionCalling\" | \"jsonMode\" | \"jsonSchema\" | string;\n includeRaw?: IncludeRaw;\n /** Whether to use strict mode. Currently only supported by OpenAI models. */\n strict?: boolean;\n };\n\n/** @deprecated Use StructuredOutputMethodOptions instead */\nexport type StructuredOutputMethodParams<\n RunOutput,\n IncludeRaw extends boolean = false,\n> = {\n /** @deprecated Pass schema in as the first argument */\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<RunOutput> | Record<string, any>;\n name?: string;\n method?: \"functionCalling\" | \"jsonMode\";\n includeRaw?: IncludeRaw;\n};\n\nexport interface BaseLanguageModelInterface<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n CallOptions extends BaseLanguageModelCallOptions =\n BaseLanguageModelCallOptions,\n> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {\n get callKeys(): string[];\n\n generatePrompt(\n promptValues: BasePromptValueInterface[],\n options?: string[] | Partial<CallOptions>,\n callbacks?: Callbacks\n ): Promise<LLMResult>;\n\n _modelType(): string;\n\n _llmType(): string;\n\n getNumTokens(content: MessageContent): Promise<number>;\n\n /**\n * Get the identifying parameters of the LLM.\n */\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n _identifyingParams(): Record<string, any>;\n\n serialize(): SerializedLLM;\n}\n\nexport type LanguageModelOutput = BaseMessage | string;\n\nexport type LanguageModelLike = RunnableInterface<\n BaseLanguageModelInput,\n LanguageModelOutput\n>;\n\n/**\n * Base class for language models.\n */\nexport abstract class BaseLanguageModel<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n CallOptions extends BaseLanguageModelCallOptions =\n BaseLanguageModelCallOptions,\n>\n extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions>\n implements\n BaseLanguageModelParams,\n BaseLanguageModelInterface<RunOutput, CallOptions>\n{\n /**\n * Keys that the language model accepts as call options.\n */\n get callKeys(): string[] {\n return [\"stop\", \"timeout\", \"signal\", \"tags\", \"metadata\", \"callbacks\"];\n }\n\n /**\n * The async caller should be used by subclasses to make any async calls,\n * which will thus benefit from the concurrency and retry logic.\n */\n caller: AsyncCaller;\n\n cache?: BaseCache;\n\n constructor({\n callbacks,\n callbackManager,\n ...params\n }: BaseLanguageModelParams) {\n const { cache, ...rest } = params;\n super({\n callbacks: callbacks ?? callbackManager,\n ...rest,\n });\n if (typeof cache === \"object\") {\n this.cache = cache;\n } else if (cache) {\n this.cache = InMemoryCache.global();\n } else {\n this.cache = undefined;\n }\n this.caller = new AsyncCaller(params ?? {});\n }\n\n abstract generatePrompt(\n promptValues: BasePromptValueInterface[],\n options?: string[] | CallOptions,\n callbacks?: Callbacks\n ): Promise<LLMResult>;\n\n abstract _modelType(): string;\n\n abstract _llmType(): string;\n\n private _encoding?: Tiktoken;\n\n /**\n * Get the number of tokens in the content.\n * @param content The content to get the number of tokens for.\n * @returns The number of tokens in the content.\n */\n async getNumTokens(content: MessageContent) {\n // Extract text content from MessageContent\n let textContent: string;\n if (typeof content === \"string\") {\n textContent = content;\n } else {\n /**\n * Content is an array of ContentBlock\n *\n * ToDo(@christian-bromann): This is a temporary fix to get the number of tokens for the content.\n * We need to find a better way to do this.\n * @see https://github.com/langchain-ai/langchainjs/pull/8341#pullrequestreview-2933713116\n */\n textContent = content\n .map((item) => {\n if (typeof item === \"string\") return item;\n if (item.type === \"text\" && \"text\" in item) return item.text;\n return \"\";\n })\n .join(\"\");\n }\n\n // fallback to approximate calculation if tiktoken is not available\n let numTokens = Math.ceil(textContent.length / 4);\n\n if (!this._encoding) {\n try {\n this._encoding = await encodingForModel(\n \"modelName\" in this\n ? getModelNameForTiktoken(this.modelName as string)\n : \"gpt2\"\n );\n } catch (error) {\n console.warn(\n \"Failed to calculate number of tokens, falling back to approximate count\",\n error\n );\n }\n }\n\n if (this._encoding) {\n try {\n numTokens = this._encoding.encode(textContent).length;\n } catch (error) {\n console.warn(\n \"Failed to calculate number of tokens, falling back to approximate count\",\n error\n );\n }\n }\n\n return numTokens;\n }\n\n protected static _convertInputToPromptValue(\n input: BaseLanguageModelInput\n ): BasePromptValueInterface {\n if (typeof input === \"string\") {\n return new StringPromptValue(input);\n } else if (Array.isArray(input)) {\n return new ChatPromptValue(input.map(coerceMessageLikeToMessage));\n } else {\n return input;\n }\n }\n\n /**\n * Get the identifying parameters of the LLM.\n */\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n _identifyingParams(): Record<string, any> {\n return {};\n }\n\n /**\n * Create a unique cache key for a specific call to a specific language model.\n * @param callOptions Call options for the model\n * @returns A unique cache key.\n */\n _getSerializedCacheKeyParametersForCall(\n // TODO: Fix when we remove the RunnableLambda backwards compatibility shim.\n { config, ...callOptions }: CallOptions & { config?: RunnableConfig }\n ): string {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const params: Record<string, any> = {\n ...this._identifyingParams(),\n ...callOptions,\n _type: this._llmType(),\n _model: this._modelType(),\n };\n const filteredEntries = Object.entries(params).filter(\n ([_, value]) => value !== undefined\n );\n const serializedEntries = filteredEntries\n .map(([key, value]) => `${key}:${JSON.stringify(value)}`)\n .sort()\n .join(\",\");\n return serializedEntries;\n }\n\n /**\n * @deprecated\n * Return a json-like object representing this LLM.\n */\n serialize(): SerializedLLM {\n return {\n ...this._identifyingParams(),\n _type: this._llmType(),\n _model: this._modelType(),\n };\n }\n\n /**\n * @deprecated\n * Load an LLM from a json-like object describing it.\n */\n static async deserialize(_data: SerializedLLM): Promise<BaseLanguageModel> {\n throw new Error(\"Use .toJSON() instead\");\n }\n\n /**\n * Return profiling information for the model.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile {\n return {};\n }\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema: SerializableSchema<RunOutput>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema: SerializableSchema<RunOutput>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV3Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV3Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV4Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | ZodV4Like<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n /**\n * Model wrapper that returns outputs formatted to match the given schema.\n *\n * @template {BaseLanguageModelInput} RunInput The input type for the Runnable, expected to be the same input for the LLM.\n * @template {Record<string, any>} RunOutput The output type for the Runnable, expected to be a Zod schema object for structured output validation.\n *\n * @param {InteropZodType<RunOutput>} schema The schema for the structured output. Either as a Zod schema or a valid JSON schema object.\n * If a Zod schema is passed, the returned attributes will be validated, whereas with JSON schema they will not be.\n * @param {string} name The name of the function to call.\n * @param {\"functionCalling\" | \"jsonMode\"} [method=functionCalling] The method to use for getting the structured output. Defaults to \"functionCalling\".\n * @param {boolean | undefined} [includeRaw=false] Whether to include the raw output in the result. Defaults to false.\n * @returns {Runnable<RunInput, RunOutput> | Runnable<RunInput, { raw: BaseMessage; parsed: RunOutput }>} A new runnable that calls the LLM with structured output.\n */\n withStructuredOutput?<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n schema:\n | InteropZodType<RunOutput>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n {\n raw: BaseMessage;\n parsed: RunOutput;\n }\n >;\n\n /**\n * Filter out large/inappropriate fields from invocation params for tracing metadata.\n * Removes fields like tools, functions, messages, response_format that can be large.\n */\n protected _filterInvocationParamsForTracing(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n params: Record<string, any>\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n ): Record<string, any> {\n const { tools, functions, messages, response_format, ...rest } = params;\n return rest;\n }\n}\n\n/**\n * Shared interface for token usage\n * return type from LLM calls.\n */\nexport interface TokenUsage {\n completionTokens?: number;\n promptTokens?: number;\n totalTokens?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAa,2BAA2B,cAAqC;CAC3E,IAAI,UAAU,WAAW,OAAO,GAC9B,OAAO;CAGT,IAAI,UAAU,WAAW,mBAAmB,GAC1C,OAAO;CAGT,IAAI,UAAU,WAAW,gBAAgB,GACvC,OAAO;CAGT,IAAI,UAAU,WAAW,WAAW,GAClC,OAAO;CAGT,IAAI,UAAU,WAAW,QAAQ,GAC/B,OAAO;CAGT,IAAI,UAAU,WAAW,QAAQ,GAC/B,OAAO;CAGT,OAAO;AACT;AAEA,MAA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;GACrB,QAAQ,KAAK,WAAW;EAC1B;CACF;;;;;CAMA,aAAa,YAAY,OAAkD;EACzE,MAAM,IAAI,MAAM,uBAAuB;CACzC;;;;;;CAOA,IAAI,UAAwB;EAC1B,OAAO,CAAC;CACV;;;;;CAkGA,kCAEE,QAEqB;EACrB,MAAM,EAAE,OAAO,WAAW,UAAU,iBAAiB,GAAG,SAAS;EACjE,OAAO;CACT;AACF"}
@@ -19,25 +19,25 @@ import { StructuredToolInterface, StructuredToolParams } from "../tools/types.cj
19
19
  import "../tools/index.cjs";
20
20
  import { ChatModelStream } from "./stream.cjs";
21
21
  //#region src/language_models/chat_models.d.ts
22
- type ToolChoice = string | Record<string, any> | "auto" | "any";
22
+ export type ToolChoice = string | Record<string, any> | "auto" | "any";
23
23
  /**
24
24
  * Represents a serialized chat model.
25
25
  */
26
- type SerializedChatModel = {
26
+ export type SerializedChatModel = {
27
27
  _model: string;
28
28
  _type: string;
29
29
  } & Record<string, any>;
30
30
  /**
31
31
  * Represents a serialized large language model.
32
32
  */
33
- type SerializedLLM = {
33
+ export type SerializedLLM = {
34
34
  _model: string;
35
35
  _type: string;
36
36
  } & Record<string, any>;
37
37
  /**
38
38
  * Represents the parameters for a base chat model.
39
39
  */
40
- type BaseChatModelParams = BaseLanguageModelParams & {
40
+ export type BaseChatModelParams = BaseLanguageModelParams & {
41
41
  /**
42
42
  * Whether to disable streaming.
43
43
  *
@@ -68,7 +68,7 @@ type BaseChatModelParams = BaseLanguageModelParams & {
68
68
  /**
69
69
  * Represents the call options for a base chat model.
70
70
  */
71
- type BaseChatModelCallOptions = BaseLanguageModelCallOptions & {
71
+ export type BaseChatModelCallOptions = BaseLanguageModelCallOptions & {
72
72
  /**
73
73
  * Specifies how the chat model should use tools.
74
74
  * @default undefined
@@ -101,7 +101,7 @@ type BaseChatModelCallOptions = BaseLanguageModelCallOptions & {
101
101
  */
102
102
  outputVersion?: MessageOutputVersion;
103
103
  };
104
- type LangSmithParams = {
104
+ export type LangSmithParams = {
105
105
  ls_provider?: string;
106
106
  ls_model_name?: string;
107
107
  ls_model_type: "chat";
@@ -110,12 +110,12 @@ type LangSmithParams = {
110
110
  ls_stop?: Array<string>;
111
111
  ls_integration?: string;
112
112
  };
113
- type BindToolsInput = StructuredToolInterface | Record<string, any> | ToolDefinition | RunnableToolLike | StructuredToolParams;
113
+ export type BindToolsInput = StructuredToolInterface | Record<string, any> | ToolDefinition | RunnableToolLike | StructuredToolParams;
114
114
  /**
115
115
  * Base class for chat models. It extends the BaseLanguageModel class and
116
116
  * provides methods for generating chat based on input messages.
117
117
  */
118
- declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions, OutputMessageType extends BaseMessageChunk = AIMessageChunk> extends BaseLanguageModel<OutputMessageType, CallOptions> {
118
+ export declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions, OutputMessageType extends BaseMessageChunk = AIMessageChunk> extends BaseLanguageModel<OutputMessageType, CallOptions> {
119
119
  ParsedCallOptions: Omit<CallOptions, Exclude<keyof RunnableConfig, "signal" | "timeout" | "maxConcurrency">>;
120
120
  lc_namespace: string[];
121
121
  disableStreaming: boolean;
@@ -327,10 +327,9 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
327
327
  * An abstract class that extends BaseChatModel and provides a simple
328
328
  * implementation of _generate.
329
329
  */
330
- declare abstract class SimpleChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions> extends BaseChatModel<CallOptions> {
330
+ export declare abstract class SimpleChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions> extends BaseChatModel<CallOptions> {
331
331
  abstract _call(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<string>;
332
332
  _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
333
333
  }
334
334
  //#endregion
335
- export { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams, BindToolsInput, LangSmithParams, SerializedChatModel, SerializedLLM, SimpleChatModel, ToolChoice };
336
335
  //# sourceMappingURL=chat_models.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.d.cts","names":[],"sources":["../../src/language_models/chat_models.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;KA+EY,sBAAsB;;;;KAKtB;EACV;EACA;IAEE;;;;KAMQ;EACV;EACA;IAEE;;;;KAKQ,sBAAsB;;;;;;;;;;EAUhC;;;;;;;;;;;;;;;;EAgBA,gBAAgB;;;;;KAMN,2BAA2B;;;;;;;;;;;;;;;EAerC,cAAc;;;;;;;;;;;;;;;;EAgBd,gBAAgB;;KA+BN;EACV;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;KAGU,iBACR,0BAEA,sBACA,iBACA,mBACA;;;;;uBAMkB,cACpB,oBAAoB,2BAA2B,0BAE/C,0BAA0B,mBAAmB,wBACrC,kBAAkB,mBAAmB;EAErC,mBAAmB,KACzB,aACA,cAAc;EAIhB;EAEA;EAEA,gBAAgB;MAEZ;EAIJ,YAAY,QAAQ;EAYpB,sBACK,YAAY,2BACd;YAEO,6CACR,UAAU,QAAQ,gBAChB;;;;;;;;;EAgBJ,WACE,OAAO,kBACP,SAAS,QAAQ,eAChB,SAAS,wBAAwB,mBAAmB;;;;;;;EAQjD,OACJ,OAAO,wBACP,UAAU,QAAQ,eACjB,QAAQ;EAaJ,sBACL,WAAW,eACX,qCACA,cAAc,2BACb,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BX,uBACL,UAAU,eACV,oCACA,aAAa,2BACZ,eAAe;;;;;EAUlB,aACE,OAAO,wBACP,SAAS,QAAQ;IAAiB;KAClC,gBAAgB,KAAK,gDACpB,uBAAuB;;;;;EAM1B,aACE,OAAO,wBACP,SAAS,QAAQ;IACf;IACA;KAEF,gBAAgB,KAAK,gDACpB,uBAAuB;;;;;EAM1B,aACE,OAAO,wBACP,SAAS,QAAQ;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,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;EAEhE,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;;;;;;uBAqG5C,gBACpB,oBAAoB,2BAA2B,kCACvC,cAAc;WACb,MACP,UAAU,eACV,oCACA,aAAa,2BACZ;EAEG,UACJ,UAAU,eACV,oCACA,aAAa,2BACZ,QAAQ"}
1
+ {"version":3,"file":"chat_models.d.cts","names":[],"sources":["../../src/language_models/chat_models.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;YA+EY,sBAAsB;;;;YAKtB;EACV;EACA;IAEE;;;;YAMQ;EACV;EACA;IAEE;;;;YAKQ,sBAAsB;;;;;;;;;;EAUhC;;;;;;;;;;;;;;;;EAgBA,gBAAgB;;;;;YAMN,2BAA2B;;;;;;;;;;;;;;;EAerC,cAAc;;;;;;;;;;;;;;;;EAgBd,gBAAgB;;YA+BN;EACV;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;YAGU,iBACR,0BAEA,sBACA,iBACA,mBACA;;;;;8BAMkB,cACpB,oBAAoB,2BAA2B,0BAE/C,0BAA0B,mBAAmB,wBACrC,kBAAkB,mBAAmB;EAErC,mBAAmB,KACzB,aACA,cAAc;EAIhB;EAEA;EAEA,gBAAgB;MAEZ;EAIJ,YAAY,QAAQ;EAYpB,sBACK,YAAY,2BACd;YAEO,6CACR,UAAU,QAAQ,gBAChB;;;;;;;;;EAgBJ,WACE,OAAO,kBACP,SAAS,QAAQ,eAChB,SAAS,wBAAwB,mBAAmB;;;;;;;EAQjD,OAC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,oCACA,mBAAmB;;;;EASrB,iBAAiB;EAIjB;WAIS;;;;;;;;EASH,eACJ,cAAc,4BACd,qBAAqB,QAAQ,cAC7B,YAAY,YACX,QAAQ;WAOF,UACP,UAAU,eACV,oCACA,aAAa,2BACZ,QAAQ;EAEX,qBAEE,kBAAkB,sBAAsB,qBAExC,cAAc,mBAAmB,YACjC,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cAAc,mBAAmB,YACjC,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;EAEhE,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;EAEhE,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;;;;;;8BAqG5C,gBACpB,oBAAoB,2BAA2B,kCACvC,cAAc;WACb,MACP,UAAU,eACV,oCACA,aAAa,2BACZ;EAEG,UACJ,UAAU,eACV,oCACA,aAAa,2BACZ,QAAQ"}
@@ -19,25 +19,25 @@ import { StructuredToolInterface, StructuredToolParams } from "../tools/types.js
19
19
  import "../tools/index.js";
20
20
  import { ChatModelStream } from "./stream.js";
21
21
  //#region src/language_models/chat_models.d.ts
22
- type ToolChoice = string | Record<string, any> | "auto" | "any";
22
+ export type ToolChoice = string | Record<string, any> | "auto" | "any";
23
23
  /**
24
24
  * Represents a serialized chat model.
25
25
  */
26
- type SerializedChatModel = {
26
+ export type SerializedChatModel = {
27
27
  _model: string;
28
28
  _type: string;
29
29
  } & Record<string, any>;
30
30
  /**
31
31
  * Represents a serialized large language model.
32
32
  */
33
- type SerializedLLM = {
33
+ export type SerializedLLM = {
34
34
  _model: string;
35
35
  _type: string;
36
36
  } & Record<string, any>;
37
37
  /**
38
38
  * Represents the parameters for a base chat model.
39
39
  */
40
- type BaseChatModelParams = BaseLanguageModelParams & {
40
+ export type BaseChatModelParams = BaseLanguageModelParams & {
41
41
  /**
42
42
  * Whether to disable streaming.
43
43
  *
@@ -68,7 +68,7 @@ type BaseChatModelParams = BaseLanguageModelParams & {
68
68
  /**
69
69
  * Represents the call options for a base chat model.
70
70
  */
71
- type BaseChatModelCallOptions = BaseLanguageModelCallOptions & {
71
+ export type BaseChatModelCallOptions = BaseLanguageModelCallOptions & {
72
72
  /**
73
73
  * Specifies how the chat model should use tools.
74
74
  * @default undefined
@@ -101,7 +101,7 @@ type BaseChatModelCallOptions = BaseLanguageModelCallOptions & {
101
101
  */
102
102
  outputVersion?: MessageOutputVersion;
103
103
  };
104
- type LangSmithParams = {
104
+ export type LangSmithParams = {
105
105
  ls_provider?: string;
106
106
  ls_model_name?: string;
107
107
  ls_model_type: "chat";
@@ -110,12 +110,12 @@ type LangSmithParams = {
110
110
  ls_stop?: Array<string>;
111
111
  ls_integration?: string;
112
112
  };
113
- type BindToolsInput = StructuredToolInterface | Record<string, any> | ToolDefinition | RunnableToolLike | StructuredToolParams;
113
+ export type BindToolsInput = StructuredToolInterface | Record<string, any> | ToolDefinition | RunnableToolLike | StructuredToolParams;
114
114
  /**
115
115
  * Base class for chat models. It extends the BaseLanguageModel class and
116
116
  * provides methods for generating chat based on input messages.
117
117
  */
118
- declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions, OutputMessageType extends BaseMessageChunk = AIMessageChunk> extends BaseLanguageModel<OutputMessageType, CallOptions> {
118
+ export declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions, OutputMessageType extends BaseMessageChunk = AIMessageChunk> extends BaseLanguageModel<OutputMessageType, CallOptions> {
119
119
  ParsedCallOptions: Omit<CallOptions, Exclude<keyof RunnableConfig, "signal" | "timeout" | "maxConcurrency">>;
120
120
  lc_namespace: string[];
121
121
  disableStreaming: boolean;
@@ -327,10 +327,9 @@ declare abstract class BaseChatModel<CallOptions extends BaseChatModelCallOption
327
327
  * An abstract class that extends BaseChatModel and provides a simple
328
328
  * implementation of _generate.
329
329
  */
330
- declare abstract class SimpleChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions> extends BaseChatModel<CallOptions> {
330
+ export declare abstract class SimpleChatModel<CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions> extends BaseChatModel<CallOptions> {
331
331
  abstract _call(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<string>;
332
332
  _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
333
333
  }
334
334
  //#endregion
335
- export { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams, BindToolsInput, LangSmithParams, SerializedChatModel, SerializedLLM, SimpleChatModel, ToolChoice };
336
335
  //# sourceMappingURL=chat_models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.d.ts","names":[],"sources":["../../src/language_models/chat_models.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;KA+EY,sBAAsB;;;;KAKtB;EACV;EACA;IAEE;;;;KAMQ;EACV;EACA;IAEE;;;;KAKQ,sBAAsB;;;;;;;;;;EAUhC;;;;;;;;;;;;;;;;EAgBA,gBAAgB;;;;;KAMN,2BAA2B;;;;;;;;;;;;;;;EAerC,cAAc;;;;;;;;;;;;;;;;EAgBd,gBAAgB;;KA+BN;EACV;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;KAGU,iBACR,0BAEA,sBACA,iBACA,mBACA;;;;;uBAMkB,cACpB,oBAAoB,2BAA2B,0BAE/C,0BAA0B,mBAAmB,wBACrC,kBAAkB,mBAAmB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B,6BACpB,QAAQ;EAiRL,kBACJ,UACA,OACA,cACA,eACA;IAEA,UAAU;IACV,OAAO,UAAU;IACjB;IAEA;IACA,gBAAgB;MACd,QACF;IACE;IACA,qBAAqB;;;;;;;;;EAyJnB,SACJ,UAAU,qBACV,qBAAqB,QAAQ,cAC7B,YAAY,YACX,QAAQ;YA8DD,+BACR,sCACC;YAIO,0BACR,oCACA,mBAAmB;;;;EASrB,iBAAiB;EAIjB;WAIS;;;;;;;;EASH,eACJ,cAAc,4BACd,qBAAqB,QAAQ,cAC7B,YAAY,YACX,QAAQ;WAOF,UACP,UAAU,eACV,oCACA,aAAa,2BACZ,QAAQ;EAEX,qBAEE,kBAAkB,sBAAsB,qBAExC,cAAc,mBAAmB,YACjC,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cAAc,mBAAmB,YACjC,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;EAEhE,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;EAEhE,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;;;;;;uBAqG5C,gBACpB,oBAAoB,2BAA2B,kCACvC,cAAc;WACb,MACP,UAAU,eACV,oCACA,aAAa,2BACZ;EAEG,UACJ,UAAU,eACV,oCACA,aAAa,2BACZ,QAAQ"}
1
+ {"version":3,"file":"chat_models.d.ts","names":[],"sources":["../../src/language_models/chat_models.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;YA+EY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V,qBACJ,SAAS,uCACR,SAAS,wBAAwB;EAEpC,qBAEE,kBAAkB,sBAAsB,qBAExC,cACI,UAAU,aAEV,qBACJ,SAAS,sCACR,SAAS;IAA0B,KAAK;IAAa,QAAQ;;;;;;;8BAqG5C,gBACpB,oBAAoB,2BAA2B,kCACvC,cAAc;WACb,MACP,UAAU,eACV,oCACA,aAAa,2BACZ;EAEG,UACJ,UAAU,eACV,oCACA,aAAa,2BACZ,QAAQ"}
@@ -6,14 +6,13 @@ import { ChatModelStreamEvent } from "./event.cjs";
6
6
  * Convert an async iterable of legacy `ChatGenerationChunk`s into
7
7
  * `ChatModelStreamEvent`s with typed deltas.
8
8
  */
9
- declare function convertChunksToEvents(chunks: AsyncIterable<ChatGenerationChunk>, options?: {
9
+ export declare function convertChunksToEvents(chunks: AsyncIterable<ChatGenerationChunk>, options?: {
10
10
  signal?: AbortSignal;
11
11
  }): AsyncGenerator<ChatModelStreamEvent>;
12
12
  /**
13
13
  * Finalize a content block for the finish event.
14
14
  * For tool calls, parse the accumulated JSON args string.
15
15
  */
16
- declare function finalizeContentBlock(block: ContentBlock): ContentBlock;
16
+ export declare function finalizeContentBlock(block: ContentBlock): ContentBlock;
17
17
  //#endregion
18
- export { convertChunksToEvents, finalizeContentBlock };
19
18
  //# sourceMappingURL=compat.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compat.d.cts","names":[],"sources":["../../src/language_models/compat.ts"],"mappings":";;;;;;;;iBA8IuB,sBACrB,QAAQ,cAAc,sBACtB;EAAY,SAAS;IACpB,eAAe;;;;;iBAwWF,qBAAqB,OAAO,eAAe"}
1
+ {"version":3,"file":"compat.d.cts","names":[],"sources":["../../src/language_models/compat.ts"],"mappings":";;;;;;;;wBA8IuB,sBACrB,QAAQ,cAAc,sBACtB;EAAY,SAAS;IACpB,eAAe;;;;;wBAwWF,qBAAqB,OAAO,eAAe"}
@@ -6,14 +6,13 @@ import { ChatModelStreamEvent } from "./event.js";
6
6
  * Convert an async iterable of legacy `ChatGenerationChunk`s into
7
7
  * `ChatModelStreamEvent`s with typed deltas.
8
8
  */
9
- declare function convertChunksToEvents(chunks: AsyncIterable<ChatGenerationChunk>, options?: {
9
+ export declare function convertChunksToEvents(chunks: AsyncIterable<ChatGenerationChunk>, options?: {
10
10
  signal?: AbortSignal;
11
11
  }): AsyncGenerator<ChatModelStreamEvent>;
12
12
  /**
13
13
  * Finalize a content block for the finish event.
14
14
  * For tool calls, parse the accumulated JSON args string.
15
15
  */
16
- declare function finalizeContentBlock(block: ContentBlock): ContentBlock;
16
+ export declare function finalizeContentBlock(block: ContentBlock): ContentBlock;
17
17
  //#endregion
18
- export { convertChunksToEvents, finalizeContentBlock };
19
18
  //# sourceMappingURL=compat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compat.d.ts","names":[],"sources":["../../src/language_models/compat.ts"],"mappings":";;;;;;;;iBA8IuB,sBACrB,QAAQ,cAAc,sBACtB;EAAY,SAAS;IACpB,eAAe;;;;;iBAwWF,qBAAqB,OAAO,eAAe"}
1
+ {"version":3,"file":"compat.d.ts","names":[],"sources":["../../src/language_models/compat.ts"],"mappings":";;;;;;;;wBA8IuB,sBACrB,QAAQ,cAAc,sBACtB;EAAY,SAAS;IACpB,eAAe;;;;;wBAwWF,qBAAqB,OAAO,eAAe"}