langchain 0.2.2 → 0.2.3

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 (331) hide show
  1. package/dist/agents/tests/agent.int.test.d.ts +1 -0
  2. package/dist/agents/tests/agent.int.test.js +309 -0
  3. package/dist/agents/tests/chat_convo_output_parser.test.d.ts +1 -0
  4. package/dist/agents/tests/chat_convo_output_parser.test.js +91 -0
  5. package/dist/agents/tests/create_openai_functions_agent.int.test.d.ts +2 -0
  6. package/dist/agents/tests/create_openai_functions_agent.int.test.js +71 -0
  7. package/dist/agents/tests/create_openai_tools_agent.int.test.d.ts +1 -0
  8. package/dist/agents/tests/create_openai_tools_agent.int.test.js +75 -0
  9. package/dist/agents/tests/create_react_agent.int.test.d.ts +1 -0
  10. package/dist/agents/tests/create_react_agent.int.test.js +32 -0
  11. package/dist/agents/tests/create_structured_chat_agent.int.test.d.ts +1 -0
  12. package/dist/agents/tests/create_structured_chat_agent.int.test.js +32 -0
  13. package/dist/agents/tests/create_tool_calling_agent.int.test.d.ts +1 -0
  14. package/dist/agents/tests/create_tool_calling_agent.int.test.js +71 -0
  15. package/dist/agents/tests/create_xml_agent.int.test.d.ts +1 -0
  16. package/dist/agents/tests/create_xml_agent.int.test.js +32 -0
  17. package/dist/agents/tests/json.test.d.ts +1 -0
  18. package/dist/agents/tests/json.test.js +74 -0
  19. package/dist/agents/tests/react.test.d.ts +1 -0
  20. package/dist/agents/tests/react.test.js +44 -0
  21. package/dist/agents/tests/runnable.int.test.d.ts +1 -0
  22. package/dist/agents/tests/runnable.int.test.js +104 -0
  23. package/dist/agents/tests/sql.test.d.ts +1 -0
  24. package/dist/agents/tests/sql.test.js +133 -0
  25. package/dist/agents/tests/structured_chat_output_parser.test.d.ts +1 -0
  26. package/dist/agents/tests/structured_chat_output_parser.test.js +35 -0
  27. package/dist/agents/tests/structured_chat_output_parser_with_retries.int.test.d.ts +1 -0
  28. package/dist/agents/tests/structured_chat_output_parser_with_retries.int.test.js +44 -0
  29. package/dist/agents/tests/structured_output_runnables.int.test.d.ts +1 -0
  30. package/dist/agents/tests/structured_output_runnables.int.test.js +112 -0
  31. package/dist/agents/toolkits/tests/conversational_retrieval.int.test.d.ts +1 -0
  32. package/dist/agents/toolkits/tests/conversational_retrieval.int.test.js +41 -0
  33. package/dist/cache/tests/file_system.int.test.d.ts +1 -0
  34. package/dist/cache/tests/file_system.int.test.js +32 -0
  35. package/dist/chains/openai_functions/tests/create_runnable_chains.int.test.d.ts +1 -0
  36. package/dist/chains/openai_functions/tests/create_runnable_chains.int.test.js +139 -0
  37. package/dist/chains/openai_functions/tests/extraction.int.test.d.ts +1 -0
  38. package/dist/chains/openai_functions/tests/extraction.int.test.js +33 -0
  39. package/dist/chains/openai_functions/tests/openapi.int.test.d.ts +1 -0
  40. package/dist/chains/openai_functions/tests/openapi.int.test.js +130 -0
  41. package/dist/chains/openai_functions/tests/openapi.test.d.ts +1 -0
  42. package/dist/chains/openai_functions/tests/openapi.test.js +172 -0
  43. package/dist/chains/openai_functions/tests/structured_output.int.test.d.ts +1 -0
  44. package/dist/chains/openai_functions/tests/structured_output.int.test.js +40 -0
  45. package/dist/chains/openai_functions/tests/structured_output.test.d.ts +1 -0
  46. package/dist/chains/openai_functions/tests/structured_output.test.js +102 -0
  47. package/dist/chains/openai_functions/tests/tagging.int.test.d.ts +1 -0
  48. package/dist/chains/openai_functions/tests/tagging.int.test.js +21 -0
  49. package/dist/chains/query_constructor/tests/query_chain.int.test.d.ts +1 -0
  50. package/dist/chains/query_constructor/tests/query_chain.int.test.js +93 -0
  51. package/dist/chains/query_constructor/tests/query_parser.test.d.ts +1 -0
  52. package/dist/chains/query_constructor/tests/query_parser.test.js +28 -0
  53. package/dist/chains/question_answering/tests/load.int.test.d.ts +1 -0
  54. package/dist/chains/question_answering/tests/load.int.test.js +39 -0
  55. package/dist/chains/router/tests/multi_prompt.int.test.d.ts +1 -0
  56. package/dist/chains/router/tests/multi_prompt.int.test.js +45 -0
  57. package/dist/chains/router/tests/multi_prompt.test.d.ts +1 -0
  58. package/dist/chains/router/tests/multi_prompt.test.js +62 -0
  59. package/dist/chains/router/tests/multi_retrieval_qa.int.test.d.ts +1 -0
  60. package/dist/chains/router/tests/multi_retrieval_qa.int.test.js +67 -0
  61. package/dist/chains/router/tests/multi_retrieval_qa.test.d.ts +1 -0
  62. package/dist/chains/router/tests/multi_retrieval_qa.test.js +125 -0
  63. package/dist/chains/summarization/tests/load.int.test.d.ts +1 -0
  64. package/dist/chains/summarization/tests/load.int.test.js +37 -0
  65. package/dist/chains/tests/api_chain.int.test.d.ts +1 -0
  66. package/dist/chains/tests/api_chain.int.test.js +55 -0
  67. package/dist/chains/tests/combine_docs_chain.int.test.d.ts +1 -0
  68. package/dist/chains/tests/combine_docs_chain.int.test.js +50 -0
  69. package/dist/chains/tests/combine_docs_chain.test.d.ts +1 -0
  70. package/dist/chains/tests/combine_docs_chain.test.js +98 -0
  71. package/dist/chains/tests/constitutional_chain.int.test.d.ts +1 -0
  72. package/dist/chains/tests/constitutional_chain.int.test.js +30 -0
  73. package/dist/chains/tests/constitutional_chain.test.d.ts +1 -0
  74. package/dist/chains/tests/constitutional_chain.test.js +63 -0
  75. package/dist/chains/tests/conversation_chain.int.test.d.ts +1 -0
  76. package/dist/chains/tests/conversation_chain.int.test.js +9 -0
  77. package/dist/chains/tests/conversational_retrieval_chain.int.test.d.ts +1 -0
  78. package/dist/chains/tests/conversational_retrieval_chain.int.test.js +243 -0
  79. package/dist/chains/tests/example_data/open_meteo_docs.d.ts +1 -0
  80. package/dist/chains/tests/example_data/open_meteo_docs.js +29 -0
  81. package/dist/chains/tests/history_aware_retriever.int.test.d.ts +1 -0
  82. package/dist/chains/tests/history_aware_retriever.int.test.js +41 -0
  83. package/dist/chains/tests/history_aware_retriever.test.d.ts +1 -0
  84. package/dist/chains/tests/history_aware_retriever.test.js +27 -0
  85. package/dist/chains/tests/llm_chain.int.test.d.ts +1 -0
  86. package/dist/chains/tests/llm_chain.int.test.js +119 -0
  87. package/dist/chains/tests/openai_moderation.int.test.d.ts +1 -0
  88. package/dist/chains/tests/openai_moderation.int.test.js +30 -0
  89. package/dist/chains/tests/retrieval_chain.int.test.d.ts +1 -0
  90. package/dist/chains/tests/retrieval_chain.int.test.js +69 -0
  91. package/dist/chains/tests/retrieval_chain.test.d.ts +1 -0
  92. package/dist/chains/tests/retrieval_chain.test.js +36 -0
  93. package/dist/chains/tests/sequential_chain.int.test.d.ts +1 -0
  94. package/dist/chains/tests/sequential_chain.int.test.js +88 -0
  95. package/dist/chains/tests/sequential_chain.test.d.ts +1 -0
  96. package/dist/chains/tests/sequential_chain.test.js +295 -0
  97. package/dist/chains/tests/simple_sequential_chain.int.test.d.ts +1 -0
  98. package/dist/chains/tests/simple_sequential_chain.int.test.js +81 -0
  99. package/dist/chains/tests/simple_sequential_chain.test.d.ts +1 -0
  100. package/dist/chains/tests/simple_sequential_chain.test.js +128 -0
  101. package/dist/chains/tests/sql_db_chain.int.test.d.ts +1 -0
  102. package/dist/chains/tests/sql_db_chain.int.test.js +125 -0
  103. package/dist/chains/tests/transform.test.d.ts +1 -0
  104. package/dist/chains/tests/transform.test.js +12 -0
  105. package/dist/chains/tests/vector_db_qa_chain.int.test.d.ts +1 -0
  106. package/dist/chains/tests/vector_db_qa_chain.int.test.js +45 -0
  107. package/dist/document_loaders/tests/assemblyai.int.test.d.ts +1 -0
  108. package/dist/document_loaders/tests/assemblyai.int.test.js +111 -0
  109. package/dist/document_loaders/tests/chatgpt-blob.test.d.ts +1 -0
  110. package/dist/document_loaders/tests/chatgpt-blob.test.js +30 -0
  111. package/dist/document_loaders/tests/chatgpt.test.d.ts +1 -0
  112. package/dist/document_loaders/tests/chatgpt.test.js +29 -0
  113. package/dist/document_loaders/tests/cheerio.int.test.d.ts +1 -0
  114. package/dist/document_loaders/tests/cheerio.int.test.js +21 -0
  115. package/dist/document_loaders/tests/college_confidential.int.test.d.ts +1 -0
  116. package/dist/document_loaders/tests/college_confidential.int.test.js +6 -0
  117. package/dist/document_loaders/tests/confluence.test.d.ts +1 -0
  118. package/dist/document_loaders/tests/confluence.test.js +52 -0
  119. package/dist/document_loaders/tests/couchbase.int.test.d.ts +1 -0
  120. package/dist/document_loaders/tests/couchbase.int.test.js +28 -0
  121. package/dist/document_loaders/tests/csv-blob.test.d.ts +1 -0
  122. package/dist/document_loaders/tests/csv-blob.test.js +51 -0
  123. package/dist/document_loaders/tests/csv.test.d.ts +1 -0
  124. package/dist/document_loaders/tests/csv.test.js +41 -0
  125. package/dist/document_loaders/tests/directory.test.d.ts +1 -0
  126. package/dist/document_loaders/tests/directory.test.js +38 -0
  127. package/dist/document_loaders/tests/docx.test.d.ts +1 -0
  128. package/dist/document_loaders/tests/docx.test.js +11 -0
  129. package/dist/document_loaders/tests/epub.test.d.ts +1 -0
  130. package/dist/document_loaders/tests/epub.test.js +18 -0
  131. package/dist/document_loaders/tests/example_data/github_api_responses.d.ts +5 -0
  132. package/dist/document_loaders/tests/example_data/github_api_responses.js +91 -0
  133. package/dist/document_loaders/tests/figma.int.test.d.ts +1 -0
  134. package/dist/document_loaders/tests/figma.int.test.js +13 -0
  135. package/dist/document_loaders/tests/firecrawl.int.test.d.ts +1 -0
  136. package/dist/document_loaders/tests/firecrawl.int.test.js +30 -0
  137. package/dist/document_loaders/tests/gitbook.int.test.d.ts +1 -0
  138. package/dist/document_loaders/tests/gitbook.int.test.js +14 -0
  139. package/dist/document_loaders/tests/github.int.test.d.ts +1 -0
  140. package/dist/document_loaders/tests/github.int.test.js +86 -0
  141. package/dist/document_loaders/tests/github.test.d.ts +1 -0
  142. package/dist/document_loaders/tests/github.test.js +51 -0
  143. package/dist/document_loaders/tests/hn.int.test.d.ts +1 -0
  144. package/dist/document_loaders/tests/hn.int.test.js +6 -0
  145. package/dist/document_loaders/tests/imsdb.test.d.ts +1 -0
  146. package/dist/document_loaders/tests/imsdb.test.js +6 -0
  147. package/dist/document_loaders/tests/json-blob.test.d.ts +1 -0
  148. package/dist/document_loaders/tests/json-blob.test.js +87 -0
  149. package/dist/document_loaders/tests/json.test.d.ts +1 -0
  150. package/dist/document_loaders/tests/json.test.js +69 -0
  151. package/dist/document_loaders/tests/jsonl-blob.test.d.ts +1 -0
  152. package/dist/document_loaders/tests/jsonl-blob.test.js +44 -0
  153. package/dist/document_loaders/tests/jsonl.test.d.ts +1 -0
  154. package/dist/document_loaders/tests/jsonl.test.js +15 -0
  155. package/dist/document_loaders/tests/notion.test.d.ts +1 -0
  156. package/dist/document_loaders/tests/notion.test.js +11 -0
  157. package/dist/document_loaders/tests/notionapi.int.test.d.ts +1 -0
  158. package/dist/document_loaders/tests/notionapi.int.test.js +80 -0
  159. package/dist/document_loaders/tests/notionapi.test.d.ts +1 -0
  160. package/dist/document_loaders/tests/notionapi.test.js +84 -0
  161. package/dist/document_loaders/tests/notiondb.int.test.d.ts +1 -0
  162. package/dist/document_loaders/tests/notiondb.int.test.js +13 -0
  163. package/dist/document_loaders/tests/obsidian.test.d.ts +1 -0
  164. package/dist/document_loaders/tests/obsidian.test.js +119 -0
  165. package/dist/document_loaders/tests/pdf-blob.test.d.ts +1 -0
  166. package/dist/document_loaders/tests/pdf-blob.test.js +44 -0
  167. package/dist/document_loaders/tests/pdf.test.d.ts +1 -0
  168. package/dist/document_loaders/tests/pdf.test.js +25 -0
  169. package/dist/document_loaders/tests/playwright_web.int.test.d.ts +1 -0
  170. package/dist/document_loaders/tests/playwright_web.int.test.js +27 -0
  171. package/dist/document_loaders/tests/pptx.test.d.ts +1 -0
  172. package/dist/document_loaders/tests/pptx.test.js +17 -0
  173. package/dist/document_loaders/tests/puppeteer.int.test.d.ts +1 -0
  174. package/dist/document_loaders/tests/puppeteer.int.test.js +47 -0
  175. package/dist/document_loaders/tests/recursive_url.int.test.d.ts +1 -0
  176. package/dist/document_loaders/tests/recursive_url.int.test.js +64 -0
  177. package/dist/document_loaders/tests/s3.int.test.d.ts +1 -0
  178. package/dist/document_loaders/tests/s3.int.test.js +48 -0
  179. package/dist/document_loaders/tests/searchapi.test.d.ts +1 -0
  180. package/dist/document_loaders/tests/searchapi.test.js +29 -0
  181. package/dist/document_loaders/tests/serpapi.test.d.ts +1 -0
  182. package/dist/document_loaders/tests/serpapi.test.js +21 -0
  183. package/dist/document_loaders/tests/sitemap.int.test.d.ts +1 -0
  184. package/dist/document_loaders/tests/sitemap.int.test.js +28 -0
  185. package/dist/document_loaders/tests/sonix_audio.int.test.d.ts +1 -0
  186. package/dist/document_loaders/tests/sonix_audio.int.test.js +55 -0
  187. package/dist/document_loaders/tests/sort_xyz_blockchain.int.test.d.ts +1 -0
  188. package/dist/document_loaders/tests/sort_xyz_blockchain.int.test.js +38 -0
  189. package/dist/document_loaders/tests/srt-blob.test.d.ts +1 -0
  190. package/dist/document_loaders/tests/srt-blob.test.js +18 -0
  191. package/dist/document_loaders/tests/srt.test.d.ts +1 -0
  192. package/dist/document_loaders/tests/srt.test.js +16 -0
  193. package/dist/document_loaders/tests/text-blob.test.d.ts +1 -0
  194. package/dist/document_loaders/tests/text-blob.test.js +14 -0
  195. package/dist/document_loaders/tests/text.test.d.ts +1 -0
  196. package/dist/document_loaders/tests/text.test.js +22 -0
  197. package/dist/document_loaders/tests/unstructured.int.test.d.ts +1 -0
  198. package/dist/document_loaders/tests/unstructured.int.test.js +40 -0
  199. package/dist/document_loaders/tests/webpdf.int.test.d.ts +1 -0
  200. package/dist/document_loaders/tests/webpdf.int.test.js +90 -0
  201. package/dist/document_transformers/tests/openai_functions.int.test.d.ts +1 -0
  202. package/dist/document_transformers/tests/openai_functions.int.test.js +40 -0
  203. package/dist/embeddings/tests/cache.test.d.ts +1 -0
  204. package/dist/embeddings/tests/cache.test.js +24 -0
  205. package/dist/embeddings/tests/fake.test.d.ts +1 -0
  206. package/dist/embeddings/tests/fake.test.js +34 -0
  207. package/dist/evaluation/agents/tests/trajectory_eval_chain.int.test.d.ts +1 -0
  208. package/dist/evaluation/agents/tests/trajectory_eval_chain.int.test.js +33 -0
  209. package/dist/evaluation/comparison/tests/pairwise_eval_chain.int.test.d.ts +1 -0
  210. package/dist/evaluation/comparison/tests/pairwise_eval_chain.int.test.js +46 -0
  211. package/dist/evaluation/criteria/tests/criteria_eval_chain.int.test.d.ts +1 -0
  212. package/dist/evaluation/criteria/tests/criteria_eval_chain.int.test.js +108 -0
  213. package/dist/evaluation/embedding_distance/tests/embedding_distance_eval_chain.int.test.d.ts +1 -0
  214. package/dist/evaluation/embedding_distance/tests/embedding_distance_eval_chain.int.test.js +26 -0
  215. package/dist/evaluation/qa/tests/eval_chain.int.test.d.ts +1 -0
  216. package/dist/evaluation/qa/tests/eval_chain.int.test.js +27 -0
  217. package/dist/experimental/autogpt/tests/output_parser.test.d.ts +1 -0
  218. package/dist/experimental/autogpt/tests/output_parser.test.js +8 -0
  219. package/dist/experimental/autogpt/tests/prompt.test.d.ts +1 -0
  220. package/dist/experimental/autogpt/tests/prompt.test.js +69 -0
  221. package/dist/experimental/autogpt/tests/prompt_generator.test.d.ts +1 -0
  222. package/dist/experimental/autogpt/tests/prompt_generator.test.js +91 -0
  223. package/dist/experimental/chains/tests/violation_of_expectations_chain.int.test.d.ts +1 -0
  224. package/dist/experimental/chains/tests/violation_of_expectations_chain.int.test.js +26 -0
  225. package/dist/experimental/generative_agents/tests/generative_agent.int.test.d.ts +1 -0
  226. package/dist/experimental/generative_agents/tests/generative_agent.int.test.js +304 -0
  227. package/dist/experimental/masking/tests/masking-extended.test.d.ts +1 -0
  228. package/dist/experimental/masking/tests/masking-extended.test.js +58 -0
  229. package/dist/experimental/masking/tests/masking.test.d.ts +1 -0
  230. package/dist/experimental/masking/tests/masking.test.js +388 -0
  231. package/dist/experimental/openai_assistant/tests/openai_assistant.int.test.d.ts +1 -0
  232. package/dist/experimental/openai_assistant/tests/openai_assistant.int.test.js +203 -0
  233. package/dist/experimental/openai_files/tests/openai_file.int.test.d.ts +1 -0
  234. package/dist/experimental/openai_files/tests/openai_file.int.test.js +87 -0
  235. package/dist/experimental/plan_and_execute/tests/plan_and_execute.int.test.d.ts +1 -0
  236. package/dist/experimental/plan_and_execute/tests/plan_and_execute.int.test.js +54 -0
  237. package/dist/experimental/prompts/tests/handlebars.test.d.ts +1 -0
  238. package/dist/experimental/prompts/tests/handlebars.test.js +24 -0
  239. package/dist/experimental/tools/tests/pyinterpreter.int.test.d.ts +1 -0
  240. package/dist/experimental/tools/tests/pyinterpreter.int.test.js +22 -0
  241. package/dist/load/import_map.cjs +1 -1
  242. package/dist/load/import_map.js +1 -1
  243. package/dist/load/tests/cross_language.test.d.ts +1 -0
  244. package/dist/load/tests/cross_language.test.js +83 -0
  245. package/dist/load/tests/load.int.test.d.ts +1 -0
  246. package/dist/load/tests/load.int.test.js +9 -0
  247. package/dist/load/tests/load.test.d.ts +1 -0
  248. package/dist/load/tests/load.test.js +412 -0
  249. package/dist/memory/tests/buffer_memory.test.d.ts +1 -0
  250. package/dist/memory/tests/buffer_memory.test.js +34 -0
  251. package/dist/memory/tests/buffer_token_memory.int.test.d.ts +1 -0
  252. package/dist/memory/tests/buffer_token_memory.int.test.js +47 -0
  253. package/dist/memory/tests/buffer_window_memory.test.d.ts +1 -0
  254. package/dist/memory/tests/buffer_window_memory.test.js +42 -0
  255. package/dist/memory/tests/combined_memory.int.test.d.ts +1 -0
  256. package/dist/memory/tests/combined_memory.int.test.js +74 -0
  257. package/dist/memory/tests/entity_memory.int.test.d.ts +1 -0
  258. package/dist/memory/tests/entity_memory.int.test.js +79 -0
  259. package/dist/memory/tests/entity_memory.test.d.ts +1 -0
  260. package/dist/memory/tests/entity_memory.test.js +48 -0
  261. package/dist/memory/tests/summary.int.test.d.ts +1 -0
  262. package/dist/memory/tests/summary.int.test.js +50 -0
  263. package/dist/memory/tests/summary_buffer.int.test.d.ts +1 -0
  264. package/dist/memory/tests/summary_buffer.int.test.js +55 -0
  265. package/dist/memory/tests/vector_store_memory.int.test.d.ts +1 -0
  266. package/dist/memory/tests/vector_store_memory.int.test.js +55 -0
  267. package/dist/output_parsers/tests/combining.int.test.d.ts +1 -0
  268. package/dist/output_parsers/tests/combining.int.test.js +26 -0
  269. package/dist/output_parsers/tests/combining.test.d.ts +1 -0
  270. package/dist/output_parsers/tests/combining.test.js +54 -0
  271. package/dist/output_parsers/tests/datetime.test.d.ts +1 -0
  272. package/dist/output_parsers/tests/datetime.test.js +14 -0
  273. package/dist/output_parsers/tests/expression.test.d.ts +1 -0
  274. package/dist/output_parsers/tests/expression.test.js +339 -0
  275. package/dist/output_parsers/tests/http_response.test.d.ts +1 -0
  276. package/dist/output_parsers/tests/http_response.test.js +39 -0
  277. package/dist/output_parsers/tests/list.test.d.ts +1 -0
  278. package/dist/output_parsers/tests/list.test.js +27 -0
  279. package/dist/output_parsers/tests/openai_functions.int.test.d.ts +1 -0
  280. package/dist/output_parsers/tests/openai_functions.int.test.js +89 -0
  281. package/dist/output_parsers/tests/openai_tools.int.test.d.ts +1 -0
  282. package/dist/output_parsers/tests/openai_tools.int.test.js +36 -0
  283. package/dist/output_parsers/tests/structured.int.test.d.ts +1 -0
  284. package/dist/output_parsers/tests/structured.int.test.js +150 -0
  285. package/dist/prompts/tests/selectors.test.d.ts +1 -0
  286. package/dist/prompts/tests/selectors.test.js +59 -0
  287. package/dist/retrievers/self_query/tests/memory_self_query.int.test.d.ts +1 -0
  288. package/dist/retrievers/self_query/tests/memory_self_query.int.test.js +330 -0
  289. package/dist/retrievers/tests/chain_extract.int.test.d.ts +1 -0
  290. package/dist/retrievers/tests/chain_extract.int.test.js +32 -0
  291. package/dist/retrievers/tests/hyde.int.test.d.ts +1 -0
  292. package/dist/retrievers/tests/hyde.int.test.js +44 -0
  293. package/dist/retrievers/tests/matryoshka_retriever.int.test.d.ts +1 -0
  294. package/dist/retrievers/tests/matryoshka_retriever.int.test.js +113 -0
  295. package/dist/retrievers/tests/multi_query.int.test.d.ts +1 -0
  296. package/dist/retrievers/tests/multi_query.int.test.js +45 -0
  297. package/dist/retrievers/tests/parent_document.int.test.d.ts +1 -0
  298. package/dist/retrievers/tests/parent_document.int.test.js +122 -0
  299. package/dist/retrievers/tests/score_threshold.int.test.d.ts +1 -0
  300. package/dist/retrievers/tests/score_threshold.int.test.js +83 -0
  301. package/dist/retrievers/tests/time_weighted.test.d.ts +1 -0
  302. package/dist/retrievers/tests/time_weighted.test.js +320 -0
  303. package/dist/retrievers/tests/vectorstores.test.d.ts +1 -0
  304. package/dist/retrievers/tests/vectorstores.test.js +50 -0
  305. package/dist/smith/tests/run_on_dataset.int.test.d.ts +1 -0
  306. package/dist/smith/tests/run_on_dataset.int.test.js +257 -0
  307. package/dist/smith/tests/runner_utils.int.test.d.ts +9 -0
  308. package/dist/smith/tests/runner_utils.int.test.js +234 -0
  309. package/dist/storage/tests/file_system.test.d.ts +1 -0
  310. package/dist/storage/tests/file_system.test.js +81 -0
  311. package/dist/tools/tests/chain.test.d.ts +1 -0
  312. package/dist/tools/tests/chain.test.js +136 -0
  313. package/dist/tools/tests/webbrowser.int.test.d.ts +1 -0
  314. package/dist/tools/tests/webbrowser.int.test.js +80 -0
  315. package/dist/tools/tests/webbrowser.test.d.ts +1 -0
  316. package/dist/tools/tests/webbrowser.test.js +21 -0
  317. package/dist/util/sql_utils.cjs +2 -1
  318. package/dist/util/sql_utils.js +2 -1
  319. package/dist/util/tests/async_caller.int.test.d.ts +1 -0
  320. package/dist/util/tests/async_caller.int.test.js +34 -0
  321. package/dist/util/tests/azure.test.d.ts +1 -0
  322. package/dist/util/tests/azure.test.js +42 -0
  323. package/dist/util/tests/openai-stream.test.d.ts +1 -0
  324. package/dist/util/tests/openai-stream.test.js +135 -0
  325. package/dist/util/tests/set.test.d.ts +1 -0
  326. package/dist/util/tests/set.test.js +36 -0
  327. package/dist/util/tests/sql_utils.test.d.ts +1 -0
  328. package/dist/util/tests/sql_utils.test.js +50 -0
  329. package/dist/vectorstores/tests/memory.test.d.ts +1 -0
  330. package/dist/vectorstores/tests/memory.test.js +78 -0
  331. package/package.json +4 -8
@@ -0,0 +1,339 @@
1
+ import { test } from "@jest/globals";
2
+ import { ExpressionParser } from "../expression.js";
3
+ const correctExps = [
4
+ { type: "call_expression", funcCall: "hello", args: [] },
5
+ {
6
+ type: "call_expression",
7
+ funcCall: "hello",
8
+ args: [{ type: "string_literal", value: "world" }],
9
+ },
10
+ {
11
+ type: "call_expression",
12
+ funcCall: "hello",
13
+ args: [
14
+ { type: "string_literal", value: "world" },
15
+ { type: "string_literal", value: "hello" },
16
+ ],
17
+ },
18
+ {
19
+ type: "call_expression",
20
+ funcCall: "hello",
21
+ args: [
22
+ { type: "string_literal", value: "world" },
23
+ { type: "string_literal", value: "hello" },
24
+ {
25
+ type: "array_literal",
26
+ values: [
27
+ { type: "string_literal", value: "hello" },
28
+ { type: "string_literal", value: "world" },
29
+ { type: "numeric_literal", value: 1 },
30
+ { type: "numeric_literal", value: 2.1 },
31
+ { type: "numeric_literal", value: 3 },
32
+ ],
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ type: "call_expression",
38
+ funcCall: "hello",
39
+ args: [
40
+ { type: "string_literal", value: "world" },
41
+ { type: "string_literal", value: "hello" },
42
+ {
43
+ type: "array_literal",
44
+ values: [
45
+ { type: "string_literal", value: "hello" },
46
+ { type: "string_literal", value: "world" },
47
+ { type: "numeric_literal", value: 1 },
48
+ { type: "numeric_literal", value: 2.1 },
49
+ { type: "numeric_literal", value: 3 },
50
+ ],
51
+ },
52
+ {
53
+ type: "object_literal",
54
+ values: [
55
+ {
56
+ type: "property_assignment",
57
+ identifier: "hello",
58
+ value: { type: "string_literal", value: "world" },
59
+ },
60
+ ],
61
+ },
62
+ ],
63
+ },
64
+ {
65
+ type: "call_expression",
66
+ funcCall: "hello",
67
+ args: [
68
+ { type: "string_literal", value: "world" },
69
+ { type: "string_literal", value: "hello" },
70
+ {
71
+ type: "array_literal",
72
+ values: [
73
+ { type: "string_literal", value: "hello" },
74
+ { type: "string_literal", value: "world" },
75
+ { type: "numeric_literal", value: 1 },
76
+ { type: "numeric_literal", value: 2.1 },
77
+ { type: "numeric_literal", value: 3 },
78
+ ],
79
+ },
80
+ {
81
+ type: "object_literal",
82
+ values: [
83
+ {
84
+ type: "property_assignment",
85
+ identifier: "hello",
86
+ value: { type: "string_literal", value: "world" },
87
+ },
88
+ ],
89
+ },
90
+ { type: "numeric_literal", value: 1 },
91
+ { type: "numeric_literal", value: 2.1 },
92
+ { type: "numeric_literal", value: 3 },
93
+ ],
94
+ },
95
+ {
96
+ type: "call_expression",
97
+ funcCall: "hello",
98
+ args: [
99
+ { type: "string_literal", value: "world" },
100
+ { type: "string_literal", value: "hello" },
101
+ {
102
+ type: "array_literal",
103
+ values: [
104
+ { type: "string_literal", value: "hello" },
105
+ { type: "string_literal", value: "world" },
106
+ { type: "numeric_literal", value: 1 },
107
+ { type: "numeric_literal", value: 2.1 },
108
+ { type: "numeric_literal", value: 3 },
109
+ ],
110
+ },
111
+ {
112
+ type: "object_literal",
113
+ values: [
114
+ {
115
+ type: "property_assignment",
116
+ identifier: "hello",
117
+ value: { type: "string_literal", value: "world" },
118
+ },
119
+ ],
120
+ },
121
+ { type: "numeric_literal", value: 1 },
122
+ { type: "numeric_literal", value: 2.1 },
123
+ { type: "numeric_literal", value: 3 },
124
+ {
125
+ type: "call_expression",
126
+ funcCall: "world",
127
+ args: [
128
+ { type: "string_literal", value: "hello" },
129
+ { type: "string_literal", value: "world" },
130
+ {
131
+ type: "array_literal",
132
+ values: [
133
+ {
134
+ type: "object_literal",
135
+ values: [
136
+ {
137
+ type: "property_assignment",
138
+ identifier: "hello",
139
+ value: { type: "string_literal", value: "world" },
140
+ },
141
+ ],
142
+ },
143
+ {
144
+ type: "object_literal",
145
+ values: [
146
+ {
147
+ type: "property_assignment",
148
+ identifier: "hello",
149
+ value: {
150
+ type: "call_expression",
151
+ funcCall: "hello",
152
+ args: [{ type: "string_literal", value: "world" }],
153
+ },
154
+ },
155
+ ],
156
+ },
157
+ ],
158
+ },
159
+ ],
160
+ },
161
+ ],
162
+ },
163
+ {
164
+ type: "call_expression",
165
+ funcCall: {
166
+ type: "member_expression",
167
+ identifier: "hello",
168
+ property: "world",
169
+ },
170
+ args: [
171
+ { type: "string_literal", value: "hello" },
172
+ { type: "string_literal", value: "world" },
173
+ {
174
+ type: "array_literal",
175
+ values: [
176
+ { type: "string_literal", value: "hello" },
177
+ { type: "string_literal", value: "world" },
178
+ ],
179
+ },
180
+ {
181
+ type: "object_literal",
182
+ values: [
183
+ {
184
+ type: "property_assignment",
185
+ identifier: "hello",
186
+ value: { type: "string_literal", value: "world" },
187
+ },
188
+ ],
189
+ },
190
+ ],
191
+ },
192
+ {
193
+ type: "call_expression",
194
+ funcCall: {
195
+ type: "member_expression",
196
+ identifier: "hello",
197
+ property: "world",
198
+ },
199
+ args: [
200
+ { type: "string_literal", value: "hello" },
201
+ { type: "string_literal", value: "world" },
202
+ {
203
+ type: "array_literal",
204
+ values: [
205
+ { type: "string_literal", value: "hello" },
206
+ { type: "string_literal", value: "world" },
207
+ ],
208
+ },
209
+ ],
210
+ },
211
+ {
212
+ type: "call_expression",
213
+ funcCall: "a",
214
+ args: [
215
+ { type: "identifier", value: "b" },
216
+ {
217
+ type: "call_expression",
218
+ funcCall: "c",
219
+ args: [
220
+ { type: "identifier", value: "d" },
221
+ { type: "identifier", value: "e" },
222
+ {
223
+ type: "array_literal",
224
+ values: [
225
+ { type: "identifier", value: "f" },
226
+ { type: "identifier", value: "g" },
227
+ ],
228
+ },
229
+ {
230
+ type: "object_literal",
231
+ values: [
232
+ {
233
+ type: "property_assignment",
234
+ identifier: "h",
235
+ value: { type: "identifier", value: "i" },
236
+ },
237
+ ],
238
+ },
239
+ ],
240
+ },
241
+ ],
242
+ },
243
+ {
244
+ type: "call_expression",
245
+ funcCall: "and",
246
+ args: [
247
+ {
248
+ type: "call_expression",
249
+ funcCall: "in",
250
+ args: [
251
+ { type: "string_literal", value: "a" },
252
+ {
253
+ type: "array_literal",
254
+ values: [
255
+ { type: "string_literal", value: "a" },
256
+ { type: "string_literal", value: "b" },
257
+ { type: "string_literal", value: "c" },
258
+ ],
259
+ },
260
+ ],
261
+ },
262
+ {
263
+ type: "call_expression",
264
+ funcCall: "eq",
265
+ args: [
266
+ { type: "string_literal", value: "a" },
267
+ { type: "string_literal", value: "b" },
268
+ ],
269
+ },
270
+ ],
271
+ },
272
+ {
273
+ type: "call_expression",
274
+ funcCall: "with",
275
+ args: [
276
+ {
277
+ type: "call_expression",
278
+ funcCall: "const",
279
+ args: [
280
+ { type: "string_literal", value: "a" },
281
+ {
282
+ type: "array_literal",
283
+ values: [
284
+ { type: "string_literal", value: "a" },
285
+ { type: "string_literal", value: "b" },
286
+ { type: "string_literal", value: "c" },
287
+ ],
288
+ },
289
+ ],
290
+ },
291
+ {
292
+ type: "call_expression",
293
+ funcCall: "eq",
294
+ args: [
295
+ { type: "string_literal", value: "a" },
296
+ { type: "string_literal", value: "b" },
297
+ { type: "boolean_literal", value: true },
298
+ ],
299
+ },
300
+ ],
301
+ },
302
+ ];
303
+ test("ExpressionParser multiple expressions test", async () => {
304
+ const parser = new ExpressionParser();
305
+ await parser.ensureParser();
306
+ const expressions = [
307
+ `hello()`,
308
+ `hello("world")`,
309
+ `hello("world", "hello")`,
310
+ `hello("world", "hello", ["hello", "world", 1, 2.1, 3])`,
311
+ `hello("world", "hello", ["hello", "world", 1, 2.1, 3], { hello: "world" })`,
312
+ `hello("world", "hello", ["hello", "world", 1, 2.1, 3], { hello: "world" }, 1, 2.1, 3)`,
313
+ `hello("world", "hello", ["hello", "world", 1, 2.1, 3], { hello: "world" }, 1, 2.1, 3, world("hello", "world", [{hello: "world"}, {"hello": hello("world")}]))`,
314
+ `hello.world("hello", "world", ["hello", "world"], {"hello": "world"})`,
315
+ `hello["world"]("hello", "world", ["hello", "world"])`,
316
+ `a(b, c(d, e, [f, g], {h: i}))`,
317
+ `and(in("a", ["a", "b", "c"]), eq("a", "b"))`,
318
+ `with(const("a", ["a", "b", "c"]), eq("a", "b", true))`,
319
+ ];
320
+ const badExpressions = [
321
+ `hello(`,
322
+ `hello("world", ["hello", "world", 1, 2, 3 { hello: "world" })`,
323
+ `hello("world", ["hello, "world", { hello: "world" )`,
324
+ `l:::"""(}))))++===/...`,
325
+ ];
326
+ const parsedPromise = expressions.map((expression) => parser.parse(expression));
327
+ const badExpressionsPromise = badExpressions.map((expression) => parser.parse(expression).catch(() => "bad"));
328
+ await Promise.allSettled(badExpressionsPromise).then((errors) => {
329
+ errors.forEach((err) => {
330
+ if (err.status === "fulfilled") {
331
+ expect(err.value).toBe("bad");
332
+ }
333
+ });
334
+ });
335
+ const parsed = await Promise.all(parsedPromise);
336
+ parsed.forEach((expression, index) => {
337
+ expect(expression).toMatchObject(correctExps[index]);
338
+ });
339
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import { FakeStreamingLLM } from "@langchain/core/utils/testing";
2
+ import { HttpResponseOutputParser } from "../http_response.js";
3
+ test("text/plain stream", async () => {
4
+ const llm = new FakeStreamingLLM({});
5
+ const stream = await llm
6
+ .pipe(new HttpResponseOutputParser())
7
+ .stream("Hi there!");
8
+ const chunks = [];
9
+ const decoder = new TextDecoder();
10
+ for await (const chunk of stream) {
11
+ chunks.push(decoder.decode(chunk));
12
+ }
13
+ expect(chunks.length).toEqual("Hi there!".length);
14
+ expect(chunks.join("")).toEqual("Hi there!");
15
+ });
16
+ test("text/event-stream stream", async () => {
17
+ const llm = new FakeStreamingLLM({});
18
+ const stream = await llm
19
+ .pipe(new HttpResponseOutputParser({ contentType: "text/event-stream" }))
20
+ .stream("Hi there!");
21
+ const chunks = [];
22
+ const decoder = new TextDecoder();
23
+ for await (const chunk of stream) {
24
+ chunks.push(decoder.decode(chunk));
25
+ }
26
+ expect(chunks.length).toEqual("Hi there!".length + 1);
27
+ expect(chunks).toEqual([
28
+ `event: data\ndata: "H"\n\n`,
29
+ `event: data\ndata: "i"\n\n`,
30
+ `event: data\ndata: " "\n\n`,
31
+ `event: data\ndata: "t"\n\n`,
32
+ `event: data\ndata: "h"\n\n`,
33
+ `event: data\ndata: "e"\n\n`,
34
+ `event: data\ndata: "r"\n\n`,
35
+ `event: data\ndata: "e"\n\n`,
36
+ `event: data\ndata: "!"\n\n`,
37
+ `event: end\n\n`,
38
+ ]);
39
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { test, expect } from "@jest/globals";
2
+ import { OutputParserException, CommaSeparatedListOutputParser, CustomListOutputParser, } from "@langchain/core/output_parsers";
3
+ test("CommaSeparatedListOutputParser", async () => {
4
+ const parser = new CommaSeparatedListOutputParser();
5
+ expect(await parser.parse("hello, bye")).toEqual(["hello", "bye"]);
6
+ expect(await parser.parse("hello,bye")).toEqual(["hello", "bye"]);
7
+ expect(await parser.parse("hello")).toEqual(["hello"]);
8
+ });
9
+ test("CustomListOutputParser", async () => {
10
+ const parser1 = new CustomListOutputParser({ length: 3, separator: ";" });
11
+ expect(await parser1.parse("a; b;c")).toEqual(["a", "b", "c"]);
12
+ await expect(() => parser1.parse("a; b c")).rejects.toThrow(OutputParserException);
13
+ await expect(() => parser1.parse("a; b; c; d")).rejects.toThrow(OutputParserException);
14
+ const parser2 = new CustomListOutputParser({ separator: "\n" });
15
+ expect(await parser2.parse("a\nb\nc\nd")).toEqual(["a", "b", "c", "d"]);
16
+ const parser3 = new CustomListOutputParser({ length: 8 });
17
+ expect(await parser3.parse("a,b,c,d,e,f,g,h")).toEqual([
18
+ "a",
19
+ "b",
20
+ "c",
21
+ "d",
22
+ "e",
23
+ "f",
24
+ "g",
25
+ "h",
26
+ ]);
27
+ });
@@ -0,0 +1,89 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { expect, test } from "@jest/globals";
3
+ import { z } from "zod";
4
+ import { zodToJsonSchema } from "zod-to-json-schema";
5
+ import { applyPatch } from "@langchain/core/utils/json_patch";
6
+ import { ChatOpenAI } from "@langchain/openai";
7
+ import { ChatPromptTemplate } from "@langchain/core/prompts";
8
+ import { JsonOutputFunctionsParser } from "../openai_functions.js";
9
+ import { HttpResponseOutputParser } from "../http_response.js";
10
+ const schema = z.object({
11
+ setup: z.string().describe("The setup for the joke"),
12
+ punchline: z.string().describe("The punchline to the joke"),
13
+ });
14
+ const modelParams = {
15
+ functions: [
16
+ {
17
+ name: "joke",
18
+ description: "A joke",
19
+ parameters: zodToJsonSchema(schema),
20
+ },
21
+ ],
22
+ function_call: { name: "joke" },
23
+ };
24
+ test("Streaming JSON patch", async () => {
25
+ const prompt = ChatPromptTemplate.fromTemplate(`tell me a long joke about {foo}`);
26
+ const model = new ChatOpenAI({
27
+ temperature: 0,
28
+ }).bind(modelParams);
29
+ const parser = new JsonOutputFunctionsParser({ diff: true });
30
+ const chain = prompt.pipe(model).pipe(parser);
31
+ const stream = await chain.stream({
32
+ foo: "bears",
33
+ });
34
+ const chunks = [];
35
+ let aggregate = {};
36
+ for await (const chunk of stream) {
37
+ console.log(chunk);
38
+ chunks.push(chunk);
39
+ aggregate = applyPatch(aggregate, chunk).newDocument;
40
+ }
41
+ expect(chunks.length).toBeGreaterThan(1);
42
+ console.log(aggregate);
43
+ expect(aggregate.setup.length).toBeGreaterThan(1);
44
+ expect(aggregate.punchline.length).toBeGreaterThan(1);
45
+ });
46
+ test("Streaming JSON patch with an event stream output parser", async () => {
47
+ const prompt = ChatPromptTemplate.fromTemplate(`tell me a long joke about {foo}`);
48
+ const model = new ChatOpenAI({
49
+ temperature: 0,
50
+ }).bind(modelParams);
51
+ const jsonParser = new JsonOutputFunctionsParser({ diff: true });
52
+ const parser = new HttpResponseOutputParser({
53
+ outputParser: jsonParser,
54
+ contentType: "text/event-stream",
55
+ });
56
+ const chain = prompt.pipe(model).pipe(parser);
57
+ const stream = await chain.stream({
58
+ foo: "bears",
59
+ });
60
+ const chunks = [];
61
+ const decoder = new TextDecoder();
62
+ for await (const chunk of stream) {
63
+ console.log(decoder.decode(chunk));
64
+ chunks.push(chunk);
65
+ }
66
+ expect(chunks.length).toBeGreaterThan(1);
67
+ });
68
+ test("Streaming aggregated JSON", async () => {
69
+ const prompt = ChatPromptTemplate.fromTemplate(`tell me a long joke about {foo}`);
70
+ const model = new ChatOpenAI({
71
+ temperature: 0,
72
+ }).bind(modelParams);
73
+ const parser = new JsonOutputFunctionsParser();
74
+ const chain = prompt.pipe(model).pipe(parser);
75
+ const stream = await chain.stream({
76
+ foo: "bears",
77
+ });
78
+ const chunks = [];
79
+ let aggregate = {};
80
+ for await (const chunk of stream) {
81
+ console.log(chunk);
82
+ chunks.push(chunk);
83
+ aggregate = chunk;
84
+ }
85
+ expect(chunks.length).toBeGreaterThan(1);
86
+ console.log(aggregate);
87
+ expect(aggregate.setup.length).toBeGreaterThan(1);
88
+ expect(aggregate.punchline.length).toBeGreaterThan(1);
89
+ });
@@ -0,0 +1,36 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { expect, test } from "@jest/globals";
3
+ import { z } from "zod";
4
+ import { zodToJsonSchema } from "zod-to-json-schema";
5
+ import { ChatOpenAI } from "@langchain/openai";
6
+ import { ChatPromptTemplate } from "@langchain/core/prompts";
7
+ import { JsonOutputToolsParser } from "../openai_tools.js";
8
+ const schema = z.object({
9
+ setup: z.string().describe("The setup for the joke"),
10
+ punchline: z.string().describe("The punchline to the joke"),
11
+ });
12
+ test("Extraction", async () => {
13
+ const prompt = ChatPromptTemplate.fromTemplate(`tell me two jokes about {foo}`);
14
+ const model = new ChatOpenAI({
15
+ modelName: "gpt-3.5-turbo-1106",
16
+ temperature: 0,
17
+ }).bind({
18
+ tools: [
19
+ {
20
+ type: "function",
21
+ function: {
22
+ name: "joke",
23
+ description: "A joke",
24
+ parameters: zodToJsonSchema(schema),
25
+ },
26
+ },
27
+ ],
28
+ });
29
+ const parser = new JsonOutputToolsParser();
30
+ const chain = prompt.pipe(model).pipe(parser);
31
+ const res = await chain.invoke({
32
+ foo: "bears",
33
+ });
34
+ console.log(res);
35
+ expect(res.length).toBe(2);
36
+ });
@@ -0,0 +1 @@
1
+ export {};