langchain 0.2.18 → 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.
- package/dist/agents/openai_functions/index.cjs +2 -2
- package/dist/agents/openai_functions/index.js +2 -2
- package/dist/chains/combine_documents/stuff.cjs +2 -2
- package/dist/chains/combine_documents/stuff.js +2 -2
- package/dist/chains/openai_functions/openapi.cjs +3 -1
- package/dist/chains/openai_functions/openapi.js +3 -1
- package/dist/load/import_constants.cjs +2 -39
- package/dist/load/import_constants.js +2 -39
- package/dist/load/import_map.cjs +2 -3
- package/dist/load/import_map.d.ts +0 -1
- package/dist/load/import_map.js +0 -1
- package/dist/smith/config.d.ts +1 -5
- package/package.json +31 -854
- package/dist/document_loaders/fs/chatgpt.cjs +0 -90
- package/dist/document_loaders/fs/chatgpt.d.ts +0 -8
- package/dist/document_loaders/fs/chatgpt.js +0 -86
- package/dist/document_loaders/fs/csv.cjs +0 -73
- package/dist/document_loaders/fs/csv.d.ts +0 -65
- package/dist/document_loaders/fs/csv.js +0 -69
- package/dist/document_loaders/fs/docx.cjs +0 -58
- package/dist/document_loaders/fs/docx.d.ts +0 -25
- package/dist/document_loaders/fs/docx.js +0 -54
- package/dist/document_loaders/fs/epub.cjs +0 -103
- package/dist/document_loaders/fs/epub.d.ts +0 -33
- package/dist/document_loaders/fs/epub.js +0 -99
- package/dist/document_loaders/fs/notion.cjs +0 -26
- package/dist/document_loaders/fs/notion.d.ts +0 -12
- package/dist/document_loaders/fs/notion.js +0 -22
- package/dist/document_loaders/fs/obsidian.cjs +0 -247
- package/dist/document_loaders/fs/obsidian.d.ts +0 -28
- package/dist/document_loaders/fs/obsidian.js +0 -240
- package/dist/document_loaders/fs/openai_whisper_audio.cjs +0 -49
- package/dist/document_loaders/fs/openai_whisper_audio.d.ts +0 -23
- package/dist/document_loaders/fs/openai_whisper_audio.js +0 -45
- package/dist/document_loaders/fs/pdf.cjs +0 -148
- package/dist/document_loaders/fs/pdf.d.ts +0 -49
- package/dist/document_loaders/fs/pdf.js +0 -144
- package/dist/document_loaders/fs/pptx.cjs +0 -46
- package/dist/document_loaders/fs/pptx.d.ts +0 -25
- package/dist/document_loaders/fs/pptx.js +0 -42
- package/dist/document_loaders/fs/srt.cjs +0 -57
- package/dist/document_loaders/fs/srt.d.ts +0 -32
- package/dist/document_loaders/fs/srt.js +0 -50
- package/dist/document_loaders/fs/unstructured.cjs +0 -338
- package/dist/document_loaders/fs/unstructured.d.ts +0 -125
- package/dist/document_loaders/fs/unstructured.js +0 -333
- package/dist/document_loaders/web/apify_dataset.cjs +0 -130
- package/dist/document_loaders/web/apify_dataset.d.ts +0 -85
- package/dist/document_loaders/web/apify_dataset.js +0 -126
- package/dist/document_loaders/web/assemblyai.cjs +0 -200
- package/dist/document_loaders/web/assemblyai.d.ts +0 -95
- package/dist/document_loaders/web/assemblyai.js +0 -193
- package/dist/document_loaders/web/azure_blob_storage_container.cjs +0 -73
- package/dist/document_loaders/web/azure_blob_storage_container.d.ts +0 -46
- package/dist/document_loaders/web/azure_blob_storage_container.js +0 -69
- package/dist/document_loaders/web/azure_blob_storage_file.cjs +0 -124
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +0 -53
- package/dist/document_loaders/web/azure_blob_storage_file.js +0 -97
- package/dist/document_loaders/web/browserbase.cjs +0 -93
- package/dist/document_loaders/web/browserbase.d.ts +0 -48
- package/dist/document_loaders/web/browserbase.js +0 -86
- package/dist/document_loaders/web/cheerio.cjs +0 -118
- package/dist/document_loaders/web/cheerio.d.ts +0 -77
- package/dist/document_loaders/web/cheerio.js +0 -114
- package/dist/document_loaders/web/college_confidential.cjs +0 -41
- package/dist/document_loaders/web/college_confidential.d.ts +0 -25
- package/dist/document_loaders/web/college_confidential.js +0 -37
- package/dist/document_loaders/web/confluence.cjs +0 -190
- package/dist/document_loaders/web/confluence.d.ts +0 -114
- package/dist/document_loaders/web/confluence.js +0 -186
- package/dist/document_loaders/web/couchbase.cjs +0 -95
- package/dist/document_loaders/web/couchbase.d.ts +0 -32
- package/dist/document_loaders/web/couchbase.js +0 -91
- package/dist/document_loaders/web/figma.cjs +0 -102
- package/dist/document_loaders/web/figma.d.ts +0 -82
- package/dist/document_loaders/web/figma.js +0 -98
- package/dist/document_loaders/web/firecrawl.cjs +0 -95
- package/dist/document_loaders/web/firecrawl.d.ts +0 -50
- package/dist/document_loaders/web/firecrawl.js +0 -88
- package/dist/document_loaders/web/gitbook.cjs +0 -110
- package/dist/document_loaders/web/gitbook.d.ts +0 -55
- package/dist/document_loaders/web/gitbook.js +0 -106
- package/dist/document_loaders/web/github.cjs +0 -615
- package/dist/document_loaders/web/github.d.ts +0 -203
- package/dist/document_loaders/web/github.js +0 -608
- package/dist/document_loaders/web/hn.cjs +0 -90
- package/dist/document_loaders/web/hn.d.ts +0 -42
- package/dist/document_loaders/web/hn.js +0 -86
- package/dist/document_loaders/web/imsdb.cjs +0 -44
- package/dist/document_loaders/web/imsdb.d.ts +0 -23
- package/dist/document_loaders/web/imsdb.js +0 -40
- package/dist/document_loaders/web/notionapi.cjs +0 -404
- package/dist/document_loaders/web/notionapi.d.ts +0 -133
- package/dist/document_loaders/web/notionapi.js +0 -392
- package/dist/document_loaders/web/notiondb.cjs +0 -199
- package/dist/document_loaders/web/notiondb.d.ts +0 -56
- package/dist/document_loaders/web/notiondb.js +0 -195
- package/dist/document_loaders/web/pdf.cjs +0 -140
- package/dist/document_loaders/web/pdf.d.ts +0 -35
- package/dist/document_loaders/web/pdf.js +0 -136
- package/dist/document_loaders/web/playwright.cjs +0 -89
- package/dist/document_loaders/web/playwright.d.ts +0 -58
- package/dist/document_loaders/web/playwright.js +0 -85
- package/dist/document_loaders/web/puppeteer.cjs +0 -139
- package/dist/document_loaders/web/puppeteer.d.ts +0 -82
- package/dist/document_loaders/web/puppeteer.js +0 -135
- package/dist/document_loaders/web/recursive_url.cjs +0 -198
- package/dist/document_loaders/web/recursive_url.d.ts +0 -33
- package/dist/document_loaders/web/recursive_url.js +0 -194
- package/dist/document_loaders/web/s3.cjs +0 -164
- package/dist/document_loaders/web/s3.d.ts +0 -78
- package/dist/document_loaders/web/s3.js +0 -137
- package/dist/document_loaders/web/searchapi.cjs +0 -150
- package/dist/document_loaders/web/searchapi.d.ts +0 -76
- package/dist/document_loaders/web/searchapi.js +0 -146
- package/dist/document_loaders/web/serpapi.cjs +0 -127
- package/dist/document_loaders/web/serpapi.d.ts +0 -62
- package/dist/document_loaders/web/serpapi.js +0 -123
- package/dist/document_loaders/web/sitemap.cjs +0 -118
- package/dist/document_loaders/web/sitemap.d.ts +0 -41
- package/dist/document_loaders/web/sitemap.js +0 -114
- package/dist/document_loaders/web/sonix_audio.cjs +0 -68
- package/dist/document_loaders/web/sonix_audio.d.ts +0 -36
- package/dist/document_loaders/web/sonix_audio.js +0 -64
- package/dist/document_loaders/web/sort_xyz_blockchain.cjs +0 -157
- package/dist/document_loaders/web/sort_xyz_blockchain.d.ts +0 -78
- package/dist/document_loaders/web/sort_xyz_blockchain.js +0 -153
- package/dist/document_loaders/web/youtube.cjs +0 -116
- package/dist/document_loaders/web/youtube.d.ts +0 -55
- package/dist/document_loaders/web/youtube.js +0 -112
- package/dist/experimental/tools/pyinterpreter.cjs +0 -248
- package/dist/experimental/tools/pyinterpreter.d.ts +0 -18
- package/dist/experimental/tools/pyinterpreter.js +0 -244
- package/dist/retrievers/self_query/chroma.cjs +0 -48
- package/dist/retrievers/self_query/chroma.d.ts +0 -26
- package/dist/retrievers/self_query/chroma.js +0 -44
- package/dist/retrievers/self_query/pinecone.cjs +0 -47
- package/dist/retrievers/self_query/pinecone.d.ts +0 -26
- package/dist/retrievers/self_query/pinecone.js +0 -43
- package/dist/retrievers/self_query/supabase.cjs +0 -278
- package/dist/retrievers/self_query/supabase.d.ts +0 -109
- package/dist/retrievers/self_query/supabase.js +0 -274
- package/dist/retrievers/self_query/supabase_utils.cjs +0 -264
- package/dist/retrievers/self_query/supabase_utils.d.ts +0 -101
- package/dist/retrievers/self_query/supabase_utils.js +0 -259
- package/dist/retrievers/self_query/vectara.cjs +0 -143
- package/dist/retrievers/self_query/vectara.d.ts +0 -42
- package/dist/retrievers/self_query/vectara.js +0 -139
- package/dist/retrievers/self_query/weaviate.cjs +0 -201
- package/dist/retrievers/self_query/weaviate.d.ts +0 -99
- package/dist/retrievers/self_query/weaviate.js +0 -197
- package/dist/types/assemblyai-types.cjs +0 -2
- package/dist/types/assemblyai-types.d.ts +0 -4
- package/dist/types/assemblyai-types.js +0 -1
- package/document_loaders/fs/chatgpt.cjs +0 -1
- package/document_loaders/fs/chatgpt.d.cts +0 -1
- package/document_loaders/fs/chatgpt.d.ts +0 -1
- package/document_loaders/fs/chatgpt.js +0 -1
- package/document_loaders/fs/csv.cjs +0 -1
- package/document_loaders/fs/csv.d.cts +0 -1
- package/document_loaders/fs/csv.d.ts +0 -1
- package/document_loaders/fs/csv.js +0 -1
- package/document_loaders/fs/docx.cjs +0 -1
- package/document_loaders/fs/docx.d.cts +0 -1
- package/document_loaders/fs/docx.d.ts +0 -1
- package/document_loaders/fs/docx.js +0 -1
- package/document_loaders/fs/epub.cjs +0 -1
- package/document_loaders/fs/epub.d.cts +0 -1
- package/document_loaders/fs/epub.d.ts +0 -1
- package/document_loaders/fs/epub.js +0 -1
- package/document_loaders/fs/notion.cjs +0 -1
- package/document_loaders/fs/notion.d.cts +0 -1
- package/document_loaders/fs/notion.d.ts +0 -1
- package/document_loaders/fs/notion.js +0 -1
- package/document_loaders/fs/obsidian.cjs +0 -1
- package/document_loaders/fs/obsidian.d.cts +0 -1
- package/document_loaders/fs/obsidian.d.ts +0 -1
- package/document_loaders/fs/obsidian.js +0 -1
- package/document_loaders/fs/openai_whisper_audio.cjs +0 -1
- package/document_loaders/fs/openai_whisper_audio.d.cts +0 -1
- package/document_loaders/fs/openai_whisper_audio.d.ts +0 -1
- package/document_loaders/fs/openai_whisper_audio.js +0 -1
- package/document_loaders/fs/pdf.cjs +0 -1
- package/document_loaders/fs/pdf.d.cts +0 -1
- package/document_loaders/fs/pdf.d.ts +0 -1
- package/document_loaders/fs/pdf.js +0 -1
- package/document_loaders/fs/pptx.cjs +0 -1
- package/document_loaders/fs/pptx.d.cts +0 -1
- package/document_loaders/fs/pptx.d.ts +0 -1
- package/document_loaders/fs/pptx.js +0 -1
- package/document_loaders/fs/srt.cjs +0 -1
- package/document_loaders/fs/srt.d.cts +0 -1
- package/document_loaders/fs/srt.d.ts +0 -1
- package/document_loaders/fs/srt.js +0 -1
- package/document_loaders/fs/unstructured.cjs +0 -1
- package/document_loaders/fs/unstructured.d.cts +0 -1
- package/document_loaders/fs/unstructured.d.ts +0 -1
- package/document_loaders/fs/unstructured.js +0 -1
- package/document_loaders/web/apify_dataset.cjs +0 -1
- package/document_loaders/web/apify_dataset.d.cts +0 -1
- package/document_loaders/web/apify_dataset.d.ts +0 -1
- package/document_loaders/web/apify_dataset.js +0 -1
- package/document_loaders/web/assemblyai.cjs +0 -1
- package/document_loaders/web/assemblyai.d.cts +0 -1
- package/document_loaders/web/assemblyai.d.ts +0 -1
- package/document_loaders/web/assemblyai.js +0 -1
- package/document_loaders/web/azure_blob_storage_container.cjs +0 -1
- package/document_loaders/web/azure_blob_storage_container.d.cts +0 -1
- package/document_loaders/web/azure_blob_storage_container.d.ts +0 -1
- package/document_loaders/web/azure_blob_storage_container.js +0 -1
- package/document_loaders/web/azure_blob_storage_file.cjs +0 -1
- package/document_loaders/web/azure_blob_storage_file.d.cts +0 -1
- package/document_loaders/web/azure_blob_storage_file.d.ts +0 -1
- package/document_loaders/web/azure_blob_storage_file.js +0 -1
- package/document_loaders/web/browserbase.cjs +0 -1
- package/document_loaders/web/browserbase.d.cts +0 -1
- package/document_loaders/web/browserbase.d.ts +0 -1
- package/document_loaders/web/browserbase.js +0 -1
- package/document_loaders/web/cheerio.cjs +0 -1
- package/document_loaders/web/cheerio.d.cts +0 -1
- package/document_loaders/web/cheerio.d.ts +0 -1
- package/document_loaders/web/cheerio.js +0 -1
- package/document_loaders/web/college_confidential.cjs +0 -1
- package/document_loaders/web/college_confidential.d.cts +0 -1
- package/document_loaders/web/college_confidential.d.ts +0 -1
- package/document_loaders/web/college_confidential.js +0 -1
- package/document_loaders/web/confluence.cjs +0 -1
- package/document_loaders/web/confluence.d.cts +0 -1
- package/document_loaders/web/confluence.d.ts +0 -1
- package/document_loaders/web/confluence.js +0 -1
- package/document_loaders/web/couchbase.cjs +0 -1
- package/document_loaders/web/couchbase.d.cts +0 -1
- package/document_loaders/web/couchbase.d.ts +0 -1
- package/document_loaders/web/couchbase.js +0 -1
- package/document_loaders/web/figma.cjs +0 -1
- package/document_loaders/web/figma.d.cts +0 -1
- package/document_loaders/web/figma.d.ts +0 -1
- package/document_loaders/web/figma.js +0 -1
- package/document_loaders/web/firecrawl.cjs +0 -1
- package/document_loaders/web/firecrawl.d.cts +0 -1
- package/document_loaders/web/firecrawl.d.ts +0 -1
- package/document_loaders/web/firecrawl.js +0 -1
- package/document_loaders/web/gitbook.cjs +0 -1
- package/document_loaders/web/gitbook.d.cts +0 -1
- package/document_loaders/web/gitbook.d.ts +0 -1
- package/document_loaders/web/gitbook.js +0 -1
- package/document_loaders/web/github.cjs +0 -1
- package/document_loaders/web/github.d.cts +0 -1
- package/document_loaders/web/github.d.ts +0 -1
- package/document_loaders/web/github.js +0 -1
- package/document_loaders/web/hn.cjs +0 -1
- package/document_loaders/web/hn.d.cts +0 -1
- package/document_loaders/web/hn.d.ts +0 -1
- package/document_loaders/web/hn.js +0 -1
- package/document_loaders/web/imsdb.cjs +0 -1
- package/document_loaders/web/imsdb.d.cts +0 -1
- package/document_loaders/web/imsdb.d.ts +0 -1
- package/document_loaders/web/imsdb.js +0 -1
- package/document_loaders/web/notionapi.cjs +0 -1
- package/document_loaders/web/notionapi.d.cts +0 -1
- package/document_loaders/web/notionapi.d.ts +0 -1
- package/document_loaders/web/notionapi.js +0 -1
- package/document_loaders/web/notiondb.cjs +0 -1
- package/document_loaders/web/notiondb.d.cts +0 -1
- package/document_loaders/web/notiondb.d.ts +0 -1
- package/document_loaders/web/notiondb.js +0 -1
- package/document_loaders/web/pdf.cjs +0 -1
- package/document_loaders/web/pdf.d.cts +0 -1
- package/document_loaders/web/pdf.d.ts +0 -1
- package/document_loaders/web/pdf.js +0 -1
- package/document_loaders/web/playwright.cjs +0 -1
- package/document_loaders/web/playwright.d.cts +0 -1
- package/document_loaders/web/playwright.d.ts +0 -1
- package/document_loaders/web/playwright.js +0 -1
- package/document_loaders/web/puppeteer.cjs +0 -1
- package/document_loaders/web/puppeteer.d.cts +0 -1
- package/document_loaders/web/puppeteer.d.ts +0 -1
- package/document_loaders/web/puppeteer.js +0 -1
- package/document_loaders/web/recursive_url.cjs +0 -1
- package/document_loaders/web/recursive_url.d.cts +0 -1
- package/document_loaders/web/recursive_url.d.ts +0 -1
- package/document_loaders/web/recursive_url.js +0 -1
- package/document_loaders/web/s3.cjs +0 -1
- package/document_loaders/web/s3.d.cts +0 -1
- package/document_loaders/web/s3.d.ts +0 -1
- package/document_loaders/web/s3.js +0 -1
- package/document_loaders/web/searchapi.cjs +0 -1
- package/document_loaders/web/searchapi.d.cts +0 -1
- package/document_loaders/web/searchapi.d.ts +0 -1
- package/document_loaders/web/searchapi.js +0 -1
- package/document_loaders/web/serpapi.cjs +0 -1
- package/document_loaders/web/serpapi.d.cts +0 -1
- package/document_loaders/web/serpapi.d.ts +0 -1
- package/document_loaders/web/serpapi.js +0 -1
- package/document_loaders/web/sitemap.cjs +0 -1
- package/document_loaders/web/sitemap.d.cts +0 -1
- package/document_loaders/web/sitemap.d.ts +0 -1
- package/document_loaders/web/sitemap.js +0 -1
- package/document_loaders/web/sonix_audio.cjs +0 -1
- package/document_loaders/web/sonix_audio.d.cts +0 -1
- package/document_loaders/web/sonix_audio.d.ts +0 -1
- package/document_loaders/web/sonix_audio.js +0 -1
- package/document_loaders/web/sort_xyz_blockchain.cjs +0 -1
- package/document_loaders/web/sort_xyz_blockchain.d.cts +0 -1
- package/document_loaders/web/sort_xyz_blockchain.d.ts +0 -1
- package/document_loaders/web/sort_xyz_blockchain.js +0 -1
- package/document_loaders/web/youtube.cjs +0 -1
- package/document_loaders/web/youtube.d.cts +0 -1
- package/document_loaders/web/youtube.d.ts +0 -1
- package/document_loaders/web/youtube.js +0 -1
- package/experimental/tools/pyinterpreter.cjs +0 -1
- package/experimental/tools/pyinterpreter.d.cts +0 -1
- package/experimental/tools/pyinterpreter.d.ts +0 -1
- package/experimental/tools/pyinterpreter.js +0 -1
- package/memory/index.cjs +0 -1
- package/memory/index.d.cts +0 -1
- package/memory/index.d.ts +0 -1
- package/memory/index.js +0 -1
- package/retrievers/self_query/chroma.cjs +0 -1
- package/retrievers/self_query/chroma.d.cts +0 -1
- package/retrievers/self_query/chroma.d.ts +0 -1
- package/retrievers/self_query/chroma.js +0 -1
- package/retrievers/self_query/pinecone.cjs +0 -1
- package/retrievers/self_query/pinecone.d.cts +0 -1
- package/retrievers/self_query/pinecone.d.ts +0 -1
- package/retrievers/self_query/pinecone.js +0 -1
- package/retrievers/self_query/supabase.cjs +0 -1
- package/retrievers/self_query/supabase.d.cts +0 -1
- package/retrievers/self_query/supabase.d.ts +0 -1
- package/retrievers/self_query/supabase.js +0 -1
- package/retrievers/self_query/vectara.cjs +0 -1
- package/retrievers/self_query/vectara.d.cts +0 -1
- package/retrievers/self_query/vectara.d.ts +0 -1
- package/retrievers/self_query/vectara.js +0 -1
- package/retrievers/self_query/weaviate.cjs +0 -1
- package/retrievers/self_query/weaviate.d.cts +0 -1
- package/retrievers/self_query/weaviate.d.ts +0 -1
- 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
|
-
}
|