langchain 0.2.19 → 0.3.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 (366) hide show
  1. package/README.md +9 -9
  2. package/dist/agents/chat/index.cjs +1 -1
  3. package/dist/agents/chat/index.d.ts +1 -1
  4. package/dist/agents/chat/index.js +1 -1
  5. package/dist/agents/chat_convo/index.cjs +1 -1
  6. package/dist/agents/chat_convo/index.d.ts +1 -1
  7. package/dist/agents/chat_convo/index.js +1 -1
  8. package/dist/agents/mrkl/index.cjs +1 -1
  9. package/dist/agents/mrkl/index.d.ts +1 -1
  10. package/dist/agents/mrkl/index.js +1 -1
  11. package/dist/agents/openai_functions/index.cjs +3 -3
  12. package/dist/agents/openai_functions/index.d.ts +1 -1
  13. package/dist/agents/openai_functions/index.js +3 -3
  14. package/dist/agents/structured_chat/index.cjs +1 -1
  15. package/dist/agents/structured_chat/index.d.ts +1 -1
  16. package/dist/agents/structured_chat/index.js +1 -1
  17. package/dist/agents/xml/index.cjs +1 -1
  18. package/dist/agents/xml/index.d.ts +1 -1
  19. package/dist/agents/xml/index.js +1 -1
  20. package/dist/chains/combine_documents/stuff.cjs +2 -2
  21. package/dist/chains/combine_documents/stuff.js +2 -2
  22. package/dist/chains/load.cjs +1 -1
  23. package/dist/chains/load.d.ts +1 -1
  24. package/dist/chains/load.js +1 -1
  25. package/dist/chains/openai_functions/structured_output.cjs +2 -2
  26. package/dist/chains/openai_functions/structured_output.d.ts +2 -2
  27. package/dist/chains/openai_functions/structured_output.js +2 -2
  28. package/dist/chains/serde.d.ts +12 -12
  29. package/dist/experimental/plan_and_execute/agent_executor.cjs +1 -1
  30. package/dist/experimental/plan_and_execute/agent_executor.js +1 -1
  31. package/dist/load/import_constants.cjs +2 -39
  32. package/dist/load/import_constants.js +2 -39
  33. package/dist/load/import_map.cjs +2 -3
  34. package/dist/load/import_map.d.ts +0 -1
  35. package/dist/load/import_map.js +0 -1
  36. package/dist/output_parsers/openai_tools.cjs +2 -4
  37. package/dist/output_parsers/openai_tools.d.ts +8 -3
  38. package/dist/output_parsers/openai_tools.js +2 -4
  39. package/dist/retrievers/multi_query.d.ts +1 -0
  40. package/dist/smith/config.d.ts +1 -5
  41. package/package.json +31 -854
  42. package/dist/document_loaders/fs/chatgpt.cjs +0 -90
  43. package/dist/document_loaders/fs/chatgpt.d.ts +0 -8
  44. package/dist/document_loaders/fs/chatgpt.js +0 -86
  45. package/dist/document_loaders/fs/csv.cjs +0 -73
  46. package/dist/document_loaders/fs/csv.d.ts +0 -65
  47. package/dist/document_loaders/fs/csv.js +0 -69
  48. package/dist/document_loaders/fs/docx.cjs +0 -58
  49. package/dist/document_loaders/fs/docx.d.ts +0 -25
  50. package/dist/document_loaders/fs/docx.js +0 -54
  51. package/dist/document_loaders/fs/epub.cjs +0 -103
  52. package/dist/document_loaders/fs/epub.d.ts +0 -33
  53. package/dist/document_loaders/fs/epub.js +0 -99
  54. package/dist/document_loaders/fs/notion.cjs +0 -26
  55. package/dist/document_loaders/fs/notion.d.ts +0 -12
  56. package/dist/document_loaders/fs/notion.js +0 -22
  57. package/dist/document_loaders/fs/obsidian.cjs +0 -247
  58. package/dist/document_loaders/fs/obsidian.d.ts +0 -28
  59. package/dist/document_loaders/fs/obsidian.js +0 -240
  60. package/dist/document_loaders/fs/openai_whisper_audio.cjs +0 -49
  61. package/dist/document_loaders/fs/openai_whisper_audio.d.ts +0 -23
  62. package/dist/document_loaders/fs/openai_whisper_audio.js +0 -45
  63. package/dist/document_loaders/fs/pdf.cjs +0 -148
  64. package/dist/document_loaders/fs/pdf.d.ts +0 -49
  65. package/dist/document_loaders/fs/pdf.js +0 -144
  66. package/dist/document_loaders/fs/pptx.cjs +0 -46
  67. package/dist/document_loaders/fs/pptx.d.ts +0 -25
  68. package/dist/document_loaders/fs/pptx.js +0 -42
  69. package/dist/document_loaders/fs/srt.cjs +0 -57
  70. package/dist/document_loaders/fs/srt.d.ts +0 -32
  71. package/dist/document_loaders/fs/srt.js +0 -50
  72. package/dist/document_loaders/fs/unstructured.cjs +0 -338
  73. package/dist/document_loaders/fs/unstructured.d.ts +0 -125
  74. package/dist/document_loaders/fs/unstructured.js +0 -333
  75. package/dist/document_loaders/web/apify_dataset.cjs +0 -130
  76. package/dist/document_loaders/web/apify_dataset.d.ts +0 -85
  77. package/dist/document_loaders/web/apify_dataset.js +0 -126
  78. package/dist/document_loaders/web/assemblyai.cjs +0 -200
  79. package/dist/document_loaders/web/assemblyai.d.ts +0 -95
  80. package/dist/document_loaders/web/assemblyai.js +0 -193
  81. package/dist/document_loaders/web/azure_blob_storage_container.cjs +0 -73
  82. package/dist/document_loaders/web/azure_blob_storage_container.d.ts +0 -46
  83. package/dist/document_loaders/web/azure_blob_storage_container.js +0 -69
  84. package/dist/document_loaders/web/azure_blob_storage_file.cjs +0 -124
  85. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +0 -53
  86. package/dist/document_loaders/web/azure_blob_storage_file.js +0 -97
  87. package/dist/document_loaders/web/browserbase.cjs +0 -93
  88. package/dist/document_loaders/web/browserbase.d.ts +0 -48
  89. package/dist/document_loaders/web/browserbase.js +0 -86
  90. package/dist/document_loaders/web/cheerio.cjs +0 -118
  91. package/dist/document_loaders/web/cheerio.d.ts +0 -77
  92. package/dist/document_loaders/web/cheerio.js +0 -114
  93. package/dist/document_loaders/web/college_confidential.cjs +0 -41
  94. package/dist/document_loaders/web/college_confidential.d.ts +0 -25
  95. package/dist/document_loaders/web/college_confidential.js +0 -37
  96. package/dist/document_loaders/web/confluence.cjs +0 -190
  97. package/dist/document_loaders/web/confluence.d.ts +0 -114
  98. package/dist/document_loaders/web/confluence.js +0 -186
  99. package/dist/document_loaders/web/couchbase.cjs +0 -95
  100. package/dist/document_loaders/web/couchbase.d.ts +0 -32
  101. package/dist/document_loaders/web/couchbase.js +0 -91
  102. package/dist/document_loaders/web/figma.cjs +0 -102
  103. package/dist/document_loaders/web/figma.d.ts +0 -82
  104. package/dist/document_loaders/web/figma.js +0 -98
  105. package/dist/document_loaders/web/firecrawl.cjs +0 -95
  106. package/dist/document_loaders/web/firecrawl.d.ts +0 -50
  107. package/dist/document_loaders/web/firecrawl.js +0 -88
  108. package/dist/document_loaders/web/gitbook.cjs +0 -110
  109. package/dist/document_loaders/web/gitbook.d.ts +0 -55
  110. package/dist/document_loaders/web/gitbook.js +0 -106
  111. package/dist/document_loaders/web/github.cjs +0 -615
  112. package/dist/document_loaders/web/github.d.ts +0 -203
  113. package/dist/document_loaders/web/github.js +0 -608
  114. package/dist/document_loaders/web/hn.cjs +0 -90
  115. package/dist/document_loaders/web/hn.d.ts +0 -42
  116. package/dist/document_loaders/web/hn.js +0 -86
  117. package/dist/document_loaders/web/imsdb.cjs +0 -44
  118. package/dist/document_loaders/web/imsdb.d.ts +0 -23
  119. package/dist/document_loaders/web/imsdb.js +0 -40
  120. package/dist/document_loaders/web/notionapi.cjs +0 -404
  121. package/dist/document_loaders/web/notionapi.d.ts +0 -133
  122. package/dist/document_loaders/web/notionapi.js +0 -392
  123. package/dist/document_loaders/web/notiondb.cjs +0 -199
  124. package/dist/document_loaders/web/notiondb.d.ts +0 -56
  125. package/dist/document_loaders/web/notiondb.js +0 -195
  126. package/dist/document_loaders/web/pdf.cjs +0 -140
  127. package/dist/document_loaders/web/pdf.d.ts +0 -35
  128. package/dist/document_loaders/web/pdf.js +0 -136
  129. package/dist/document_loaders/web/playwright.cjs +0 -89
  130. package/dist/document_loaders/web/playwright.d.ts +0 -58
  131. package/dist/document_loaders/web/playwright.js +0 -85
  132. package/dist/document_loaders/web/puppeteer.cjs +0 -139
  133. package/dist/document_loaders/web/puppeteer.d.ts +0 -82
  134. package/dist/document_loaders/web/puppeteer.js +0 -135
  135. package/dist/document_loaders/web/recursive_url.cjs +0 -198
  136. package/dist/document_loaders/web/recursive_url.d.ts +0 -33
  137. package/dist/document_loaders/web/recursive_url.js +0 -194
  138. package/dist/document_loaders/web/s3.cjs +0 -164
  139. package/dist/document_loaders/web/s3.d.ts +0 -78
  140. package/dist/document_loaders/web/s3.js +0 -137
  141. package/dist/document_loaders/web/searchapi.cjs +0 -150
  142. package/dist/document_loaders/web/searchapi.d.ts +0 -76
  143. package/dist/document_loaders/web/searchapi.js +0 -146
  144. package/dist/document_loaders/web/serpapi.cjs +0 -127
  145. package/dist/document_loaders/web/serpapi.d.ts +0 -62
  146. package/dist/document_loaders/web/serpapi.js +0 -123
  147. package/dist/document_loaders/web/sitemap.cjs +0 -118
  148. package/dist/document_loaders/web/sitemap.d.ts +0 -41
  149. package/dist/document_loaders/web/sitemap.js +0 -114
  150. package/dist/document_loaders/web/sonix_audio.cjs +0 -68
  151. package/dist/document_loaders/web/sonix_audio.d.ts +0 -36
  152. package/dist/document_loaders/web/sonix_audio.js +0 -64
  153. package/dist/document_loaders/web/sort_xyz_blockchain.cjs +0 -157
  154. package/dist/document_loaders/web/sort_xyz_blockchain.d.ts +0 -78
  155. package/dist/document_loaders/web/sort_xyz_blockchain.js +0 -153
  156. package/dist/document_loaders/web/youtube.cjs +0 -116
  157. package/dist/document_loaders/web/youtube.d.ts +0 -55
  158. package/dist/document_loaders/web/youtube.js +0 -112
  159. package/dist/experimental/tools/pyinterpreter.cjs +0 -248
  160. package/dist/experimental/tools/pyinterpreter.d.ts +0 -18
  161. package/dist/experimental/tools/pyinterpreter.js +0 -244
  162. package/dist/retrievers/self_query/chroma.cjs +0 -48
  163. package/dist/retrievers/self_query/chroma.d.ts +0 -26
  164. package/dist/retrievers/self_query/chroma.js +0 -44
  165. package/dist/retrievers/self_query/pinecone.cjs +0 -47
  166. package/dist/retrievers/self_query/pinecone.d.ts +0 -26
  167. package/dist/retrievers/self_query/pinecone.js +0 -43
  168. package/dist/retrievers/self_query/supabase.cjs +0 -278
  169. package/dist/retrievers/self_query/supabase.d.ts +0 -109
  170. package/dist/retrievers/self_query/supabase.js +0 -274
  171. package/dist/retrievers/self_query/supabase_utils.cjs +0 -264
  172. package/dist/retrievers/self_query/supabase_utils.d.ts +0 -101
  173. package/dist/retrievers/self_query/supabase_utils.js +0 -259
  174. package/dist/retrievers/self_query/vectara.cjs +0 -143
  175. package/dist/retrievers/self_query/vectara.d.ts +0 -42
  176. package/dist/retrievers/self_query/vectara.js +0 -139
  177. package/dist/retrievers/self_query/weaviate.cjs +0 -201
  178. package/dist/retrievers/self_query/weaviate.d.ts +0 -99
  179. package/dist/retrievers/self_query/weaviate.js +0 -197
  180. package/dist/types/assemblyai-types.cjs +0 -2
  181. package/dist/types/assemblyai-types.d.ts +0 -4
  182. package/dist/types/assemblyai-types.js +0 -1
  183. package/document_loaders/fs/chatgpt.cjs +0 -1
  184. package/document_loaders/fs/chatgpt.d.cts +0 -1
  185. package/document_loaders/fs/chatgpt.d.ts +0 -1
  186. package/document_loaders/fs/chatgpt.js +0 -1
  187. package/document_loaders/fs/csv.cjs +0 -1
  188. package/document_loaders/fs/csv.d.cts +0 -1
  189. package/document_loaders/fs/csv.d.ts +0 -1
  190. package/document_loaders/fs/csv.js +0 -1
  191. package/document_loaders/fs/docx.cjs +0 -1
  192. package/document_loaders/fs/docx.d.cts +0 -1
  193. package/document_loaders/fs/docx.d.ts +0 -1
  194. package/document_loaders/fs/docx.js +0 -1
  195. package/document_loaders/fs/epub.cjs +0 -1
  196. package/document_loaders/fs/epub.d.cts +0 -1
  197. package/document_loaders/fs/epub.d.ts +0 -1
  198. package/document_loaders/fs/epub.js +0 -1
  199. package/document_loaders/fs/notion.cjs +0 -1
  200. package/document_loaders/fs/notion.d.cts +0 -1
  201. package/document_loaders/fs/notion.d.ts +0 -1
  202. package/document_loaders/fs/notion.js +0 -1
  203. package/document_loaders/fs/obsidian.cjs +0 -1
  204. package/document_loaders/fs/obsidian.d.cts +0 -1
  205. package/document_loaders/fs/obsidian.d.ts +0 -1
  206. package/document_loaders/fs/obsidian.js +0 -1
  207. package/document_loaders/fs/openai_whisper_audio.cjs +0 -1
  208. package/document_loaders/fs/openai_whisper_audio.d.cts +0 -1
  209. package/document_loaders/fs/openai_whisper_audio.d.ts +0 -1
  210. package/document_loaders/fs/openai_whisper_audio.js +0 -1
  211. package/document_loaders/fs/pdf.cjs +0 -1
  212. package/document_loaders/fs/pdf.d.cts +0 -1
  213. package/document_loaders/fs/pdf.d.ts +0 -1
  214. package/document_loaders/fs/pdf.js +0 -1
  215. package/document_loaders/fs/pptx.cjs +0 -1
  216. package/document_loaders/fs/pptx.d.cts +0 -1
  217. package/document_loaders/fs/pptx.d.ts +0 -1
  218. package/document_loaders/fs/pptx.js +0 -1
  219. package/document_loaders/fs/srt.cjs +0 -1
  220. package/document_loaders/fs/srt.d.cts +0 -1
  221. package/document_loaders/fs/srt.d.ts +0 -1
  222. package/document_loaders/fs/srt.js +0 -1
  223. package/document_loaders/fs/unstructured.cjs +0 -1
  224. package/document_loaders/fs/unstructured.d.cts +0 -1
  225. package/document_loaders/fs/unstructured.d.ts +0 -1
  226. package/document_loaders/fs/unstructured.js +0 -1
  227. package/document_loaders/web/apify_dataset.cjs +0 -1
  228. package/document_loaders/web/apify_dataset.d.cts +0 -1
  229. package/document_loaders/web/apify_dataset.d.ts +0 -1
  230. package/document_loaders/web/apify_dataset.js +0 -1
  231. package/document_loaders/web/assemblyai.cjs +0 -1
  232. package/document_loaders/web/assemblyai.d.cts +0 -1
  233. package/document_loaders/web/assemblyai.d.ts +0 -1
  234. package/document_loaders/web/assemblyai.js +0 -1
  235. package/document_loaders/web/azure_blob_storage_container.cjs +0 -1
  236. package/document_loaders/web/azure_blob_storage_container.d.cts +0 -1
  237. package/document_loaders/web/azure_blob_storage_container.d.ts +0 -1
  238. package/document_loaders/web/azure_blob_storage_container.js +0 -1
  239. package/document_loaders/web/azure_blob_storage_file.cjs +0 -1
  240. package/document_loaders/web/azure_blob_storage_file.d.cts +0 -1
  241. package/document_loaders/web/azure_blob_storage_file.d.ts +0 -1
  242. package/document_loaders/web/azure_blob_storage_file.js +0 -1
  243. package/document_loaders/web/browserbase.cjs +0 -1
  244. package/document_loaders/web/browserbase.d.cts +0 -1
  245. package/document_loaders/web/browserbase.d.ts +0 -1
  246. package/document_loaders/web/browserbase.js +0 -1
  247. package/document_loaders/web/cheerio.cjs +0 -1
  248. package/document_loaders/web/cheerio.d.cts +0 -1
  249. package/document_loaders/web/cheerio.d.ts +0 -1
  250. package/document_loaders/web/cheerio.js +0 -1
  251. package/document_loaders/web/college_confidential.cjs +0 -1
  252. package/document_loaders/web/college_confidential.d.cts +0 -1
  253. package/document_loaders/web/college_confidential.d.ts +0 -1
  254. package/document_loaders/web/college_confidential.js +0 -1
  255. package/document_loaders/web/confluence.cjs +0 -1
  256. package/document_loaders/web/confluence.d.cts +0 -1
  257. package/document_loaders/web/confluence.d.ts +0 -1
  258. package/document_loaders/web/confluence.js +0 -1
  259. package/document_loaders/web/couchbase.cjs +0 -1
  260. package/document_loaders/web/couchbase.d.cts +0 -1
  261. package/document_loaders/web/couchbase.d.ts +0 -1
  262. package/document_loaders/web/couchbase.js +0 -1
  263. package/document_loaders/web/figma.cjs +0 -1
  264. package/document_loaders/web/figma.d.cts +0 -1
  265. package/document_loaders/web/figma.d.ts +0 -1
  266. package/document_loaders/web/figma.js +0 -1
  267. package/document_loaders/web/firecrawl.cjs +0 -1
  268. package/document_loaders/web/firecrawl.d.cts +0 -1
  269. package/document_loaders/web/firecrawl.d.ts +0 -1
  270. package/document_loaders/web/firecrawl.js +0 -1
  271. package/document_loaders/web/gitbook.cjs +0 -1
  272. package/document_loaders/web/gitbook.d.cts +0 -1
  273. package/document_loaders/web/gitbook.d.ts +0 -1
  274. package/document_loaders/web/gitbook.js +0 -1
  275. package/document_loaders/web/github.cjs +0 -1
  276. package/document_loaders/web/github.d.cts +0 -1
  277. package/document_loaders/web/github.d.ts +0 -1
  278. package/document_loaders/web/github.js +0 -1
  279. package/document_loaders/web/hn.cjs +0 -1
  280. package/document_loaders/web/hn.d.cts +0 -1
  281. package/document_loaders/web/hn.d.ts +0 -1
  282. package/document_loaders/web/hn.js +0 -1
  283. package/document_loaders/web/imsdb.cjs +0 -1
  284. package/document_loaders/web/imsdb.d.cts +0 -1
  285. package/document_loaders/web/imsdb.d.ts +0 -1
  286. package/document_loaders/web/imsdb.js +0 -1
  287. package/document_loaders/web/notionapi.cjs +0 -1
  288. package/document_loaders/web/notionapi.d.cts +0 -1
  289. package/document_loaders/web/notionapi.d.ts +0 -1
  290. package/document_loaders/web/notionapi.js +0 -1
  291. package/document_loaders/web/notiondb.cjs +0 -1
  292. package/document_loaders/web/notiondb.d.cts +0 -1
  293. package/document_loaders/web/notiondb.d.ts +0 -1
  294. package/document_loaders/web/notiondb.js +0 -1
  295. package/document_loaders/web/pdf.cjs +0 -1
  296. package/document_loaders/web/pdf.d.cts +0 -1
  297. package/document_loaders/web/pdf.d.ts +0 -1
  298. package/document_loaders/web/pdf.js +0 -1
  299. package/document_loaders/web/playwright.cjs +0 -1
  300. package/document_loaders/web/playwright.d.cts +0 -1
  301. package/document_loaders/web/playwright.d.ts +0 -1
  302. package/document_loaders/web/playwright.js +0 -1
  303. package/document_loaders/web/puppeteer.cjs +0 -1
  304. package/document_loaders/web/puppeteer.d.cts +0 -1
  305. package/document_loaders/web/puppeteer.d.ts +0 -1
  306. package/document_loaders/web/puppeteer.js +0 -1
  307. package/document_loaders/web/recursive_url.cjs +0 -1
  308. package/document_loaders/web/recursive_url.d.cts +0 -1
  309. package/document_loaders/web/recursive_url.d.ts +0 -1
  310. package/document_loaders/web/recursive_url.js +0 -1
  311. package/document_loaders/web/s3.cjs +0 -1
  312. package/document_loaders/web/s3.d.cts +0 -1
  313. package/document_loaders/web/s3.d.ts +0 -1
  314. package/document_loaders/web/s3.js +0 -1
  315. package/document_loaders/web/searchapi.cjs +0 -1
  316. package/document_loaders/web/searchapi.d.cts +0 -1
  317. package/document_loaders/web/searchapi.d.ts +0 -1
  318. package/document_loaders/web/searchapi.js +0 -1
  319. package/document_loaders/web/serpapi.cjs +0 -1
  320. package/document_loaders/web/serpapi.d.cts +0 -1
  321. package/document_loaders/web/serpapi.d.ts +0 -1
  322. package/document_loaders/web/serpapi.js +0 -1
  323. package/document_loaders/web/sitemap.cjs +0 -1
  324. package/document_loaders/web/sitemap.d.cts +0 -1
  325. package/document_loaders/web/sitemap.d.ts +0 -1
  326. package/document_loaders/web/sitemap.js +0 -1
  327. package/document_loaders/web/sonix_audio.cjs +0 -1
  328. package/document_loaders/web/sonix_audio.d.cts +0 -1
  329. package/document_loaders/web/sonix_audio.d.ts +0 -1
  330. package/document_loaders/web/sonix_audio.js +0 -1
  331. package/document_loaders/web/sort_xyz_blockchain.cjs +0 -1
  332. package/document_loaders/web/sort_xyz_blockchain.d.cts +0 -1
  333. package/document_loaders/web/sort_xyz_blockchain.d.ts +0 -1
  334. package/document_loaders/web/sort_xyz_blockchain.js +0 -1
  335. package/document_loaders/web/youtube.cjs +0 -1
  336. package/document_loaders/web/youtube.d.cts +0 -1
  337. package/document_loaders/web/youtube.d.ts +0 -1
  338. package/document_loaders/web/youtube.js +0 -1
  339. package/experimental/tools/pyinterpreter.cjs +0 -1
  340. package/experimental/tools/pyinterpreter.d.cts +0 -1
  341. package/experimental/tools/pyinterpreter.d.ts +0 -1
  342. package/experimental/tools/pyinterpreter.js +0 -1
  343. package/memory/index.cjs +0 -1
  344. package/memory/index.d.cts +0 -1
  345. package/memory/index.d.ts +0 -1
  346. package/memory/index.js +0 -1
  347. package/retrievers/self_query/chroma.cjs +0 -1
  348. package/retrievers/self_query/chroma.d.cts +0 -1
  349. package/retrievers/self_query/chroma.d.ts +0 -1
  350. package/retrievers/self_query/chroma.js +0 -1
  351. package/retrievers/self_query/pinecone.cjs +0 -1
  352. package/retrievers/self_query/pinecone.d.cts +0 -1
  353. package/retrievers/self_query/pinecone.d.ts +0 -1
  354. package/retrievers/self_query/pinecone.js +0 -1
  355. package/retrievers/self_query/supabase.cjs +0 -1
  356. package/retrievers/self_query/supabase.d.cts +0 -1
  357. package/retrievers/self_query/supabase.d.ts +0 -1
  358. package/retrievers/self_query/supabase.js +0 -1
  359. package/retrievers/self_query/vectara.cjs +0 -1
  360. package/retrievers/self_query/vectara.d.cts +0 -1
  361. package/retrievers/self_query/vectara.d.ts +0 -1
  362. package/retrievers/self_query/vectara.js +0 -1
  363. package/retrievers/self_query/weaviate.cjs +0 -1
  364. package/retrievers/self_query/weaviate.d.cts +0 -1
  365. package/retrievers/self_query/weaviate.d.ts +0 -1
  366. package/retrievers/self_query/weaviate.js +0 -1
@@ -1,186 +0,0 @@
1
- import { htmlToText } from "html-to-text";
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/confluence",
7
- newPackageName: "@langchain/community",
8
- });
9
- /**
10
- * @deprecated - Import from "@langchain/community/document_loaders/web/confluence" instead. This entrypoint will be removed in 0.3.0.
11
- *
12
- * Class representing a document loader for loading pages from Confluence.
13
- * @example
14
- * ```typescript
15
- * const loader = new ConfluencePagesLoader({
16
- * baseUrl: "https:
17
- * spaceKey: "~EXAMPLE362906de5d343d49dcdbae5dEXAMPLE",
18
- * username: "your-username",
19
- * accessToken: "your-access-token",
20
- * });
21
- * const documents = await loader.load();
22
- * console.log(documents);
23
- * ```
24
- */
25
- export class ConfluencePagesLoader extends BaseDocumentLoader {
26
- constructor({ baseUrl, spaceKey, username, accessToken, limit = 25, expand = "body.storage,version", personalAccessToken, }) {
27
- super();
28
- Object.defineProperty(this, "baseUrl", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: void 0
33
- });
34
- Object.defineProperty(this, "spaceKey", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- Object.defineProperty(this, "username", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: void 0
45
- });
46
- Object.defineProperty(this, "accessToken", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: void 0
51
- });
52
- Object.defineProperty(this, "limit", {
53
- enumerable: true,
54
- configurable: true,
55
- writable: true,
56
- value: void 0
57
- });
58
- /**
59
- * expand parameter for confluence rest api
60
- * description can be found at https://developer.atlassian.com/server/confluence/expansions-in-the-rest-api/
61
- */
62
- Object.defineProperty(this, "expand", {
63
- enumerable: true,
64
- configurable: true,
65
- writable: true,
66
- value: void 0
67
- });
68
- Object.defineProperty(this, "personalAccessToken", {
69
- enumerable: true,
70
- configurable: true,
71
- writable: true,
72
- value: void 0
73
- });
74
- this.baseUrl = baseUrl;
75
- this.spaceKey = spaceKey;
76
- this.username = username;
77
- this.accessToken = accessToken;
78
- this.limit = limit;
79
- this.expand = expand;
80
- this.personalAccessToken = personalAccessToken;
81
- }
82
- /**
83
- * Returns the authorization header for the request.
84
- * @returns The authorization header as a string, or undefined if no credentials were provided.
85
- */
86
- get authorizationHeader() {
87
- if (this.personalAccessToken) {
88
- return `Bearer ${this.personalAccessToken}`;
89
- }
90
- else if (this.username && this.accessToken) {
91
- const authToken = Buffer.from(`${this.username}:${this.accessToken}`).toString("base64");
92
- return `Basic ${authToken}`;
93
- }
94
- return undefined;
95
- }
96
- /**
97
- * Fetches all the pages in the specified space and converts each page to
98
- * a Document instance.
99
- * @param options the extra options of the load function
100
- * @param options.limit The limit parameter to overwrite the size to fetch pages.
101
- * @param options.start The start parameter to set inital offset to fetch pages.
102
- * @returns Promise resolving to an array of Document instances.
103
- */
104
- async load(options) {
105
- try {
106
- const pages = await this.fetchAllPagesInSpace(options?.start, options?.limit);
107
- return pages.map((page) => this.createDocumentFromPage(page));
108
- }
109
- catch (error) {
110
- console.error("Error:", error);
111
- return [];
112
- }
113
- }
114
- /**
115
- * Fetches data from the Confluence API using the provided URL.
116
- * @param url The URL to fetch data from.
117
- * @returns Promise resolving to the JSON response from the API.
118
- */
119
- async fetchConfluenceData(url) {
120
- try {
121
- const initialHeaders = {
122
- "Content-Type": "application/json",
123
- Accept: "application/json",
124
- };
125
- const authHeader = this.authorizationHeader;
126
- if (authHeader) {
127
- initialHeaders.Authorization = authHeader;
128
- }
129
- const response = await fetch(url, {
130
- headers: initialHeaders,
131
- });
132
- if (!response.ok) {
133
- throw new Error(`Failed to fetch ${url} from Confluence: ${response.status}`);
134
- }
135
- return await response.json();
136
- }
137
- catch (error) {
138
- throw new Error(`Failed to fetch ${url} from Confluence: ${error}`);
139
- }
140
- }
141
- /**
142
- * Recursively fetches all the pages in the specified space.
143
- * @param start The start parameter to paginate through the results.
144
- * @returns Promise resolving to an array of ConfluencePage objects.
145
- */
146
- async fetchAllPagesInSpace(start = 0, limit = this.limit) {
147
- const url = `${this.baseUrl}/rest/api/content?spaceKey=${this.spaceKey}&limit=${limit}&start=${start}&expand=${this.expand}`;
148
- const data = await this.fetchConfluenceData(url);
149
- if (data.size === 0) {
150
- return [];
151
- }
152
- const nextPageStart = start + data.size;
153
- const nextPageResults = await this.fetchAllPagesInSpace(nextPageStart, limit);
154
- return data.results.concat(nextPageResults);
155
- }
156
- /**
157
- * Creates a Document instance from a ConfluencePage object.
158
- * @param page The ConfluencePage object to convert.
159
- * @returns A Document instance.
160
- */
161
- createDocumentFromPage(page) {
162
- // Convert the HTML content to plain text
163
- const plainTextContent = htmlToText(page.body.storage.value, {
164
- wordwrap: false,
165
- preserveNewlines: false,
166
- });
167
- // Remove empty lines
168
- const textWithoutEmptyLines = plainTextContent.replace(/^\s*[\r\n]/gm, "");
169
- // Generate the URL
170
- const pageUrl = `${this.baseUrl}/spaces/${this.spaceKey}/pages/${page.id}`;
171
- // Return a langchain document
172
- return new Document({
173
- pageContent: textWithoutEmptyLines,
174
- metadata: {
175
- id: page.id,
176
- status: page.status,
177
- title: page.title,
178
- type: page.type,
179
- url: pageUrl,
180
- version: page.version?.number,
181
- updated_by: page.version?.by?.displayName,
182
- updated_at: page.version?.when,
183
- },
184
- });
185
- }
186
- }
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CouchbaseDocumentLoader = 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/couchbase",
9
- newPackageName: "@langchain/community",
10
- });
11
- /**
12
- * @deprecated - Import from "@langchain/community/document_loaders/web/couchbase" instead. This entrypoint will be removed in 0.3.0.
13
- *
14
- * loader for couchbase document
15
- */
16
- class CouchbaseDocumentLoader extends base_js_1.BaseDocumentLoader {
17
- /**
18
- * construct Couchbase document loader with a requirement for couchbase cluster client
19
- * @param client { Cluster } [ couchbase connected client to connect to database ]
20
- * @param query { string } [ query to get results from while loading the data ]
21
- * @param pageContentFields { Array<string> } [ filters fields of the document and shows these only ]
22
- * @param metadataFields { Array<string> } [ metadata fields required ]
23
- */
24
- constructor(client, query, pageContentFields, metadataFields) {
25
- super();
26
- Object.defineProperty(this, "cluster", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- Object.defineProperty(this, "query", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
- Object.defineProperty(this, "pageContentFields", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- Object.defineProperty(this, "metadataFields", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
- if (!client) {
51
- throw new Error("Couchbase client cluster must be provided.");
52
- }
53
- this.cluster = client;
54
- this.query = query;
55
- this.pageContentFields = pageContentFields;
56
- this.metadataFields = metadataFields;
57
- }
58
- /**
59
- * Function to load document based on query from couchbase
60
- * @returns {Promise<Document[]>} [ Returns a promise of all the documents as array ]
61
- */
62
- async load() {
63
- const documents = [];
64
- for await (const doc of this.lazyLoad()) {
65
- documents.push(doc);
66
- }
67
- return documents;
68
- }
69
- /**
70
- * Function to load documents based on iterator rather than full load
71
- * @returns {AsyncIterable<Document>} [ Returns an iterator to fetch documents ]
72
- */
73
- async *lazyLoad() {
74
- // Run SQL++ Query
75
- const result = await this.cluster.query(this.query);
76
- for await (const row of result.rows) {
77
- let { metadataFields, pageContentFields } = this;
78
- if (!pageContentFields) {
79
- pageContentFields = Object.keys(row);
80
- }
81
- if (!metadataFields) {
82
- metadataFields = [];
83
- }
84
- const metadata = metadataFields.reduce((obj, field) => ({ ...obj, [field]: row[field] }), {});
85
- const document = pageContentFields
86
- .map((k) => `${k}: ${JSON.stringify(row[k])}`)
87
- .join("\n");
88
- yield new documents_1.Document({
89
- pageContent: document,
90
- metadata,
91
- });
92
- }
93
- }
94
- }
95
- exports.CouchbaseDocumentLoader = CouchbaseDocumentLoader;
@@ -1,32 +0,0 @@
1
- import { Cluster } from "couchbase";
2
- import { Document } from "@langchain/core/documents";
3
- import { BaseDocumentLoader, DocumentLoader } from "../base.js";
4
- /**
5
- * @deprecated - Import from "@langchain/community/document_loaders/web/couchbase" instead. This entrypoint will be removed in 0.3.0.
6
- *
7
- * loader for couchbase document
8
- */
9
- export declare class CouchbaseDocumentLoader extends BaseDocumentLoader implements DocumentLoader {
10
- private cluster;
11
- private query;
12
- private pageContentFields?;
13
- private metadataFields?;
14
- /**
15
- * construct Couchbase document loader with a requirement for couchbase cluster client
16
- * @param client { Cluster } [ couchbase connected client to connect to database ]
17
- * @param query { string } [ query to get results from while loading the data ]
18
- * @param pageContentFields { Array<string> } [ filters fields of the document and shows these only ]
19
- * @param metadataFields { Array<string> } [ metadata fields required ]
20
- */
21
- constructor(client: Cluster, query: string, pageContentFields?: string[], metadataFields?: string[]);
22
- /**
23
- * Function to load document based on query from couchbase
24
- * @returns {Promise<Document[]>} [ Returns a promise of all the documents as array ]
25
- */
26
- load(): Promise<Document[]>;
27
- /**
28
- * Function to load documents based on iterator rather than full load
29
- * @returns {AsyncIterable<Document>} [ Returns an iterator to fetch documents ]
30
- */
31
- lazyLoad(): AsyncIterable<Document>;
32
- }
@@ -1,91 +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/couchbase",
6
- newPackageName: "@langchain/community",
7
- });
8
- /**
9
- * @deprecated - Import from "@langchain/community/document_loaders/web/couchbase" instead. This entrypoint will be removed in 0.3.0.
10
- *
11
- * loader for couchbase document
12
- */
13
- export class CouchbaseDocumentLoader extends BaseDocumentLoader {
14
- /**
15
- * construct Couchbase document loader with a requirement for couchbase cluster client
16
- * @param client { Cluster } [ couchbase connected client to connect to database ]
17
- * @param query { string } [ query to get results from while loading the data ]
18
- * @param pageContentFields { Array<string> } [ filters fields of the document and shows these only ]
19
- * @param metadataFields { Array<string> } [ metadata fields required ]
20
- */
21
- constructor(client, query, pageContentFields, metadataFields) {
22
- super();
23
- Object.defineProperty(this, "cluster", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- Object.defineProperty(this, "query", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: void 0
34
- });
35
- Object.defineProperty(this, "pageContentFields", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: void 0
40
- });
41
- Object.defineProperty(this, "metadataFields", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
- if (!client) {
48
- throw new Error("Couchbase client cluster must be provided.");
49
- }
50
- this.cluster = client;
51
- this.query = query;
52
- this.pageContentFields = pageContentFields;
53
- this.metadataFields = metadataFields;
54
- }
55
- /**
56
- * Function to load document based on query from couchbase
57
- * @returns {Promise<Document[]>} [ Returns a promise of all the documents as array ]
58
- */
59
- async load() {
60
- const documents = [];
61
- for await (const doc of this.lazyLoad()) {
62
- documents.push(doc);
63
- }
64
- return documents;
65
- }
66
- /**
67
- * Function to load documents based on iterator rather than full load
68
- * @returns {AsyncIterable<Document>} [ Returns an iterator to fetch documents ]
69
- */
70
- async *lazyLoad() {
71
- // Run SQL++ Query
72
- const result = await this.cluster.query(this.query);
73
- for await (const row of result.rows) {
74
- let { metadataFields, pageContentFields } = this;
75
- if (!pageContentFields) {
76
- pageContentFields = Object.keys(row);
77
- }
78
- if (!metadataFields) {
79
- metadataFields = [];
80
- }
81
- const metadata = metadataFields.reduce((obj, field) => ({ ...obj, [field]: row[field] }), {});
82
- const document = pageContentFields
83
- .map((k) => `${k}: ${JSON.stringify(row[k])}`)
84
- .join("\n");
85
- yield new Document({
86
- pageContent: document,
87
- metadata,
88
- });
89
- }
90
- }
91
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FigmaFileLoader = void 0;
4
- const documents_1 = require("@langchain/core/documents");
5
- const env_1 = require("@langchain/core/utils/env");
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/figma",
10
- newPackageName: "@langchain/community",
11
- });
12
- /**
13
- * @deprecated - Import from "@langchain/community/document_loaders/web/figma" instead. This entrypoint will be removed in 0.3.0.
14
- *
15
- * Class representing a document loader for loading Figma files. It
16
- * extends the BaseDocumentLoader and implements the FigmaLoaderParams
17
- * interface. The constructor takes a config object as a parameter, which
18
- * contains the access token, an array of node IDs, and the file key.
19
- * @example
20
- * ```typescript
21
- * const loader = new FigmaFileLoader({
22
- * accessToken: "FIGMA_ACCESS_TOKEN",
23
- * nodeIds: ["id1", "id2", "id3"],
24
- * fileKey: "key",
25
- * });
26
- * const docs = await loader.load();
27
- * ```
28
- */
29
- class FigmaFileLoader extends base_js_1.BaseDocumentLoader {
30
- constructor({ accessToken = (0, env_1.getEnvironmentVariable)("FIGMA_ACCESS_TOKEN"), nodeIds, fileKey, }) {
31
- super();
32
- Object.defineProperty(this, "accessToken", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
- Object.defineProperty(this, "nodeIds", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- Object.defineProperty(this, "fileKey", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
- Object.defineProperty(this, "headers", {
51
- enumerable: true,
52
- configurable: true,
53
- writable: true,
54
- value: {}
55
- });
56
- this.accessToken = accessToken;
57
- this.nodeIds = nodeIds;
58
- this.fileKey = fileKey;
59
- if (this.accessToken) {
60
- this.headers = {
61
- "x-figma-token": this.accessToken,
62
- };
63
- }
64
- }
65
- /**
66
- * Constructs the URL for the Figma API call.
67
- * @returns The constructed URL as a string.
68
- */
69
- constructFigmaApiURL() {
70
- return `https://api.figma.com/v1/files/${this.fileKey}/nodes?ids=${this.nodeIds.join(",")}`;
71
- }
72
- /**
73
- * Fetches the Figma file using the Figma API and returns it as a
74
- * FigmaFile object.
75
- * @returns A Promise that resolves to a FigmaFile object.
76
- */
77
- async getFigmaFile() {
78
- const url = this.constructFigmaApiURL();
79
- const response = await fetch(url, { headers: this.headers });
80
- const data = await response.json();
81
- if (!response.ok) {
82
- throw new Error(`Unable to get figma file: ${response.status} ${JSON.stringify(data)}`);
83
- }
84
- if (!data) {
85
- throw new Error("Unable to get file");
86
- }
87
- return data;
88
- }
89
- /**
90
- * Fetches the Figma file using the Figma API, creates a Document instance
91
- * with the JSON representation of the file as the page content and the
92
- * API URL as the metadata, and returns it.
93
- * @returns A Promise that resolves to an array of Document instances.
94
- */
95
- async load() {
96
- const data = await this.getFigmaFile();
97
- const text = JSON.stringify(data);
98
- const metadata = { source: this.constructFigmaApiURL() };
99
- return [new documents_1.Document({ pageContent: text, metadata })];
100
- }
101
- }
102
- exports.FigmaFileLoader = FigmaFileLoader;
@@ -1,82 +0,0 @@
1
- import { Document } from "@langchain/core/documents";
2
- import { BaseDocumentLoader } from "../base.js";
3
- /**
4
- * @deprecated - Import from "@langchain/community/document_loaders/web/figma" instead. This entrypoint will be removed in 0.3.0.
5
- *
6
- * Interface representing a Figma file. It includes properties for the
7
- * file name, role, last modified date, editor type, thumbnail URL,
8
- * version, document node, schema version, main file key, and an array of
9
- * branches.
10
- */
11
- export interface FigmaFile {
12
- name: string;
13
- role: string;
14
- lastModified: string;
15
- editorType: string;
16
- thumbnailUrl: string;
17
- version: string;
18
- document: Node;
19
- schemaVersion: number;
20
- mainFileKey: string;
21
- branches: Array<{
22
- key: string;
23
- name: string;
24
- thumbnail_url: string;
25
- last_modified: string;
26
- link_access: string;
27
- }>;
28
- }
29
- /**
30
- * @deprecated - Import from "@langchain/community/document_loaders/web/figma" instead. This entrypoint will be removed in 0.3.0.
31
- *
32
- * Interface representing the parameters for configuring the FigmaLoader.
33
- * It includes optional properties for the access token, an array of node
34
- * IDs, and the file key.
35
- */
36
- export interface FigmaLoaderParams {
37
- accessToken?: string;
38
- nodeIds: string[];
39
- fileKey: string;
40
- }
41
- /**
42
- * @deprecated - Import from "@langchain/community/document_loaders/web/figma" instead. This entrypoint will be removed in 0.3.0.
43
- *
44
- * Class representing a document loader for loading Figma files. It
45
- * extends the BaseDocumentLoader and implements the FigmaLoaderParams
46
- * interface. The constructor takes a config object as a parameter, which
47
- * contains the access token, an array of node IDs, and the file key.
48
- * @example
49
- * ```typescript
50
- * const loader = new FigmaFileLoader({
51
- * accessToken: "FIGMA_ACCESS_TOKEN",
52
- * nodeIds: ["id1", "id2", "id3"],
53
- * fileKey: "key",
54
- * });
55
- * const docs = await loader.load();
56
- * ```
57
- */
58
- export declare class FigmaFileLoader extends BaseDocumentLoader implements FigmaLoaderParams {
59
- accessToken?: string;
60
- nodeIds: string[];
61
- fileKey: string;
62
- private headers;
63
- constructor({ accessToken, nodeIds, fileKey, }: FigmaLoaderParams);
64
- /**
65
- * Constructs the URL for the Figma API call.
66
- * @returns The constructed URL as a string.
67
- */
68
- private constructFigmaApiURL;
69
- /**
70
- * Fetches the Figma file using the Figma API and returns it as a
71
- * FigmaFile object.
72
- * @returns A Promise that resolves to a FigmaFile object.
73
- */
74
- private getFigmaFile;
75
- /**
76
- * Fetches the Figma file using the Figma API, creates a Document instance
77
- * with the JSON representation of the file as the page content and the
78
- * API URL as the metadata, and returns it.
79
- * @returns A Promise that resolves to an array of Document instances.
80
- */
81
- load(): Promise<Document[]>;
82
- }
@@ -1,98 +0,0 @@
1
- import { Document } from "@langchain/core/documents";
2
- import { getEnvironmentVariable } from "@langchain/core/utils/env";
3
- import { BaseDocumentLoader } from "../base.js";
4
- import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation.js";
5
- /* #__PURE__ */ logVersion020MigrationWarning({
6
- oldEntrypointName: "document_loaders/web/figma",
7
- newPackageName: "@langchain/community",
8
- });
9
- /**
10
- * @deprecated - Import from "@langchain/community/document_loaders/web/figma" instead. This entrypoint will be removed in 0.3.0.
11
- *
12
- * Class representing a document loader for loading Figma files. It
13
- * extends the BaseDocumentLoader and implements the FigmaLoaderParams
14
- * interface. The constructor takes a config object as a parameter, which
15
- * contains the access token, an array of node IDs, and the file key.
16
- * @example
17
- * ```typescript
18
- * const loader = new FigmaFileLoader({
19
- * accessToken: "FIGMA_ACCESS_TOKEN",
20
- * nodeIds: ["id1", "id2", "id3"],
21
- * fileKey: "key",
22
- * });
23
- * const docs = await loader.load();
24
- * ```
25
- */
26
- export class FigmaFileLoader extends BaseDocumentLoader {
27
- constructor({ accessToken = getEnvironmentVariable("FIGMA_ACCESS_TOKEN"), nodeIds, fileKey, }) {
28
- super();
29
- Object.defineProperty(this, "accessToken", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: void 0
34
- });
35
- Object.defineProperty(this, "nodeIds", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: void 0
40
- });
41
- Object.defineProperty(this, "fileKey", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
- Object.defineProperty(this, "headers", {
48
- enumerable: true,
49
- configurable: true,
50
- writable: true,
51
- value: {}
52
- });
53
- this.accessToken = accessToken;
54
- this.nodeIds = nodeIds;
55
- this.fileKey = fileKey;
56
- if (this.accessToken) {
57
- this.headers = {
58
- "x-figma-token": this.accessToken,
59
- };
60
- }
61
- }
62
- /**
63
- * Constructs the URL for the Figma API call.
64
- * @returns The constructed URL as a string.
65
- */
66
- constructFigmaApiURL() {
67
- return `https://api.figma.com/v1/files/${this.fileKey}/nodes?ids=${this.nodeIds.join(",")}`;
68
- }
69
- /**
70
- * Fetches the Figma file using the Figma API and returns it as a
71
- * FigmaFile object.
72
- * @returns A Promise that resolves to a FigmaFile object.
73
- */
74
- async getFigmaFile() {
75
- const url = this.constructFigmaApiURL();
76
- const response = await fetch(url, { headers: this.headers });
77
- const data = await response.json();
78
- if (!response.ok) {
79
- throw new Error(`Unable to get figma file: ${response.status} ${JSON.stringify(data)}`);
80
- }
81
- if (!data) {
82
- throw new Error("Unable to get file");
83
- }
84
- return data;
85
- }
86
- /**
87
- * Fetches the Figma file using the Figma API, creates a Document instance
88
- * with the JSON representation of the file as the page content and the
89
- * API URL as the metadata, and returns it.
90
- * @returns A Promise that resolves to an array of Document instances.
91
- */
92
- async load() {
93
- const data = await this.getFigmaFile();
94
- const text = JSON.stringify(data);
95
- const metadata = { source: this.constructFigmaApiURL() };
96
- return [new Document({ pageContent: text, metadata })];
97
- }
98
- }