langchain 0.2.17 → 0.3.0-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 (355) hide show
  1. package/dist/agents/executor.cjs +11 -0
  2. package/dist/agents/executor.d.ts +2 -0
  3. package/dist/agents/executor.js +11 -0
  4. package/dist/agents/openai_functions/index.cjs +2 -2
  5. package/dist/agents/openai_functions/index.js +2 -2
  6. package/dist/agents/react/output_parser.cjs +3 -2
  7. package/dist/agents/react/output_parser.js +3 -2
  8. package/dist/chains/combine_documents/stuff.cjs +2 -2
  9. package/dist/chains/combine_documents/stuff.js +2 -2
  10. package/dist/chains/conversational_retrieval_chain.cjs +1 -1
  11. package/dist/chains/conversational_retrieval_chain.d.ts +1 -1
  12. package/dist/chains/conversational_retrieval_chain.js +1 -1
  13. package/dist/chains/llm_chain.cjs +1 -1
  14. package/dist/chains/llm_chain.d.ts +1 -1
  15. package/dist/chains/llm_chain.js +1 -1
  16. package/dist/chains/openai_functions/openapi.cjs +3 -1
  17. package/dist/chains/openai_functions/openapi.js +3 -1
  18. package/dist/chains/retrieval_qa.cjs +1 -1
  19. package/dist/chains/retrieval_qa.d.ts +1 -1
  20. package/dist/chains/retrieval_qa.js +1 -1
  21. package/dist/load/import_constants.cjs +2 -39
  22. package/dist/load/import_constants.js +2 -39
  23. package/dist/load/import_map.cjs +2 -3
  24. package/dist/load/import_map.d.ts +0 -1
  25. package/dist/load/import_map.js +0 -1
  26. package/dist/smith/config.d.ts +1 -5
  27. package/package.json +35 -858
  28. package/dist/document_loaders/fs/chatgpt.cjs +0 -90
  29. package/dist/document_loaders/fs/chatgpt.d.ts +0 -8
  30. package/dist/document_loaders/fs/chatgpt.js +0 -86
  31. package/dist/document_loaders/fs/csv.cjs +0 -73
  32. package/dist/document_loaders/fs/csv.d.ts +0 -65
  33. package/dist/document_loaders/fs/csv.js +0 -69
  34. package/dist/document_loaders/fs/docx.cjs +0 -58
  35. package/dist/document_loaders/fs/docx.d.ts +0 -25
  36. package/dist/document_loaders/fs/docx.js +0 -54
  37. package/dist/document_loaders/fs/epub.cjs +0 -103
  38. package/dist/document_loaders/fs/epub.d.ts +0 -33
  39. package/dist/document_loaders/fs/epub.js +0 -99
  40. package/dist/document_loaders/fs/notion.cjs +0 -26
  41. package/dist/document_loaders/fs/notion.d.ts +0 -12
  42. package/dist/document_loaders/fs/notion.js +0 -22
  43. package/dist/document_loaders/fs/obsidian.cjs +0 -247
  44. package/dist/document_loaders/fs/obsidian.d.ts +0 -28
  45. package/dist/document_loaders/fs/obsidian.js +0 -240
  46. package/dist/document_loaders/fs/openai_whisper_audio.cjs +0 -49
  47. package/dist/document_loaders/fs/openai_whisper_audio.d.ts +0 -23
  48. package/dist/document_loaders/fs/openai_whisper_audio.js +0 -45
  49. package/dist/document_loaders/fs/pdf.cjs +0 -148
  50. package/dist/document_loaders/fs/pdf.d.ts +0 -49
  51. package/dist/document_loaders/fs/pdf.js +0 -144
  52. package/dist/document_loaders/fs/pptx.cjs +0 -46
  53. package/dist/document_loaders/fs/pptx.d.ts +0 -25
  54. package/dist/document_loaders/fs/pptx.js +0 -42
  55. package/dist/document_loaders/fs/srt.cjs +0 -57
  56. package/dist/document_loaders/fs/srt.d.ts +0 -32
  57. package/dist/document_loaders/fs/srt.js +0 -50
  58. package/dist/document_loaders/fs/unstructured.cjs +0 -338
  59. package/dist/document_loaders/fs/unstructured.d.ts +0 -125
  60. package/dist/document_loaders/fs/unstructured.js +0 -333
  61. package/dist/document_loaders/web/apify_dataset.cjs +0 -130
  62. package/dist/document_loaders/web/apify_dataset.d.ts +0 -85
  63. package/dist/document_loaders/web/apify_dataset.js +0 -126
  64. package/dist/document_loaders/web/assemblyai.cjs +0 -200
  65. package/dist/document_loaders/web/assemblyai.d.ts +0 -95
  66. package/dist/document_loaders/web/assemblyai.js +0 -193
  67. package/dist/document_loaders/web/azure_blob_storage_container.cjs +0 -73
  68. package/dist/document_loaders/web/azure_blob_storage_container.d.ts +0 -46
  69. package/dist/document_loaders/web/azure_blob_storage_container.js +0 -69
  70. package/dist/document_loaders/web/azure_blob_storage_file.cjs +0 -124
  71. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +0 -53
  72. package/dist/document_loaders/web/azure_blob_storage_file.js +0 -97
  73. package/dist/document_loaders/web/browserbase.cjs +0 -93
  74. package/dist/document_loaders/web/browserbase.d.ts +0 -48
  75. package/dist/document_loaders/web/browserbase.js +0 -86
  76. package/dist/document_loaders/web/cheerio.cjs +0 -118
  77. package/dist/document_loaders/web/cheerio.d.ts +0 -77
  78. package/dist/document_loaders/web/cheerio.js +0 -114
  79. package/dist/document_loaders/web/college_confidential.cjs +0 -41
  80. package/dist/document_loaders/web/college_confidential.d.ts +0 -25
  81. package/dist/document_loaders/web/college_confidential.js +0 -37
  82. package/dist/document_loaders/web/confluence.cjs +0 -190
  83. package/dist/document_loaders/web/confluence.d.ts +0 -114
  84. package/dist/document_loaders/web/confluence.js +0 -186
  85. package/dist/document_loaders/web/couchbase.cjs +0 -95
  86. package/dist/document_loaders/web/couchbase.d.ts +0 -32
  87. package/dist/document_loaders/web/couchbase.js +0 -91
  88. package/dist/document_loaders/web/figma.cjs +0 -102
  89. package/dist/document_loaders/web/figma.d.ts +0 -82
  90. package/dist/document_loaders/web/figma.js +0 -98
  91. package/dist/document_loaders/web/firecrawl.cjs +0 -95
  92. package/dist/document_loaders/web/firecrawl.d.ts +0 -50
  93. package/dist/document_loaders/web/firecrawl.js +0 -88
  94. package/dist/document_loaders/web/gitbook.cjs +0 -110
  95. package/dist/document_loaders/web/gitbook.d.ts +0 -55
  96. package/dist/document_loaders/web/gitbook.js +0 -106
  97. package/dist/document_loaders/web/github.cjs +0 -615
  98. package/dist/document_loaders/web/github.d.ts +0 -203
  99. package/dist/document_loaders/web/github.js +0 -608
  100. package/dist/document_loaders/web/hn.cjs +0 -90
  101. package/dist/document_loaders/web/hn.d.ts +0 -42
  102. package/dist/document_loaders/web/hn.js +0 -86
  103. package/dist/document_loaders/web/imsdb.cjs +0 -44
  104. package/dist/document_loaders/web/imsdb.d.ts +0 -23
  105. package/dist/document_loaders/web/imsdb.js +0 -40
  106. package/dist/document_loaders/web/notionapi.cjs +0 -404
  107. package/dist/document_loaders/web/notionapi.d.ts +0 -133
  108. package/dist/document_loaders/web/notionapi.js +0 -392
  109. package/dist/document_loaders/web/notiondb.cjs +0 -199
  110. package/dist/document_loaders/web/notiondb.d.ts +0 -56
  111. package/dist/document_loaders/web/notiondb.js +0 -195
  112. package/dist/document_loaders/web/pdf.cjs +0 -140
  113. package/dist/document_loaders/web/pdf.d.ts +0 -35
  114. package/dist/document_loaders/web/pdf.js +0 -136
  115. package/dist/document_loaders/web/playwright.cjs +0 -89
  116. package/dist/document_loaders/web/playwright.d.ts +0 -58
  117. package/dist/document_loaders/web/playwright.js +0 -85
  118. package/dist/document_loaders/web/puppeteer.cjs +0 -139
  119. package/dist/document_loaders/web/puppeteer.d.ts +0 -82
  120. package/dist/document_loaders/web/puppeteer.js +0 -135
  121. package/dist/document_loaders/web/recursive_url.cjs +0 -198
  122. package/dist/document_loaders/web/recursive_url.d.ts +0 -33
  123. package/dist/document_loaders/web/recursive_url.js +0 -194
  124. package/dist/document_loaders/web/s3.cjs +0 -164
  125. package/dist/document_loaders/web/s3.d.ts +0 -78
  126. package/dist/document_loaders/web/s3.js +0 -137
  127. package/dist/document_loaders/web/searchapi.cjs +0 -150
  128. package/dist/document_loaders/web/searchapi.d.ts +0 -76
  129. package/dist/document_loaders/web/searchapi.js +0 -146
  130. package/dist/document_loaders/web/serpapi.cjs +0 -127
  131. package/dist/document_loaders/web/serpapi.d.ts +0 -62
  132. package/dist/document_loaders/web/serpapi.js +0 -123
  133. package/dist/document_loaders/web/sitemap.cjs +0 -118
  134. package/dist/document_loaders/web/sitemap.d.ts +0 -41
  135. package/dist/document_loaders/web/sitemap.js +0 -114
  136. package/dist/document_loaders/web/sonix_audio.cjs +0 -68
  137. package/dist/document_loaders/web/sonix_audio.d.ts +0 -36
  138. package/dist/document_loaders/web/sonix_audio.js +0 -64
  139. package/dist/document_loaders/web/sort_xyz_blockchain.cjs +0 -157
  140. package/dist/document_loaders/web/sort_xyz_blockchain.d.ts +0 -78
  141. package/dist/document_loaders/web/sort_xyz_blockchain.js +0 -153
  142. package/dist/document_loaders/web/youtube.cjs +0 -116
  143. package/dist/document_loaders/web/youtube.d.ts +0 -55
  144. package/dist/document_loaders/web/youtube.js +0 -112
  145. package/dist/experimental/chrome_ai/app/dist/bundle.cjs +0 -1250
  146. package/dist/experimental/chrome_ai/app/dist/bundle.d.ts +0 -1
  147. package/dist/experimental/chrome_ai/app/dist/bundle.js +0 -1249
  148. package/dist/experimental/tools/pyinterpreter.cjs +0 -248
  149. package/dist/experimental/tools/pyinterpreter.d.ts +0 -18
  150. package/dist/experimental/tools/pyinterpreter.js +0 -244
  151. package/dist/retrievers/self_query/chroma.cjs +0 -48
  152. package/dist/retrievers/self_query/chroma.d.ts +0 -26
  153. package/dist/retrievers/self_query/chroma.js +0 -44
  154. package/dist/retrievers/self_query/pinecone.cjs +0 -47
  155. package/dist/retrievers/self_query/pinecone.d.ts +0 -26
  156. package/dist/retrievers/self_query/pinecone.js +0 -43
  157. package/dist/retrievers/self_query/supabase.cjs +0 -278
  158. package/dist/retrievers/self_query/supabase.d.ts +0 -109
  159. package/dist/retrievers/self_query/supabase.js +0 -274
  160. package/dist/retrievers/self_query/supabase_utils.cjs +0 -264
  161. package/dist/retrievers/self_query/supabase_utils.d.ts +0 -101
  162. package/dist/retrievers/self_query/supabase_utils.js +0 -259
  163. package/dist/retrievers/self_query/vectara.cjs +0 -143
  164. package/dist/retrievers/self_query/vectara.d.ts +0 -42
  165. package/dist/retrievers/self_query/vectara.js +0 -139
  166. package/dist/retrievers/self_query/weaviate.cjs +0 -201
  167. package/dist/retrievers/self_query/weaviate.d.ts +0 -99
  168. package/dist/retrievers/self_query/weaviate.js +0 -197
  169. package/dist/types/assemblyai-types.cjs +0 -2
  170. package/dist/types/assemblyai-types.d.ts +0 -4
  171. package/dist/types/assemblyai-types.js +0 -1
  172. package/document_loaders/fs/chatgpt.cjs +0 -1
  173. package/document_loaders/fs/chatgpt.d.cts +0 -1
  174. package/document_loaders/fs/chatgpt.d.ts +0 -1
  175. package/document_loaders/fs/chatgpt.js +0 -1
  176. package/document_loaders/fs/csv.cjs +0 -1
  177. package/document_loaders/fs/csv.d.cts +0 -1
  178. package/document_loaders/fs/csv.d.ts +0 -1
  179. package/document_loaders/fs/csv.js +0 -1
  180. package/document_loaders/fs/docx.cjs +0 -1
  181. package/document_loaders/fs/docx.d.cts +0 -1
  182. package/document_loaders/fs/docx.d.ts +0 -1
  183. package/document_loaders/fs/docx.js +0 -1
  184. package/document_loaders/fs/epub.cjs +0 -1
  185. package/document_loaders/fs/epub.d.cts +0 -1
  186. package/document_loaders/fs/epub.d.ts +0 -1
  187. package/document_loaders/fs/epub.js +0 -1
  188. package/document_loaders/fs/notion.cjs +0 -1
  189. package/document_loaders/fs/notion.d.cts +0 -1
  190. package/document_loaders/fs/notion.d.ts +0 -1
  191. package/document_loaders/fs/notion.js +0 -1
  192. package/document_loaders/fs/obsidian.cjs +0 -1
  193. package/document_loaders/fs/obsidian.d.cts +0 -1
  194. package/document_loaders/fs/obsidian.d.ts +0 -1
  195. package/document_loaders/fs/obsidian.js +0 -1
  196. package/document_loaders/fs/openai_whisper_audio.cjs +0 -1
  197. package/document_loaders/fs/openai_whisper_audio.d.cts +0 -1
  198. package/document_loaders/fs/openai_whisper_audio.d.ts +0 -1
  199. package/document_loaders/fs/openai_whisper_audio.js +0 -1
  200. package/document_loaders/fs/pdf.cjs +0 -1
  201. package/document_loaders/fs/pdf.d.cts +0 -1
  202. package/document_loaders/fs/pdf.d.ts +0 -1
  203. package/document_loaders/fs/pdf.js +0 -1
  204. package/document_loaders/fs/pptx.cjs +0 -1
  205. package/document_loaders/fs/pptx.d.cts +0 -1
  206. package/document_loaders/fs/pptx.d.ts +0 -1
  207. package/document_loaders/fs/pptx.js +0 -1
  208. package/document_loaders/fs/srt.cjs +0 -1
  209. package/document_loaders/fs/srt.d.cts +0 -1
  210. package/document_loaders/fs/srt.d.ts +0 -1
  211. package/document_loaders/fs/srt.js +0 -1
  212. package/document_loaders/fs/unstructured.cjs +0 -1
  213. package/document_loaders/fs/unstructured.d.cts +0 -1
  214. package/document_loaders/fs/unstructured.d.ts +0 -1
  215. package/document_loaders/fs/unstructured.js +0 -1
  216. package/document_loaders/web/apify_dataset.cjs +0 -1
  217. package/document_loaders/web/apify_dataset.d.cts +0 -1
  218. package/document_loaders/web/apify_dataset.d.ts +0 -1
  219. package/document_loaders/web/apify_dataset.js +0 -1
  220. package/document_loaders/web/assemblyai.cjs +0 -1
  221. package/document_loaders/web/assemblyai.d.cts +0 -1
  222. package/document_loaders/web/assemblyai.d.ts +0 -1
  223. package/document_loaders/web/assemblyai.js +0 -1
  224. package/document_loaders/web/azure_blob_storage_container.cjs +0 -1
  225. package/document_loaders/web/azure_blob_storage_container.d.cts +0 -1
  226. package/document_loaders/web/azure_blob_storage_container.d.ts +0 -1
  227. package/document_loaders/web/azure_blob_storage_container.js +0 -1
  228. package/document_loaders/web/azure_blob_storage_file.cjs +0 -1
  229. package/document_loaders/web/azure_blob_storage_file.d.cts +0 -1
  230. package/document_loaders/web/azure_blob_storage_file.d.ts +0 -1
  231. package/document_loaders/web/azure_blob_storage_file.js +0 -1
  232. package/document_loaders/web/browserbase.cjs +0 -1
  233. package/document_loaders/web/browserbase.d.cts +0 -1
  234. package/document_loaders/web/browserbase.d.ts +0 -1
  235. package/document_loaders/web/browserbase.js +0 -1
  236. package/document_loaders/web/cheerio.cjs +0 -1
  237. package/document_loaders/web/cheerio.d.cts +0 -1
  238. package/document_loaders/web/cheerio.d.ts +0 -1
  239. package/document_loaders/web/cheerio.js +0 -1
  240. package/document_loaders/web/college_confidential.cjs +0 -1
  241. package/document_loaders/web/college_confidential.d.cts +0 -1
  242. package/document_loaders/web/college_confidential.d.ts +0 -1
  243. package/document_loaders/web/college_confidential.js +0 -1
  244. package/document_loaders/web/confluence.cjs +0 -1
  245. package/document_loaders/web/confluence.d.cts +0 -1
  246. package/document_loaders/web/confluence.d.ts +0 -1
  247. package/document_loaders/web/confluence.js +0 -1
  248. package/document_loaders/web/couchbase.cjs +0 -1
  249. package/document_loaders/web/couchbase.d.cts +0 -1
  250. package/document_loaders/web/couchbase.d.ts +0 -1
  251. package/document_loaders/web/couchbase.js +0 -1
  252. package/document_loaders/web/figma.cjs +0 -1
  253. package/document_loaders/web/figma.d.cts +0 -1
  254. package/document_loaders/web/figma.d.ts +0 -1
  255. package/document_loaders/web/figma.js +0 -1
  256. package/document_loaders/web/firecrawl.cjs +0 -1
  257. package/document_loaders/web/firecrawl.d.cts +0 -1
  258. package/document_loaders/web/firecrawl.d.ts +0 -1
  259. package/document_loaders/web/firecrawl.js +0 -1
  260. package/document_loaders/web/gitbook.cjs +0 -1
  261. package/document_loaders/web/gitbook.d.cts +0 -1
  262. package/document_loaders/web/gitbook.d.ts +0 -1
  263. package/document_loaders/web/gitbook.js +0 -1
  264. package/document_loaders/web/github.cjs +0 -1
  265. package/document_loaders/web/github.d.cts +0 -1
  266. package/document_loaders/web/github.d.ts +0 -1
  267. package/document_loaders/web/github.js +0 -1
  268. package/document_loaders/web/hn.cjs +0 -1
  269. package/document_loaders/web/hn.d.cts +0 -1
  270. package/document_loaders/web/hn.d.ts +0 -1
  271. package/document_loaders/web/hn.js +0 -1
  272. package/document_loaders/web/imsdb.cjs +0 -1
  273. package/document_loaders/web/imsdb.d.cts +0 -1
  274. package/document_loaders/web/imsdb.d.ts +0 -1
  275. package/document_loaders/web/imsdb.js +0 -1
  276. package/document_loaders/web/notionapi.cjs +0 -1
  277. package/document_loaders/web/notionapi.d.cts +0 -1
  278. package/document_loaders/web/notionapi.d.ts +0 -1
  279. package/document_loaders/web/notionapi.js +0 -1
  280. package/document_loaders/web/notiondb.cjs +0 -1
  281. package/document_loaders/web/notiondb.d.cts +0 -1
  282. package/document_loaders/web/notiondb.d.ts +0 -1
  283. package/document_loaders/web/notiondb.js +0 -1
  284. package/document_loaders/web/pdf.cjs +0 -1
  285. package/document_loaders/web/pdf.d.cts +0 -1
  286. package/document_loaders/web/pdf.d.ts +0 -1
  287. package/document_loaders/web/pdf.js +0 -1
  288. package/document_loaders/web/playwright.cjs +0 -1
  289. package/document_loaders/web/playwright.d.cts +0 -1
  290. package/document_loaders/web/playwright.d.ts +0 -1
  291. package/document_loaders/web/playwright.js +0 -1
  292. package/document_loaders/web/puppeteer.cjs +0 -1
  293. package/document_loaders/web/puppeteer.d.cts +0 -1
  294. package/document_loaders/web/puppeteer.d.ts +0 -1
  295. package/document_loaders/web/puppeteer.js +0 -1
  296. package/document_loaders/web/recursive_url.cjs +0 -1
  297. package/document_loaders/web/recursive_url.d.cts +0 -1
  298. package/document_loaders/web/recursive_url.d.ts +0 -1
  299. package/document_loaders/web/recursive_url.js +0 -1
  300. package/document_loaders/web/s3.cjs +0 -1
  301. package/document_loaders/web/s3.d.cts +0 -1
  302. package/document_loaders/web/s3.d.ts +0 -1
  303. package/document_loaders/web/s3.js +0 -1
  304. package/document_loaders/web/searchapi.cjs +0 -1
  305. package/document_loaders/web/searchapi.d.cts +0 -1
  306. package/document_loaders/web/searchapi.d.ts +0 -1
  307. package/document_loaders/web/searchapi.js +0 -1
  308. package/document_loaders/web/serpapi.cjs +0 -1
  309. package/document_loaders/web/serpapi.d.cts +0 -1
  310. package/document_loaders/web/serpapi.d.ts +0 -1
  311. package/document_loaders/web/serpapi.js +0 -1
  312. package/document_loaders/web/sitemap.cjs +0 -1
  313. package/document_loaders/web/sitemap.d.cts +0 -1
  314. package/document_loaders/web/sitemap.d.ts +0 -1
  315. package/document_loaders/web/sitemap.js +0 -1
  316. package/document_loaders/web/sonix_audio.cjs +0 -1
  317. package/document_loaders/web/sonix_audio.d.cts +0 -1
  318. package/document_loaders/web/sonix_audio.d.ts +0 -1
  319. package/document_loaders/web/sonix_audio.js +0 -1
  320. package/document_loaders/web/sort_xyz_blockchain.cjs +0 -1
  321. package/document_loaders/web/sort_xyz_blockchain.d.cts +0 -1
  322. package/document_loaders/web/sort_xyz_blockchain.d.ts +0 -1
  323. package/document_loaders/web/sort_xyz_blockchain.js +0 -1
  324. package/document_loaders/web/youtube.cjs +0 -1
  325. package/document_loaders/web/youtube.d.cts +0 -1
  326. package/document_loaders/web/youtube.d.ts +0 -1
  327. package/document_loaders/web/youtube.js +0 -1
  328. package/experimental/tools/pyinterpreter.cjs +0 -1
  329. package/experimental/tools/pyinterpreter.d.cts +0 -1
  330. package/experimental/tools/pyinterpreter.d.ts +0 -1
  331. package/experimental/tools/pyinterpreter.js +0 -1
  332. package/memory/index.cjs +0 -1
  333. package/memory/index.d.cts +0 -1
  334. package/memory/index.d.ts +0 -1
  335. package/memory/index.js +0 -1
  336. package/retrievers/self_query/chroma.cjs +0 -1
  337. package/retrievers/self_query/chroma.d.cts +0 -1
  338. package/retrievers/self_query/chroma.d.ts +0 -1
  339. package/retrievers/self_query/chroma.js +0 -1
  340. package/retrievers/self_query/pinecone.cjs +0 -1
  341. package/retrievers/self_query/pinecone.d.cts +0 -1
  342. package/retrievers/self_query/pinecone.d.ts +0 -1
  343. package/retrievers/self_query/pinecone.js +0 -1
  344. package/retrievers/self_query/supabase.cjs +0 -1
  345. package/retrievers/self_query/supabase.d.cts +0 -1
  346. package/retrievers/self_query/supabase.d.ts +0 -1
  347. package/retrievers/self_query/supabase.js +0 -1
  348. package/retrievers/self_query/vectara.cjs +0 -1
  349. package/retrievers/self_query/vectara.d.cts +0 -1
  350. package/retrievers/self_query/vectara.d.ts +0 -1
  351. package/retrievers/self_query/vectara.js +0 -1
  352. package/retrievers/self_query/weaviate.cjs +0 -1
  353. package/retrievers/self_query/weaviate.d.cts +0 -1
  354. package/retrievers/self_query/weaviate.d.ts +0 -1
  355. package/retrievers/self_query/weaviate.js +0 -1
@@ -1,114 +0,0 @@
1
- import { Document } from "@langchain/core/documents";
2
- import { chunkArray } from "@langchain/core/utils/chunk_array";
3
- import { CheerioWebBaseLoader } from "./cheerio.js";
4
- import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation.js";
5
- /* #__PURE__ */ logVersion020MigrationWarning({
6
- oldEntrypointName: "document_loaders/web/sitemap",
7
- newPackageName: "@langchain/community",
8
- });
9
- const DEFAULT_CHUNK_SIZE = 300;
10
- /**
11
- * @deprecated - Import from "@langchain/community/document_loaders/web/sitemap" instead. This entrypoint will be removed in 0.3.0.
12
- */
13
- export class SitemapLoader extends CheerioWebBaseLoader {
14
- constructor(webPath, params = {}) {
15
- const paramsWithDefaults = { chunkSize: DEFAULT_CHUNK_SIZE, ...params };
16
- let path = webPath.endsWith("/") ? webPath.slice(0, -1) : webPath;
17
- // Allow for custom sitemap paths to be passed in with the url.
18
- path = path.endsWith(".xml") ? path : `${path}/sitemap.xml`;
19
- super(path, paramsWithDefaults);
20
- Object.defineProperty(this, "webPath", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: webPath
25
- });
26
- Object.defineProperty(this, "allowUrlPatterns", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- Object.defineProperty(this, "chunkSize", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
- this.webPath = path;
39
- this.allowUrlPatterns = paramsWithDefaults.filterUrls;
40
- this.chunkSize = paramsWithDefaults.chunkSize;
41
- }
42
- _checkUrlPatterns(url) {
43
- if (!this.allowUrlPatterns) {
44
- return false;
45
- }
46
- return !this.allowUrlPatterns.some((pattern) => !new RegExp(pattern).test(url));
47
- }
48
- async parseSitemap() {
49
- const $ = await CheerioWebBaseLoader._scrape(this.webPath, this.caller, this.timeout, this.textDecoder, {
50
- xmlMode: true,
51
- xml: true,
52
- });
53
- const elements = [];
54
- $("url").each((_, element) => {
55
- const loc = $(element).find("loc").text();
56
- if (!loc) {
57
- return;
58
- }
59
- if (this._checkUrlPatterns(loc)) {
60
- return;
61
- }
62
- const changefreq = $(element).find("changefreq").text();
63
- const lastmod = $(element).find("lastmod").text();
64
- const priority = $(element).find("priority").text();
65
- elements.push({ loc, changefreq, lastmod, priority });
66
- });
67
- $("sitemap").each((_, element) => {
68
- const loc = $(element).find("loc").text();
69
- if (!loc) {
70
- return;
71
- }
72
- const changefreq = $(element).find("changefreq").text();
73
- const lastmod = $(element).find("lastmod").text();
74
- const priority = $(element).find("priority").text();
75
- elements.push({ loc, changefreq, lastmod, priority });
76
- });
77
- return elements;
78
- }
79
- async _loadSitemapUrls(elements) {
80
- const all = await CheerioWebBaseLoader.scrapeAll(elements.map((ele) => ele.loc), this.caller, this.timeout, this.textDecoder);
81
- const documents = all.map(($, i) => {
82
- if (!elements[i]) {
83
- throw new Error("Scraped docs and elements not in sync");
84
- }
85
- const text = $(this.selector).text();
86
- const { loc: source, ...metadata } = elements[i];
87
- // extract page metadata
88
- const description = $("meta[name='description']").attr("content");
89
- const title = $("meta[property='og:title']").attr("content");
90
- const lang = $("meta[property='og:locale']").attr("content");
91
- return new Document({
92
- pageContent: text,
93
- metadata: {
94
- ...metadata,
95
- description,
96
- title,
97
- lang,
98
- source: source.trim(),
99
- },
100
- });
101
- });
102
- return documents;
103
- }
104
- async load() {
105
- const elements = await this.parseSitemap();
106
- const chunks = chunkArray(elements, this.chunkSize);
107
- const documents = [];
108
- for await (const chunk of chunks) {
109
- const chunkedDocuments = await this._loadSitemapUrls(chunk);
110
- documents.push(...chunkedDocuments);
111
- }
112
- return documents;
113
- }
114
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SonixAudioTranscriptionLoader = void 0;
4
- const sonix_speech_recognition_1 = require("sonix-speech-recognition");
5
- const documents_1 = require("@langchain/core/documents");
6
- const base_js_1 = require("../base.cjs");
7
- const entrypoint_deprecation_js_1 = require("../../util/entrypoint_deprecation.cjs");
8
- /* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion020MigrationWarning)({
9
- oldEntrypointName: "document_loaders/web/sonix_audio",
10
- newPackageName: "@langchain/community",
11
- });
12
- /**
13
- * @deprecated - Import from "@langchain/community/document_loaders/web/sonix_audio" instead. This entrypoint will be removed in 0.3.0.
14
- *
15
- * A class that represents a document loader for transcribing audio files
16
- * using the Sonix Speech Recognition service.
17
- * @example
18
- * ```typescript
19
- * const loader = new SonixAudioTranscriptionLoader({
20
- * sonixAuthKey: "SONIX_AUTH_KEY",
21
- * request: {
22
- * audioFilePath: "LOCAL_AUDIO_FILE_PATH",
23
- * fileName: "FILE_NAME",
24
- * language: "en",
25
- * },
26
- * });
27
- * const docs = await loader.load();
28
- * ```
29
- */
30
- class SonixAudioTranscriptionLoader extends base_js_1.BaseDocumentLoader {
31
- constructor({ sonixAuthKey, request: speechToTextRequest, }) {
32
- super();
33
- Object.defineProperty(this, "sonixSpeechRecognitionService", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: void 0
38
- });
39
- Object.defineProperty(this, "speechToTextRequest", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: void 0
44
- });
45
- this.sonixSpeechRecognitionService = new sonix_speech_recognition_1.SonixSpeechRecognitionService(sonixAuthKey);
46
- this.speechToTextRequest = speechToTextRequest;
47
- }
48
- /**
49
- * Performs the speech-to-text transcription using the
50
- * SonixSpeechRecognitionService and returns the transcribed text as a
51
- * Document object.
52
- * @returns An array of Document objects containing the transcribed text.
53
- */
54
- async load() {
55
- const { text, status, error } = await this.sonixSpeechRecognitionService.speechToText(this.speechToTextRequest);
56
- if (status === "failed") {
57
- throw new Error(`Failed to transcribe audio file. Error: ${error}`);
58
- }
59
- const document = new documents_1.Document({
60
- pageContent: text,
61
- metadata: {
62
- fileName: this.speechToTextRequest.fileName,
63
- },
64
- });
65
- return [document];
66
- }
67
- }
68
- exports.SonixAudioTranscriptionLoader = SonixAudioTranscriptionLoader;
@@ -1,36 +0,0 @@
1
- import { SpeechToTextRequest } from "sonix-speech-recognition/lib/types.js";
2
- import { Document } from "@langchain/core/documents";
3
- import { BaseDocumentLoader } from "../base.js";
4
- /**
5
- * @deprecated - Import from "@langchain/community/document_loaders/web/sonix_audio" instead. This entrypoint will be removed in 0.3.0.
6
- *
7
- * A class that represents a document loader for transcribing audio files
8
- * using the Sonix Speech Recognition service.
9
- * @example
10
- * ```typescript
11
- * const loader = new SonixAudioTranscriptionLoader({
12
- * sonixAuthKey: "SONIX_AUTH_KEY",
13
- * request: {
14
- * audioFilePath: "LOCAL_AUDIO_FILE_PATH",
15
- * fileName: "FILE_NAME",
16
- * language: "en",
17
- * },
18
- * });
19
- * const docs = await loader.load();
20
- * ```
21
- */
22
- export declare class SonixAudioTranscriptionLoader extends BaseDocumentLoader {
23
- private readonly sonixSpeechRecognitionService;
24
- private readonly speechToTextRequest;
25
- constructor({ sonixAuthKey, request: speechToTextRequest, }: {
26
- sonixAuthKey: string;
27
- request: SpeechToTextRequest;
28
- });
29
- /**
30
- * Performs the speech-to-text transcription using the
31
- * SonixSpeechRecognitionService and returns the transcribed text as a
32
- * Document object.
33
- * @returns An array of Document objects containing the transcribed text.
34
- */
35
- load(): Promise<Document[]>;
36
- }
@@ -1,64 +0,0 @@
1
- import { SonixSpeechRecognitionService } from "sonix-speech-recognition";
2
- import { Document } from "@langchain/core/documents";
3
- import { BaseDocumentLoader } from "../base.js";
4
- import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation.js";
5
- /* #__PURE__ */ logVersion020MigrationWarning({
6
- oldEntrypointName: "document_loaders/web/sonix_audio",
7
- newPackageName: "@langchain/community",
8
- });
9
- /**
10
- * @deprecated - Import from "@langchain/community/document_loaders/web/sonix_audio" instead. This entrypoint will be removed in 0.3.0.
11
- *
12
- * A class that represents a document loader for transcribing audio files
13
- * using the Sonix Speech Recognition service.
14
- * @example
15
- * ```typescript
16
- * const loader = new SonixAudioTranscriptionLoader({
17
- * sonixAuthKey: "SONIX_AUTH_KEY",
18
- * request: {
19
- * audioFilePath: "LOCAL_AUDIO_FILE_PATH",
20
- * fileName: "FILE_NAME",
21
- * language: "en",
22
- * },
23
- * });
24
- * const docs = await loader.load();
25
- * ```
26
- */
27
- export class SonixAudioTranscriptionLoader extends BaseDocumentLoader {
28
- constructor({ sonixAuthKey, request: speechToTextRequest, }) {
29
- super();
30
- Object.defineProperty(this, "sonixSpeechRecognitionService", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: void 0
35
- });
36
- Object.defineProperty(this, "speechToTextRequest", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- this.sonixSpeechRecognitionService = new SonixSpeechRecognitionService(sonixAuthKey);
43
- this.speechToTextRequest = speechToTextRequest;
44
- }
45
- /**
46
- * Performs the speech-to-text transcription using the
47
- * SonixSpeechRecognitionService and returns the transcribed text as a
48
- * Document object.
49
- * @returns An array of Document objects containing the transcribed text.
50
- */
51
- async load() {
52
- const { text, status, error } = await this.sonixSpeechRecognitionService.speechToText(this.speechToTextRequest);
53
- if (status === "failed") {
54
- throw new Error(`Failed to transcribe audio file. Error: ${error}`);
55
- }
56
- const document = new Document({
57
- pageContent: text,
58
- metadata: {
59
- fileName: this.speechToTextRequest.fileName,
60
- },
61
- });
62
- return [document];
63
- }
64
- }
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SortXYZBlockchainLoader = void 0;
4
- const documents_1 = require("@langchain/core/documents");
5
- const base_js_1 = require("../base.cjs");
6
- const entrypoint_deprecation_js_1 = require("../../util/entrypoint_deprecation.cjs");
7
- /* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion020MigrationWarning)({
8
- oldEntrypointName: "document_loaders/web/sortxyz_blockchain",
9
- newPackageName: "@langchain/community",
10
- });
11
- /**
12
- * @deprecated - Import from "@langchain/community/document_loaders/web/sortxyz_blockchain" instead. This entrypoint will be removed in 0.3.0.
13
- *
14
- * Class representing a document loader for loading data from the SortXYZ
15
- * blockchain using the SortXYZ API.
16
- * @example
17
- * ```typescript
18
- * const blockchainLoader = new SortXYZBlockchainLoader({
19
- * apiKey: "YOUR_SORTXYZ_API_KEY",
20
- * query: {
21
- * type: "NFTMetadata",
22
- * blockchain: "ethereum",
23
- * contractAddress: "0x887F3909C14DAbd9e9510128cA6cBb448E932d7f".toLowerCase(),
24
- * },
25
- * });
26
- *
27
- * const blockchainData = await blockchainLoader.load();
28
- *
29
- * const prompt =
30
- * "Describe the character with the attributes from the following json document in a 4 sentence story. ";
31
- * const model = new ChatOpenAI({ temperature: 0.9 })
32
- * const response = await model.invoke(
33
- * prompt + JSON.stringify(blockchainData[0], null, 2),
34
- * );
35
- * console.log(`user > ${prompt}`);
36
- * console.log(`chatgpt > ${response}`);
37
- * ```
38
- */
39
- class SortXYZBlockchainLoader extends base_js_1.BaseDocumentLoader {
40
- constructor({ apiKey, query }) {
41
- super();
42
- Object.defineProperty(this, "contractAddress", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: void 0
47
- });
48
- Object.defineProperty(this, "blockchain", {
49
- enumerable: true,
50
- configurable: true,
51
- writable: true,
52
- value: void 0
53
- });
54
- Object.defineProperty(this, "apiKey", {
55
- enumerable: true,
56
- configurable: true,
57
- writable: true,
58
- value: void 0
59
- });
60
- Object.defineProperty(this, "queryType", {
61
- enumerable: true,
62
- configurable: true,
63
- writable: true,
64
- value: void 0
65
- });
66
- Object.defineProperty(this, "sql", {
67
- enumerable: true,
68
- configurable: true,
69
- writable: true,
70
- value: void 0
71
- });
72
- Object.defineProperty(this, "limit", {
73
- enumerable: true,
74
- configurable: true,
75
- writable: true,
76
- value: void 0
77
- });
78
- if (!apiKey) {
79
- throw new Error(`apiKey is required! Head over to https://docs.sort.xyz/docs/api-keys to get your free Sort API key.`);
80
- }
81
- this.apiKey = apiKey;
82
- if (typeof query === "string") {
83
- this.sql = query;
84
- }
85
- else {
86
- this.contractAddress = query.contractAddress.toLowerCase();
87
- this.blockchain = query.blockchain;
88
- this.queryType = query.type;
89
- this.limit = query.limit ?? 100;
90
- }
91
- }
92
- /**
93
- * Method that loads the data from the SortXYZ blockchain based on the
94
- * specified query parameters. It makes requests to the SortXYZ API and
95
- * returns an array of Documents representing the retrieved data.
96
- * @returns Promise<Document[]> - An array of Documents representing the retrieved data.
97
- */
98
- async load() {
99
- if (this.limit > 1000) {
100
- throw new Error(`Limit is set too high. Please set limit to 1000 or lower.`);
101
- }
102
- const docs = [];
103
- let queryOffset = 0;
104
- // eslint-disable-next-line no-constant-condition
105
- while (true) {
106
- let query = "";
107
- if (this.sql) {
108
- query = this.sql;
109
- }
110
- else if (this.queryType === "NFTMetadata") {
111
- // All parameters here are user defined
112
- query = `SELECT * FROM ${this.blockchain}.nft_metadata WHERE contract_address = '${this.contractAddress}' ORDER BY token_id DESC LIMIT ${this.limit} OFFSET ${queryOffset}`;
113
- }
114
- else if (this.queryType === "latestTransactions") {
115
- // All parameters here are user defined
116
- query = `SELECT * FROM ${this.blockchain}.transaction t, ethereum.block b WHERE t.to_address = '${this.contractAddress}' AND b.id=t.block_id ORDER BY b.timestamp DESC LIMIT ${this.limit} OFFSET ${queryOffset}`;
117
- }
118
- try {
119
- const response = await fetch("https://api.sort.xyz/v1/queries/run", {
120
- method: "POST",
121
- headers: {
122
- "x-api-key": this.apiKey,
123
- Accept: "application/json",
124
- "Content-Type": "application/json",
125
- },
126
- body: JSON.stringify({ query }),
127
- });
128
- const fullResponse = await response.json();
129
- // Reached the end, no more records
130
- if (fullResponse &&
131
- fullResponse.data &&
132
- fullResponse.data.records.length === 0) {
133
- break;
134
- }
135
- const data = fullResponse?.data || [];
136
- for (let i = 0; i < data.records.length; i += 1) {
137
- const doc = new documents_1.Document({
138
- pageContent: JSON.stringify(data.records[i], null, 2),
139
- metadata: {
140
- row: i,
141
- },
142
- });
143
- docs.push(doc);
144
- }
145
- queryOffset += this.limit;
146
- if (queryOffset >= this.limit || this.sql) {
147
- break;
148
- }
149
- }
150
- catch (error) {
151
- console.error("Error:", error);
152
- }
153
- }
154
- return docs;
155
- }
156
- }
157
- exports.SortXYZBlockchainLoader = SortXYZBlockchainLoader;
@@ -1,78 +0,0 @@
1
- import { Document } from "@langchain/core/documents";
2
- import { BaseDocumentLoader } from "../base.js";
3
- /**
4
- * See https://docs.sort.xyz/docs/api-keys to get your free Sort API key.
5
- * See https://docs.sort.xyz for more information on the available queries.
6
- * See https://docs.sort.xyz/reference for more information about Sort's REST API.
7
- */
8
- export interface Query {
9
- type: "NFTMetadata" | "latestTransactions";
10
- contractAddress: string;
11
- blockchain: "ethereum" | "polygon" | "goerli";
12
- limit?: number;
13
- }
14
- /**
15
- * Interface representing the parameters for the SortXYZBlockchainLoader
16
- * class.
17
- */
18
- export interface SortXYZBlockchainLoaderParams {
19
- apiKey: string;
20
- query: Query | string;
21
- }
22
- /**
23
- * Interface representing the response from the SortXYZ API.
24
- */
25
- export interface SortXYZBlockchainAPIResponse {
26
- code: number;
27
- data: {
28
- durationMs: number;
29
- id: string;
30
- query: string;
31
- records: Record<string, unknown>[];
32
- recordCount: number;
33
- };
34
- }
35
- /**
36
- * @deprecated - Import from "@langchain/community/document_loaders/web/sortxyz_blockchain" instead. This entrypoint will be removed in 0.3.0.
37
- *
38
- * Class representing a document loader for loading data from the SortXYZ
39
- * blockchain using the SortXYZ API.
40
- * @example
41
- * ```typescript
42
- * const blockchainLoader = new SortXYZBlockchainLoader({
43
- * apiKey: "YOUR_SORTXYZ_API_KEY",
44
- * query: {
45
- * type: "NFTMetadata",
46
- * blockchain: "ethereum",
47
- * contractAddress: "0x887F3909C14DAbd9e9510128cA6cBb448E932d7f".toLowerCase(),
48
- * },
49
- * });
50
- *
51
- * const blockchainData = await blockchainLoader.load();
52
- *
53
- * const prompt =
54
- * "Describe the character with the attributes from the following json document in a 4 sentence story. ";
55
- * const model = new ChatOpenAI({ temperature: 0.9 })
56
- * const response = await model.invoke(
57
- * prompt + JSON.stringify(blockchainData[0], null, 2),
58
- * );
59
- * console.log(`user > ${prompt}`);
60
- * console.log(`chatgpt > ${response}`);
61
- * ```
62
- */
63
- export declare class SortXYZBlockchainLoader extends BaseDocumentLoader {
64
- readonly contractAddress: string;
65
- readonly blockchain: string;
66
- readonly apiKey: string;
67
- readonly queryType: string;
68
- readonly sql: string;
69
- readonly limit: number;
70
- constructor({ apiKey, query }: SortXYZBlockchainLoaderParams);
71
- /**
72
- * Method that loads the data from the SortXYZ blockchain based on the
73
- * specified query parameters. It makes requests to the SortXYZ API and
74
- * returns an array of Documents representing the retrieved data.
75
- * @returns Promise<Document[]> - An array of Documents representing the retrieved data.
76
- */
77
- load(): Promise<Document[]>;
78
- }
@@ -1,153 +0,0 @@
1
- import { Document } from "@langchain/core/documents";
2
- import { BaseDocumentLoader } from "../base.js";
3
- import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation.js";
4
- /* #__PURE__ */ logVersion020MigrationWarning({
5
- oldEntrypointName: "document_loaders/web/sortxyz_blockchain",
6
- newPackageName: "@langchain/community",
7
- });
8
- /**
9
- * @deprecated - Import from "@langchain/community/document_loaders/web/sortxyz_blockchain" instead. This entrypoint will be removed in 0.3.0.
10
- *
11
- * Class representing a document loader for loading data from the SortXYZ
12
- * blockchain using the SortXYZ API.
13
- * @example
14
- * ```typescript
15
- * const blockchainLoader = new SortXYZBlockchainLoader({
16
- * apiKey: "YOUR_SORTXYZ_API_KEY",
17
- * query: {
18
- * type: "NFTMetadata",
19
- * blockchain: "ethereum",
20
- * contractAddress: "0x887F3909C14DAbd9e9510128cA6cBb448E932d7f".toLowerCase(),
21
- * },
22
- * });
23
- *
24
- * const blockchainData = await blockchainLoader.load();
25
- *
26
- * const prompt =
27
- * "Describe the character with the attributes from the following json document in a 4 sentence story. ";
28
- * const model = new ChatOpenAI({ temperature: 0.9 })
29
- * const response = await model.invoke(
30
- * prompt + JSON.stringify(blockchainData[0], null, 2),
31
- * );
32
- * console.log(`user > ${prompt}`);
33
- * console.log(`chatgpt > ${response}`);
34
- * ```
35
- */
36
- export class SortXYZBlockchainLoader extends BaseDocumentLoader {
37
- constructor({ apiKey, query }) {
38
- super();
39
- Object.defineProperty(this, "contractAddress", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: void 0
44
- });
45
- Object.defineProperty(this, "blockchain", {
46
- enumerable: true,
47
- configurable: true,
48
- writable: true,
49
- value: void 0
50
- });
51
- Object.defineProperty(this, "apiKey", {
52
- enumerable: true,
53
- configurable: true,
54
- writable: true,
55
- value: void 0
56
- });
57
- Object.defineProperty(this, "queryType", {
58
- enumerable: true,
59
- configurable: true,
60
- writable: true,
61
- value: void 0
62
- });
63
- Object.defineProperty(this, "sql", {
64
- enumerable: true,
65
- configurable: true,
66
- writable: true,
67
- value: void 0
68
- });
69
- Object.defineProperty(this, "limit", {
70
- enumerable: true,
71
- configurable: true,
72
- writable: true,
73
- value: void 0
74
- });
75
- if (!apiKey) {
76
- throw new Error(`apiKey is required! Head over to https://docs.sort.xyz/docs/api-keys to get your free Sort API key.`);
77
- }
78
- this.apiKey = apiKey;
79
- if (typeof query === "string") {
80
- this.sql = query;
81
- }
82
- else {
83
- this.contractAddress = query.contractAddress.toLowerCase();
84
- this.blockchain = query.blockchain;
85
- this.queryType = query.type;
86
- this.limit = query.limit ?? 100;
87
- }
88
- }
89
- /**
90
- * Method that loads the data from the SortXYZ blockchain based on the
91
- * specified query parameters. It makes requests to the SortXYZ API and
92
- * returns an array of Documents representing the retrieved data.
93
- * @returns Promise<Document[]> - An array of Documents representing the retrieved data.
94
- */
95
- async load() {
96
- if (this.limit > 1000) {
97
- throw new Error(`Limit is set too high. Please set limit to 1000 or lower.`);
98
- }
99
- const docs = [];
100
- let queryOffset = 0;
101
- // eslint-disable-next-line no-constant-condition
102
- while (true) {
103
- let query = "";
104
- if (this.sql) {
105
- query = this.sql;
106
- }
107
- else if (this.queryType === "NFTMetadata") {
108
- // All parameters here are user defined
109
- query = `SELECT * FROM ${this.blockchain}.nft_metadata WHERE contract_address = '${this.contractAddress}' ORDER BY token_id DESC LIMIT ${this.limit} OFFSET ${queryOffset}`;
110
- }
111
- else if (this.queryType === "latestTransactions") {
112
- // All parameters here are user defined
113
- query = `SELECT * FROM ${this.blockchain}.transaction t, ethereum.block b WHERE t.to_address = '${this.contractAddress}' AND b.id=t.block_id ORDER BY b.timestamp DESC LIMIT ${this.limit} OFFSET ${queryOffset}`;
114
- }
115
- try {
116
- const response = await fetch("https://api.sort.xyz/v1/queries/run", {
117
- method: "POST",
118
- headers: {
119
- "x-api-key": this.apiKey,
120
- Accept: "application/json",
121
- "Content-Type": "application/json",
122
- },
123
- body: JSON.stringify({ query }),
124
- });
125
- const fullResponse = await response.json();
126
- // Reached the end, no more records
127
- if (fullResponse &&
128
- fullResponse.data &&
129
- fullResponse.data.records.length === 0) {
130
- break;
131
- }
132
- const data = fullResponse?.data || [];
133
- for (let i = 0; i < data.records.length; i += 1) {
134
- const doc = new Document({
135
- pageContent: JSON.stringify(data.records[i], null, 2),
136
- metadata: {
137
- row: i,
138
- },
139
- });
140
- docs.push(doc);
141
- }
142
- queryOffset += this.limit;
143
- if (queryOffset >= this.limit || this.sql) {
144
- break;
145
- }
146
- }
147
- catch (error) {
148
- console.error("Error:", error);
149
- }
150
- }
151
- return docs;
152
- }
153
- }