Public
Script
October 23, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import process from "node:process";
export async function getWebLoaderBuilder(
url: string,
type: "webpage" | "github" | "audio" = "webpage",
options?: any,
) {
const { cond, matches } = await import("npm:lodash-es");
const setup = cond([
[
matches({ type: "webpage" }),
async () => {
await import("npm:cheerio");
const { CheerioWebBaseLoader } = await import(
"npm:langchain/document_loaders/web/cheerio"
);
return new CheerioWebBaseLoader(url);
},
],
[
matches({ type: "github" }),
async () => {
await import("npm:ignore");
const { GithubRepoLoader } = await import(
"npm:langchain/document_loaders/web/github"
);
return new GithubRepoLoader(url, options);
},
],
[
matches({ type: "audio" }),
async () => {
const { AudioTranscriptLoader } = await import(
"npm:langchain/document_loaders/web/assemblyai"
);
return new AudioTranscriptLoader({
audio_url: url,
...options,
}, {
apiKey: process.env.ASSEMBLYAI,
});
},
],
]);
return () => setup({ type });
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023