langchain 0.2.2 → 0.2.3-rc.0

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 (329) 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/tests/async_caller.int.test.d.ts +1 -0
  318. package/dist/util/tests/async_caller.int.test.js +34 -0
  319. package/dist/util/tests/azure.test.d.ts +1 -0
  320. package/dist/util/tests/azure.test.js +42 -0
  321. package/dist/util/tests/openai-stream.test.d.ts +1 -0
  322. package/dist/util/tests/openai-stream.test.js +135 -0
  323. package/dist/util/tests/set.test.d.ts +1 -0
  324. package/dist/util/tests/set.test.js +36 -0
  325. package/dist/util/tests/sql_utils.test.d.ts +1 -0
  326. package/dist/util/tests/sql_utils.test.js +50 -0
  327. package/dist/vectorstores/tests/memory.test.d.ts +1 -0
  328. package/dist/vectorstores/tests/memory.test.js +78 -0
  329. package/package.json +5 -4
@@ -0,0 +1,112 @@
1
+ import { zodToJsonSchema } from "zod-to-json-schema";
2
+ import fs from "fs";
3
+ import { z } from "zod";
4
+ import { OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai";
5
+ import { convertToOpenAIFunction } from "@langchain/core/utils/function_calling";
6
+ import { RunnableSequence } from "@langchain/core/runnables";
7
+ import { ChatPromptTemplate, MessagesPlaceholder, } from "@langchain/core/prompts";
8
+ import { createRetrieverTool } from "../toolkits/index.js";
9
+ import { RecursiveCharacterTextSplitter } from "../../text_splitter.js";
10
+ import { MemoryVectorStore } from "../../vectorstores/memory.js";
11
+ import { AgentExecutor } from "../executor.js";
12
+ import { formatForOpenAIFunctions } from "../format_scratchpad/openai_functions.js";
13
+ /** Define a custom structured output parser. */
14
+ const structuredOutputParser = (output) => {
15
+ if (typeof output.content !== "string") {
16
+ throw new Error("Cannot parse non-string output.");
17
+ }
18
+ if (output.additional_kwargs.function_call === undefined) {
19
+ return { returnValues: { output: output.content }, log: output.content };
20
+ }
21
+ const functionCall = output.additional_kwargs.function_call;
22
+ const name = functionCall?.name;
23
+ const inputs = functionCall?.arguments;
24
+ console.log(functionCall);
25
+ const jsonInput = JSON.parse(inputs);
26
+ if (name === "response") {
27
+ return { returnValues: { ...jsonInput }, log: output.content };
28
+ }
29
+ return {
30
+ tool: name,
31
+ toolInput: jsonInput,
32
+ log: output.content,
33
+ };
34
+ };
35
+ test("Pass custom structured output parsers", async () => {
36
+ /** Read text file & embed documents */
37
+ const text = fs.readFileSync("../examples/state_of_the_union.txt", "utf8");
38
+ const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
39
+ let docs = await textSplitter.createDocuments([text]);
40
+ // Add fake source information
41
+ docs = docs.map((doc, i) => ({
42
+ ...doc,
43
+ metadata: {
44
+ page_chunk: i,
45
+ },
46
+ }));
47
+ /** Initialize docs & create retriever */
48
+ const vectorStore = await MemoryVectorStore.fromDocuments(docs, new OpenAIEmbeddings());
49
+ const retriever = vectorStore.asRetriever();
50
+ /** Instantiate the LLM */
51
+ const llm = new ChatOpenAI({});
52
+ /** Define the prompt template */
53
+ const prompt = ChatPromptTemplate.fromMessages([
54
+ ["system", "You are a helpful assistant"],
55
+ new MessagesPlaceholder("agent_scratchpad"),
56
+ ["user", "{input}"],
57
+ ]);
58
+ /** Define the response schema */
59
+ const responseSchema = z.object({
60
+ answer: z.string().describe("The final answer to respond to the user"),
61
+ sources: z
62
+ .array(z.string())
63
+ .describe("List of page chunks that contain answer to the question. Only include a page chunk if it contains relevant information"),
64
+ });
65
+ /** Create the response function */
66
+ const responseOpenAIFunction = {
67
+ name: "response",
68
+ description: "Return the response to the user",
69
+ parameters: zodToJsonSchema(responseSchema),
70
+ };
71
+ /** Convert retriever into a tool */
72
+ const retrieverTool = createRetrieverTool(retriever, {
73
+ name: "state-of-union-retriever",
74
+ description: "Query a retriever to get information about state of the union address",
75
+ });
76
+ /** Bind both retriever and response functions to LLM */
77
+ const llmWithTools = llm.bind({
78
+ functions: [convertToOpenAIFunction(retrieverTool), responseOpenAIFunction],
79
+ });
80
+ /** Create the runnable */
81
+ const runnableAgent = RunnableSequence.from([
82
+ {
83
+ input: (i) => i.input,
84
+ agent_scratchpad: (i) => formatForOpenAIFunctions(i.steps),
85
+ },
86
+ prompt,
87
+ llmWithTools,
88
+ structuredOutputParser,
89
+ ]);
90
+ /** Create the agent by passing in the runnable & tools */
91
+ const executor = AgentExecutor.fromAgentAndTools({
92
+ agent: runnableAgent,
93
+ tools: [retrieverTool],
94
+ });
95
+ /** Call invoke on the agent */
96
+ const res = await executor.invoke({
97
+ input: "what did the president say about kentaji brown jackson",
98
+ });
99
+ console.log({
100
+ res,
101
+ });
102
+ /**
103
+ {
104
+ res: {
105
+ answer: 'President mentioned that he nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. He described her as one of our nation’s top legal minds and stated that she will continue Justice Breyer’s legacy of excellence.',
106
+ sources: [
107
+ 'And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence. A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by Democrats and Republicans.'
108
+ ]
109
+ }
110
+ }
111
+ */
112
+ });
@@ -0,0 +1,41 @@
1
+ import { test } from "@jest/globals";
2
+ import { OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai";
3
+ import { MemoryVectorStore } from "../../../vectorstores/memory.js";
4
+ import { createConversationalRetrievalAgent } from "../conversational_retrieval/openai_functions.js";
5
+ import { createRetrieverTool } from "../conversational_retrieval/tool.js";
6
+ test("Test ConversationalRetrievalAgent", async () => {
7
+ const vectorStore = await MemoryVectorStore.fromTexts([
8
+ "LangCo made $10000 in July",
9
+ "LangCo made $20 in August",
10
+ "Foo is red",
11
+ "Bar is red",
12
+ "Buildings are made out of brick",
13
+ "Mitochondria is the powerhouse of the cell",
14
+ ], [{ id: 2 }, { id: 1 }, { id: 3 }, { id: 4 }, { id: 5 }], new OpenAIEmbeddings());
15
+ const llm = new ChatOpenAI({});
16
+ const tools = [
17
+ createRetrieverTool(vectorStore.asRetriever(), {
18
+ name: "search_LangCo_knowledge",
19
+ description: "Searches for and returns documents regarding LangCo",
20
+ }),
21
+ ];
22
+ const executor = await createConversationalRetrievalAgent(llm, tools, {
23
+ verbose: true,
24
+ });
25
+ const result = await executor.invoke({
26
+ input: "Hi, I'm Bob!",
27
+ });
28
+ console.log(result);
29
+ const result2 = await executor.invoke({
30
+ input: "What's my name?",
31
+ });
32
+ console.log(result2);
33
+ const result3 = await executor.invoke({
34
+ input: "How much money did LangCo make in July?",
35
+ });
36
+ console.log(result3);
37
+ const result4 = await executor.invoke({
38
+ input: "How about in August?",
39
+ });
40
+ console.log(result4);
41
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { test, expect } from "@jest/globals";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import * as os from "node:os";
5
+ import { OpenAI, ChatOpenAI } from "@langchain/openai";
6
+ import { LocalFileCache } from "../file_system.js";
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ let tmpDir;
9
+ describe("Test LocalFileCache", () => {
10
+ beforeAll(async () => {
11
+ tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "langchain-"));
12
+ });
13
+ afterAll(async () => {
14
+ await fs.rm(tmpDir, { recursive: true });
15
+ });
16
+ test("FSCache with an LLM", async () => {
17
+ const cache = await LocalFileCache.create(tmpDir);
18
+ const model = new OpenAI({ cache });
19
+ const response1 = await model.invoke("What is something random?");
20
+ const response2 = await model.invoke("What is something random?");
21
+ expect(response1).toEqual(response2);
22
+ });
23
+ test("FSCache with a chat model", async () => {
24
+ const cache = await LocalFileCache.create(tmpDir);
25
+ const model = new ChatOpenAI({ cache });
26
+ const response1 = await model.invoke("What is something random?");
27
+ const response2 = await model.invoke("What is something random?");
28
+ expect(response1).not.toBeUndefined();
29
+ console.log(response1, response2);
30
+ expect(response1).toEqual(response2);
31
+ });
32
+ });
@@ -0,0 +1,139 @@
1
+ import { z } from "zod";
2
+ import { ChatPromptTemplate } from "@langchain/core/prompts";
3
+ import { ChatOpenAI } from "@langchain/openai";
4
+ import { expect, test } from "@jest/globals";
5
+ import { JsonOutputFunctionsParser } from "../../../output_parsers/openai_functions.js";
6
+ import { createOpenAIFnRunnable, createStructuredOutputRunnable, } from "../base.js";
7
+ const personJSONSchema = {
8
+ title: "Person",
9
+ description: "Identifying information about a person.",
10
+ type: "object",
11
+ properties: {
12
+ name: { title: "Name", description: "The person's name", type: "string" },
13
+ age: { title: "Age", description: "The person's age", type: "integer" },
14
+ fav_food: {
15
+ title: "Fav Food",
16
+ description: "The person's favorite food",
17
+ type: "string",
18
+ },
19
+ },
20
+ required: ["name", "age"],
21
+ };
22
+ const personDetailsFunction = {
23
+ name: "get_person_details",
24
+ description: "Get details about a person",
25
+ parameters: personJSONSchema,
26
+ };
27
+ const weatherFunction = {
28
+ name: "get_weather",
29
+ description: "Get the weather for a location",
30
+ parameters: {
31
+ title: "Location",
32
+ description: "The location to get the weather for.",
33
+ type: "object",
34
+ properties: {
35
+ state: {
36
+ title: "State",
37
+ description: "The location's state",
38
+ type: "string",
39
+ },
40
+ city: {
41
+ title: "City",
42
+ description: "The location's city",
43
+ type: "string",
44
+ },
45
+ zip_code: {
46
+ title: "Zip Code",
47
+ description: "The locations's zip code",
48
+ type: "string",
49
+ },
50
+ },
51
+ required: ["state", "city"],
52
+ },
53
+ };
54
+ test("createStructuredOutputRunnable works with Zod", async () => {
55
+ const model = new ChatOpenAI();
56
+ const prompt = ChatPromptTemplate.fromMessages([
57
+ ["human", "Human description: {description}"],
58
+ ]);
59
+ const zodSchema = z.object({
60
+ person: z.object({
61
+ name: z.string(),
62
+ age: z.string(),
63
+ fav_food: z.optional(z.string()),
64
+ }),
65
+ });
66
+ const outputParser = new JsonOutputFunctionsParser();
67
+ const runnable = createStructuredOutputRunnable({
68
+ outputSchema: zodSchema,
69
+ llm: model,
70
+ prompt,
71
+ outputParser,
72
+ });
73
+ const response = await runnable.invoke({
74
+ description: "My name's John Doe and I'm 30 years old. My favorite kind of food are chocolate chip cookies.",
75
+ });
76
+ console.log(response);
77
+ expect("person" in response).toBe(true);
78
+ expect("name" in response.person).toBe(true);
79
+ expect("age" in response.person).toBe(true);
80
+ });
81
+ test("createStructuredOutputRunnable works with JSON schema", async () => {
82
+ const model = new ChatOpenAI();
83
+ const prompt = ChatPromptTemplate.fromMessages([
84
+ ["human", "Human description: {description}"],
85
+ ]);
86
+ const outputParser = new JsonOutputFunctionsParser();
87
+ const runnable = createStructuredOutputRunnable({
88
+ outputSchema: personJSONSchema,
89
+ llm: model,
90
+ prompt,
91
+ outputParser,
92
+ });
93
+ const response = await runnable.invoke({
94
+ description: "My name's John Doe and I'm 30 years old. My favorite kind of food are chocolate chip cookies.",
95
+ });
96
+ console.log(response);
97
+ expect("name" in response).toBe(true);
98
+ expect("age" in response).toBe(true);
99
+ });
100
+ test("createOpenAIFnRunnable works", async () => {
101
+ const model = new ChatOpenAI();
102
+ const prompt = ChatPromptTemplate.fromMessages([
103
+ ["human", "Human description: {description}"],
104
+ ]);
105
+ const outputParser = new JsonOutputFunctionsParser();
106
+ const runnable = createOpenAIFnRunnable({
107
+ functions: [personDetailsFunction],
108
+ llm: model,
109
+ prompt,
110
+ enforceSingleFunctionUsage: true,
111
+ outputParser,
112
+ });
113
+ const response = await runnable.invoke({
114
+ description: "My name's John Doe and I'm 30 years old. My favorite kind of food are chocolate chip cookies.",
115
+ });
116
+ console.log(response);
117
+ expect("name" in response).toBe(true);
118
+ expect("age" in response).toBe(true);
119
+ });
120
+ test("createOpenAIFnRunnable works with multiple functions", async () => {
121
+ const model = new ChatOpenAI();
122
+ const prompt = ChatPromptTemplate.fromMessages([
123
+ ["human", "Question: {question}"],
124
+ ]);
125
+ const outputParser = new JsonOutputFunctionsParser();
126
+ const runnable = createOpenAIFnRunnable({
127
+ functions: [personDetailsFunction, weatherFunction],
128
+ llm: model,
129
+ prompt,
130
+ enforceSingleFunctionUsage: false,
131
+ outputParser,
132
+ });
133
+ const response = await runnable.invoke({
134
+ question: "What's the weather like in Berkeley CA?",
135
+ });
136
+ console.log(response);
137
+ expect("state" in response).toBe(true);
138
+ expect("city" in response).toBe(true);
139
+ });
@@ -0,0 +1,33 @@
1
+ import { test, expect } from "@jest/globals";
2
+ import { z } from "zod";
3
+ import { ChatOpenAI } from "@langchain/openai";
4
+ import { createExtractionChainFromZod } from "../extraction.js";
5
+ test("extraction chain", async () => {
6
+ const chain = createExtractionChainFromZod(z.object({
7
+ "person-name": z.string().optional(),
8
+ "person-age": z.number().optional(),
9
+ "person-hair_color": z.string().optional(),
10
+ "dog-name": z.string().optional(),
11
+ "dog-breed": z.string().optional(),
12
+ }), new ChatOpenAI({ modelName: "gpt-3.5-turbo-0613", temperature: 0 }));
13
+ const result = await chain.run(`Alex is 5 feet tall. Claudia is 4 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde.
14
+ Alex's dog Frosty is a labrador and likes to play hide and seek.`);
15
+ expect(result).toMatchInlineSnapshot(`
16
+ [
17
+ {
18
+ "dog-breed": "labrador",
19
+ "dog-name": "Frosty",
20
+ "person-age": 0,
21
+ "person-hair_color": "blonde",
22
+ "person-name": "Alex",
23
+ },
24
+ {
25
+ "dog-breed": "",
26
+ "dog-name": "",
27
+ "person-age": 0,
28
+ "person-hair_color": "brunette",
29
+ "person-name": "Claudia",
30
+ },
31
+ ]
32
+ `);
33
+ });
@@ -0,0 +1,130 @@
1
+ import { test } from "@jest/globals";
2
+ import { ChatOpenAI } from "@langchain/openai";
3
+ import { createOpenAPIChain } from "../openapi.js";
4
+ test("OpenAPI chain with a provided full spec", async () => {
5
+ const chain = await createOpenAPIChain({
6
+ openapi: "3.0.1",
7
+ info: { version: "v0", title: "Open AI Klarna product Api" },
8
+ servers: [{ url: "https://www.klarna.com/us/shopping" }],
9
+ tags: [
10
+ {
11
+ name: "open-ai-product-endpoint",
12
+ description: "Open AI Product Endpoint. Query for products.",
13
+ },
14
+ ],
15
+ paths: {
16
+ "/public/openai/v0/products": {
17
+ get: {
18
+ tags: ["open-ai-product-endpoint"],
19
+ summary: "API for fetching Klarna product information",
20
+ operationId: "productsUsingGET",
21
+ parameters: [
22
+ {
23
+ name: "countryCode",
24
+ in: "query",
25
+ description: "ISO 3166 country code with 2 characters based on the user location. Currently, only US, GB, DE, SE and DK are supported.",
26
+ required: true,
27
+ schema: { type: "string" },
28
+ },
29
+ {
30
+ name: "q",
31
+ in: "query",
32
+ description: "A precise query that matches one very small category or product that needs to be searched for to find the products the user is looking for. If the user explicitly stated what they want, use that as a query. The query is as specific as possible to the product name or category mentioned by the user in its singular form, and don't contain any clarifiers like latest, newest, cheapest, budget, premium, expensive or similar. The query is always taken from the latest topic, if there is a new topic a new query is started. If the user speaks another language than English, translate their request into English (example: translate fia med knuff to ludo board game)!",
33
+ required: true,
34
+ schema: { type: "string" },
35
+ },
36
+ {
37
+ name: "size",
38
+ in: "query",
39
+ description: "number of products returned",
40
+ required: false,
41
+ schema: { type: "integer" },
42
+ },
43
+ {
44
+ name: "min_price",
45
+ in: "query",
46
+ description: "(Optional) Minimum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for.",
47
+ required: false,
48
+ schema: { type: "integer" },
49
+ },
50
+ {
51
+ name: "max_price",
52
+ in: "query",
53
+ description: "(Optional) Maximum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for.",
54
+ required: false,
55
+ schema: { type: "integer" },
56
+ },
57
+ ],
58
+ responses: {
59
+ "200": {
60
+ description: "Products found",
61
+ content: {
62
+ "application/json": {
63
+ schema: { $ref: "#/components/schemas/ProductResponse" },
64
+ },
65
+ },
66
+ },
67
+ "503": { description: "one or more services are unavailable" },
68
+ },
69
+ deprecated: false,
70
+ },
71
+ },
72
+ },
73
+ components: {
74
+ schemas: {
75
+ Product: {
76
+ type: "object",
77
+ properties: {
78
+ attributes: { type: "array", items: { type: "string" } },
79
+ name: { type: "string" },
80
+ price: { type: "string" },
81
+ url: { type: "string" },
82
+ },
83
+ title: "Product",
84
+ },
85
+ ProductResponse: {
86
+ type: "object",
87
+ properties: {
88
+ products: {
89
+ type: "array",
90
+ items: { $ref: "#/components/schemas/Product" },
91
+ },
92
+ },
93
+ title: "ProductResponse",
94
+ },
95
+ },
96
+ },
97
+ }, { llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }) });
98
+ const result = await chain.run(`What are some options for a men's large blue button down shirt`);
99
+ console.log(result);
100
+ });
101
+ test("OpenAPI chain with yml spec from a URL", async () => {
102
+ const chain = await createOpenAPIChain("https://gist.githubusercontent.com/roaldnefs/053e505b2b7a807290908fe9aa3e1f00/raw/0a212622ebfef501163f91e23803552411ed00e4/openapi.yaml", {
103
+ llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }),
104
+ });
105
+ const result = await chain.run(`What's today's comic?`);
106
+ console.log(result);
107
+ });
108
+ test("OpenAPI chain with yml spec from a URL with a path parameter", async () => {
109
+ const chain = await createOpenAPIChain("https://gist.githubusercontent.com/roaldnefs/053e505b2b7a807290908fe9aa3e1f00/raw/0a212622ebfef501163f91e23803552411ed00e4/openapi.yaml", {
110
+ llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }),
111
+ });
112
+ const result = await chain.run(`What comic has id 2184?`);
113
+ console.log(result);
114
+ });
115
+ test("OpenAPI chain with yml spec from a URL requiring a POST request", async () => {
116
+ const chain = await createOpenAPIChain("https://api.speak.com/openapi.yaml", {
117
+ llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }),
118
+ });
119
+ const result = await chain.run(`How would you say no thanks in Russian?`);
120
+ console.log(result);
121
+ });
122
+ test("OpenAPI chain with a longer spec and tricky query required params", async () => {
123
+ const chain = await createOpenAPIChain("https://scholar-ai.net/openapi.yaml", {
124
+ params: {
125
+ sort: "cited_by_count",
126
+ },
127
+ });
128
+ const result = await chain.run("Can you find and explain some articles about the intersection of AI and VR?");
129
+ console.log(result);
130
+ });