langchain 0.0.205 → 0.0.207
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.
|
@@ -10,7 +10,7 @@ const env_js_1 = require("../../util/env.cjs");
|
|
|
10
10
|
*/
|
|
11
11
|
class AssemblyAILoader extends base_js_1.BaseDocumentLoader {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Create a new AssemblyAI loader.
|
|
14
14
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
15
15
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
16
16
|
*/
|
|
@@ -37,14 +37,14 @@ class AssemblyAILoader extends base_js_1.BaseDocumentLoader {
|
|
|
37
37
|
}
|
|
38
38
|
class CreateTranscriptLoader extends AssemblyAILoader {
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param params The parameters to
|
|
40
|
+
* Transcribe audio or retrieve an existing transcript by its ID.
|
|
41
|
+
* @param params The parameters to transcribe audio, or the ID of the transcript to retrieve.
|
|
42
42
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
43
43
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
44
44
|
*/
|
|
45
45
|
constructor(params, assemblyAIOptions) {
|
|
46
46
|
super(assemblyAIOptions);
|
|
47
|
-
Object.defineProperty(this, "
|
|
47
|
+
Object.defineProperty(this, "transcribeParams", {
|
|
48
48
|
enumerable: true,
|
|
49
49
|
configurable: true,
|
|
50
50
|
writable: true,
|
|
@@ -60,38 +60,42 @@ class CreateTranscriptLoader extends AssemblyAILoader {
|
|
|
60
60
|
this.transcriptId = params;
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
this.
|
|
63
|
+
this.transcribeParams = params;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
async
|
|
66
|
+
async transcribeOrGetTranscript() {
|
|
67
67
|
if (this.transcriptId) {
|
|
68
68
|
return await this.client.transcripts.get(this.transcriptId);
|
|
69
69
|
}
|
|
70
|
-
if (this.
|
|
71
|
-
|
|
70
|
+
if (this.transcribeParams) {
|
|
71
|
+
let transcribeParams;
|
|
72
|
+
if ("audio_url" in this.transcribeParams) {
|
|
73
|
+
transcribeParams = {
|
|
74
|
+
...this.transcribeParams,
|
|
75
|
+
audio: this.transcribeParams.audio_url,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
transcribeParams = this.transcribeParams;
|
|
80
|
+
}
|
|
81
|
+
return await this.client.transcripts.transcribe(transcribeParams);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error("No transcript ID or transcribe parameters provided");
|
|
72
85
|
}
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* const loader = new AudioTranscriptLoader(
|
|
80
|
-
* { audio_url: "https:
|
|
81
|
-
* { apiKey: "ASSEMBLYAI_API_KEY" },
|
|
82
|
-
* );
|
|
83
|
-
* const docs = await loader.load();
|
|
84
|
-
* console.dir(docs, { depth: Infinity });
|
|
85
|
-
* ```
|
|
89
|
+
* Transcribe audio and load the transcript as a document using AssemblyAI.
|
|
86
90
|
*/
|
|
87
91
|
class AudioTranscriptLoader extends CreateTranscriptLoader {
|
|
88
92
|
/**
|
|
89
|
-
*
|
|
93
|
+
* Transcribe audio and load the transcript as a document using AssemblyAI.
|
|
90
94
|
* @returns A promise that resolves to a single document containing the transcript text
|
|
91
95
|
* as the page content, and the transcript object as the metadata.
|
|
92
96
|
*/
|
|
93
97
|
async load() {
|
|
94
|
-
const transcript = await this.
|
|
98
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
95
99
|
return [
|
|
96
100
|
new document_js_1.Document({
|
|
97
101
|
pageContent: transcript.text,
|
|
@@ -102,15 +106,15 @@ class AudioTranscriptLoader extends CreateTranscriptLoader {
|
|
|
102
106
|
}
|
|
103
107
|
exports.AudioTranscriptLoader = AudioTranscriptLoader;
|
|
104
108
|
/**
|
|
105
|
-
*
|
|
109
|
+
* Transcribe audio and load the paragraphs of the transcript, creating a document for each paragraph.
|
|
106
110
|
*/
|
|
107
111
|
class AudioTranscriptParagraphsLoader extends CreateTranscriptLoader {
|
|
108
112
|
/**
|
|
109
|
-
*
|
|
113
|
+
* Transcribe audio and load the paragraphs of the transcript, creating a document for each paragraph.
|
|
110
114
|
* @returns A promise that resolves to an array of documents, each containing a paragraph of the transcript.
|
|
111
115
|
*/
|
|
112
116
|
async load() {
|
|
113
|
-
const transcript = await this.
|
|
117
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
114
118
|
const paragraphsResponse = await this.client.transcripts.paragraphs(transcript.id);
|
|
115
119
|
return paragraphsResponse.paragraphs.map((p) => new document_js_1.Document({
|
|
116
120
|
pageContent: p.text,
|
|
@@ -120,16 +124,15 @@ class AudioTranscriptParagraphsLoader extends CreateTranscriptLoader {
|
|
|
120
124
|
}
|
|
121
125
|
exports.AudioTranscriptParagraphsLoader = AudioTranscriptParagraphsLoader;
|
|
122
126
|
/**
|
|
123
|
-
*
|
|
124
|
-
* and loads the sentences of the transcript, creating a document for each sentence.
|
|
127
|
+
* Transcribe audio and load the sentences of the transcript, creating a document for each sentence.
|
|
125
128
|
*/
|
|
126
129
|
class AudioTranscriptSentencesLoader extends CreateTranscriptLoader {
|
|
127
130
|
/**
|
|
128
|
-
*
|
|
131
|
+
* Transcribe audio and load the sentences of the transcript, creating a document for each sentence.
|
|
129
132
|
* @returns A promise that resolves to an array of documents, each containing a sentence of the transcript.
|
|
130
133
|
*/
|
|
131
134
|
async load() {
|
|
132
|
-
const transcript = await this.
|
|
135
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
133
136
|
const sentencesResponse = await this.client.transcripts.sentences(transcript.id);
|
|
134
137
|
return sentencesResponse.sentences.map((p) => new document_js_1.Document({
|
|
135
138
|
pageContent: p.text,
|
|
@@ -139,27 +142,12 @@ class AudioTranscriptSentencesLoader extends CreateTranscriptLoader {
|
|
|
139
142
|
}
|
|
140
143
|
exports.AudioTranscriptSentencesLoader = AudioTranscriptSentencesLoader;
|
|
141
144
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```typescript
|
|
145
|
-
* const loader = new AudioSubtitleLoader(
|
|
146
|
-
* {
|
|
147
|
-
* audio_url: "https:
|
|
148
|
-
* },
|
|
149
|
-
* "srt",
|
|
150
|
-
* {
|
|
151
|
-
* apiKey: "<ASSEMBLYAI_API_KEY>",
|
|
152
|
-
* },
|
|
153
|
-
* );
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* const docs = await loader.load();
|
|
157
|
-
* ```
|
|
145
|
+
* Transcribe audio and load subtitles for the transcript as `srt` or `vtt` format.
|
|
158
146
|
*/
|
|
159
147
|
class AudioSubtitleLoader extends CreateTranscriptLoader {
|
|
160
148
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param params The parameters to
|
|
149
|
+
* Create a new AudioSubtitleLoader.
|
|
150
|
+
* @param params The parameters to transcribe audio, or the ID of the transcript to retrieve.
|
|
163
151
|
* @param subtitleFormat The format of the subtitles, either `srt` or `vtt`.
|
|
164
152
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
165
153
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
@@ -175,11 +163,11 @@ class AudioSubtitleLoader extends CreateTranscriptLoader {
|
|
|
175
163
|
this.subtitleFormat = subtitleFormat;
|
|
176
164
|
}
|
|
177
165
|
/**
|
|
178
|
-
*
|
|
166
|
+
* Transcribe audio and load subtitles for the transcript as `srt` or `vtt` format.
|
|
179
167
|
* @returns A promise that resolves a document containing the subtitles as the page content.
|
|
180
168
|
*/
|
|
181
169
|
async load() {
|
|
182
|
-
const transcript = await this.
|
|
170
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
183
171
|
const subtitles = await this.client.transcripts.subtitles(transcript.id, this.subtitleFormat);
|
|
184
172
|
return [
|
|
185
173
|
new document_js_1.Document({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssemblyAI,
|
|
1
|
+
import { AssemblyAI, TranscribeParams, SubtitleFormat, Transcript, TranscriptParagraph, TranscriptSentence, CreateTranscriptParameters } from "assemblyai";
|
|
2
2
|
import { Document } from "../../document.js";
|
|
3
3
|
import { BaseDocumentLoader } from "../base.js";
|
|
4
4
|
import { AssemblyAIOptions } from "../../types/assemblyai-types.js";
|
|
@@ -9,95 +9,70 @@ export type * from "../../types/assemblyai-types.js";
|
|
|
9
9
|
declare abstract class AssemblyAILoader extends BaseDocumentLoader {
|
|
10
10
|
protected client: AssemblyAI;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Create a new AssemblyAI loader.
|
|
13
13
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
14
14
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
15
15
|
*/
|
|
16
16
|
constructor(assemblyAIOptions?: AssemblyAIOptions);
|
|
17
17
|
}
|
|
18
18
|
declare abstract class CreateTranscriptLoader extends AssemblyAILoader {
|
|
19
|
-
protected
|
|
19
|
+
protected transcribeParams?: TranscribeParams | CreateTranscriptParameters;
|
|
20
20
|
protected transcriptId?: string;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param params The parameters to
|
|
22
|
+
* Transcribe audio or retrieve an existing transcript by its ID.
|
|
23
|
+
* @param params The parameters to transcribe audio, or the ID of the transcript to retrieve.
|
|
24
24
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
25
25
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
26
26
|
*/
|
|
27
|
-
constructor(params: CreateTranscriptParameters | string, assemblyAIOptions?: AssemblyAIOptions);
|
|
28
|
-
protected
|
|
27
|
+
constructor(params: TranscribeParams | CreateTranscriptParameters | string, assemblyAIOptions?: AssemblyAIOptions);
|
|
28
|
+
protected transcribeOrGetTranscript(): Promise<Transcript>;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* const loader = new AudioTranscriptLoader(
|
|
35
|
-
* { audio_url: "https:
|
|
36
|
-
* { apiKey: "ASSEMBLYAI_API_KEY" },
|
|
37
|
-
* );
|
|
38
|
-
* const docs = await loader.load();
|
|
39
|
-
* console.dir(docs, { depth: Infinity });
|
|
40
|
-
* ```
|
|
31
|
+
* Transcribe audio and load the transcript as a document using AssemblyAI.
|
|
41
32
|
*/
|
|
42
33
|
export declare class AudioTranscriptLoader extends CreateTranscriptLoader {
|
|
43
34
|
/**
|
|
44
|
-
*
|
|
35
|
+
* Transcribe audio and load the transcript as a document using AssemblyAI.
|
|
45
36
|
* @returns A promise that resolves to a single document containing the transcript text
|
|
46
37
|
* as the page content, and the transcript object as the metadata.
|
|
47
38
|
*/
|
|
48
39
|
load(): Promise<Document<Transcript>[]>;
|
|
49
40
|
}
|
|
50
41
|
/**
|
|
51
|
-
*
|
|
42
|
+
* Transcribe audio and load the paragraphs of the transcript, creating a document for each paragraph.
|
|
52
43
|
*/
|
|
53
44
|
export declare class AudioTranscriptParagraphsLoader extends CreateTranscriptLoader {
|
|
54
45
|
/**
|
|
55
|
-
*
|
|
46
|
+
* Transcribe audio and load the paragraphs of the transcript, creating a document for each paragraph.
|
|
56
47
|
* @returns A promise that resolves to an array of documents, each containing a paragraph of the transcript.
|
|
57
48
|
*/
|
|
58
49
|
load(): Promise<Document<TranscriptParagraph>[]>;
|
|
59
50
|
}
|
|
60
51
|
/**
|
|
61
|
-
*
|
|
62
|
-
* and loads the sentences of the transcript, creating a document for each sentence.
|
|
52
|
+
* Transcribe audio and load the sentences of the transcript, creating a document for each sentence.
|
|
63
53
|
*/
|
|
64
54
|
export declare class AudioTranscriptSentencesLoader extends CreateTranscriptLoader {
|
|
65
55
|
/**
|
|
66
|
-
*
|
|
56
|
+
* Transcribe audio and load the sentences of the transcript, creating a document for each sentence.
|
|
67
57
|
* @returns A promise that resolves to an array of documents, each containing a sentence of the transcript.
|
|
68
58
|
*/
|
|
69
59
|
load(): Promise<Document<TranscriptSentence>[]>;
|
|
70
60
|
}
|
|
71
61
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const loader = new AudioSubtitleLoader(
|
|
76
|
-
* {
|
|
77
|
-
* audio_url: "https:
|
|
78
|
-
* },
|
|
79
|
-
* "srt",
|
|
80
|
-
* {
|
|
81
|
-
* apiKey: "<ASSEMBLYAI_API_KEY>",
|
|
82
|
-
* },
|
|
83
|
-
* );
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* const docs = await loader.load();
|
|
87
|
-
* ```
|
|
62
|
+
* Transcribe audio and load subtitles for the transcript as `srt` or `vtt` format.
|
|
88
63
|
*/
|
|
89
64
|
export declare class AudioSubtitleLoader extends CreateTranscriptLoader {
|
|
90
65
|
private subtitleFormat;
|
|
91
66
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @param
|
|
67
|
+
* Create a new AudioSubtitleLoader.
|
|
68
|
+
* @param transcribeParams The parameters to transcribe audio.
|
|
94
69
|
* @param subtitleFormat The format of the subtitles, either `srt` or `vtt`.
|
|
95
70
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
96
71
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
97
72
|
*/
|
|
98
|
-
constructor(
|
|
73
|
+
constructor(transcribeParams: TranscribeParams | CreateTranscriptParameters, subtitleFormat: SubtitleFormat, assemblyAIOptions?: AssemblyAIOptions);
|
|
99
74
|
/**
|
|
100
|
-
*
|
|
75
|
+
* Create a new AudioSubtitleLoader.
|
|
101
76
|
* @param transcriptId The ID of the transcript to retrieve.
|
|
102
77
|
* @param subtitleFormat The format of the subtitles, either `srt` or `vtt`.
|
|
103
78
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
@@ -105,7 +80,7 @@ export declare class AudioSubtitleLoader extends CreateTranscriptLoader {
|
|
|
105
80
|
*/
|
|
106
81
|
constructor(transcriptId: string, subtitleFormat: SubtitleFormat, assemblyAIOptions?: AssemblyAIOptions);
|
|
107
82
|
/**
|
|
108
|
-
*
|
|
83
|
+
* Transcribe audio and load subtitles for the transcript as `srt` or `vtt` format.
|
|
109
84
|
* @returns A promise that resolves a document containing the subtitles as the page content.
|
|
110
85
|
*/
|
|
111
86
|
load(): Promise<Document[]>;
|
|
@@ -7,7 +7,7 @@ import { getEnvironmentVariable } from "../../util/env.js";
|
|
|
7
7
|
*/
|
|
8
8
|
class AssemblyAILoader extends BaseDocumentLoader {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Create a new AssemblyAI loader.
|
|
11
11
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
12
12
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
13
13
|
*/
|
|
@@ -34,14 +34,14 @@ class AssemblyAILoader extends BaseDocumentLoader {
|
|
|
34
34
|
}
|
|
35
35
|
class CreateTranscriptLoader extends AssemblyAILoader {
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @param params The parameters to
|
|
37
|
+
* Transcribe audio or retrieve an existing transcript by its ID.
|
|
38
|
+
* @param params The parameters to transcribe audio, or the ID of the transcript to retrieve.
|
|
39
39
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
40
40
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
41
41
|
*/
|
|
42
42
|
constructor(params, assemblyAIOptions) {
|
|
43
43
|
super(assemblyAIOptions);
|
|
44
|
-
Object.defineProperty(this, "
|
|
44
|
+
Object.defineProperty(this, "transcribeParams", {
|
|
45
45
|
enumerable: true,
|
|
46
46
|
configurable: true,
|
|
47
47
|
writable: true,
|
|
@@ -57,38 +57,42 @@ class CreateTranscriptLoader extends AssemblyAILoader {
|
|
|
57
57
|
this.transcriptId = params;
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
|
-
this.
|
|
60
|
+
this.transcribeParams = params;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
async
|
|
63
|
+
async transcribeOrGetTranscript() {
|
|
64
64
|
if (this.transcriptId) {
|
|
65
65
|
return await this.client.transcripts.get(this.transcriptId);
|
|
66
66
|
}
|
|
67
|
-
if (this.
|
|
68
|
-
|
|
67
|
+
if (this.transcribeParams) {
|
|
68
|
+
let transcribeParams;
|
|
69
|
+
if ("audio_url" in this.transcribeParams) {
|
|
70
|
+
transcribeParams = {
|
|
71
|
+
...this.transcribeParams,
|
|
72
|
+
audio: this.transcribeParams.audio_url,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
transcribeParams = this.transcribeParams;
|
|
77
|
+
}
|
|
78
|
+
return await this.client.transcripts.transcribe(transcribeParams);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error("No transcript ID or transcribe parameters provided");
|
|
69
82
|
}
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
85
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const loader = new AudioTranscriptLoader(
|
|
77
|
-
* { audio_url: "https:
|
|
78
|
-
* { apiKey: "ASSEMBLYAI_API_KEY" },
|
|
79
|
-
* );
|
|
80
|
-
* const docs = await loader.load();
|
|
81
|
-
* console.dir(docs, { depth: Infinity });
|
|
82
|
-
* ```
|
|
86
|
+
* Transcribe audio and load the transcript as a document using AssemblyAI.
|
|
83
87
|
*/
|
|
84
88
|
export class AudioTranscriptLoader extends CreateTranscriptLoader {
|
|
85
89
|
/**
|
|
86
|
-
*
|
|
90
|
+
* Transcribe audio and load the transcript as a document using AssemblyAI.
|
|
87
91
|
* @returns A promise that resolves to a single document containing the transcript text
|
|
88
92
|
* as the page content, and the transcript object as the metadata.
|
|
89
93
|
*/
|
|
90
94
|
async load() {
|
|
91
|
-
const transcript = await this.
|
|
95
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
92
96
|
return [
|
|
93
97
|
new Document({
|
|
94
98
|
pageContent: transcript.text,
|
|
@@ -98,15 +102,15 @@ export class AudioTranscriptLoader extends CreateTranscriptLoader {
|
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
/**
|
|
101
|
-
*
|
|
105
|
+
* Transcribe audio and load the paragraphs of the transcript, creating a document for each paragraph.
|
|
102
106
|
*/
|
|
103
107
|
export class AudioTranscriptParagraphsLoader extends CreateTranscriptLoader {
|
|
104
108
|
/**
|
|
105
|
-
*
|
|
109
|
+
* Transcribe audio and load the paragraphs of the transcript, creating a document for each paragraph.
|
|
106
110
|
* @returns A promise that resolves to an array of documents, each containing a paragraph of the transcript.
|
|
107
111
|
*/
|
|
108
112
|
async load() {
|
|
109
|
-
const transcript = await this.
|
|
113
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
110
114
|
const paragraphsResponse = await this.client.transcripts.paragraphs(transcript.id);
|
|
111
115
|
return paragraphsResponse.paragraphs.map((p) => new Document({
|
|
112
116
|
pageContent: p.text,
|
|
@@ -115,16 +119,15 @@ export class AudioTranscriptParagraphsLoader extends CreateTranscriptLoader {
|
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
/**
|
|
118
|
-
*
|
|
119
|
-
* and loads the sentences of the transcript, creating a document for each sentence.
|
|
122
|
+
* Transcribe audio and load the sentences of the transcript, creating a document for each sentence.
|
|
120
123
|
*/
|
|
121
124
|
export class AudioTranscriptSentencesLoader extends CreateTranscriptLoader {
|
|
122
125
|
/**
|
|
123
|
-
*
|
|
126
|
+
* Transcribe audio and load the sentences of the transcript, creating a document for each sentence.
|
|
124
127
|
* @returns A promise that resolves to an array of documents, each containing a sentence of the transcript.
|
|
125
128
|
*/
|
|
126
129
|
async load() {
|
|
127
|
-
const transcript = await this.
|
|
130
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
128
131
|
const sentencesResponse = await this.client.transcripts.sentences(transcript.id);
|
|
129
132
|
return sentencesResponse.sentences.map((p) => new Document({
|
|
130
133
|
pageContent: p.text,
|
|
@@ -133,27 +136,12 @@ export class AudioTranscriptSentencesLoader extends CreateTranscriptLoader {
|
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
/**
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* const loader = new AudioSubtitleLoader(
|
|
140
|
-
* {
|
|
141
|
-
* audio_url: "https:
|
|
142
|
-
* },
|
|
143
|
-
* "srt",
|
|
144
|
-
* {
|
|
145
|
-
* apiKey: "<ASSEMBLYAI_API_KEY>",
|
|
146
|
-
* },
|
|
147
|
-
* );
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* const docs = await loader.load();
|
|
151
|
-
* ```
|
|
139
|
+
* Transcribe audio and load subtitles for the transcript as `srt` or `vtt` format.
|
|
152
140
|
*/
|
|
153
141
|
export class AudioSubtitleLoader extends CreateTranscriptLoader {
|
|
154
142
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param params The parameters to
|
|
143
|
+
* Create a new AudioSubtitleLoader.
|
|
144
|
+
* @param params The parameters to transcribe audio, or the ID of the transcript to retrieve.
|
|
157
145
|
* @param subtitleFormat The format of the subtitles, either `srt` or `vtt`.
|
|
158
146
|
* @param assemblyAIOptions The options to configure the AssemblyAI loader.
|
|
159
147
|
* Configure the `assemblyAIOptions.apiKey` with your AssemblyAI API key, or configure it as the `ASSEMBLYAI_API_KEY` environment variable.
|
|
@@ -169,11 +157,11 @@ export class AudioSubtitleLoader extends CreateTranscriptLoader {
|
|
|
169
157
|
this.subtitleFormat = subtitleFormat;
|
|
170
158
|
}
|
|
171
159
|
/**
|
|
172
|
-
*
|
|
160
|
+
* Transcribe audio and load subtitles for the transcript as `srt` or `vtt` format.
|
|
173
161
|
* @returns A promise that resolves a document containing the subtitles as the page content.
|
|
174
162
|
*/
|
|
175
163
|
async load() {
|
|
176
|
-
const transcript = await this.
|
|
164
|
+
const transcript = await this.transcribeOrGetTranscript();
|
|
177
165
|
const subtitles = await this.client.transcripts.subtitles(transcript.id, this.subtitleFormat);
|
|
178
166
|
return [
|
|
179
167
|
new Document({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.207",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -859,7 +859,8 @@
|
|
|
859
859
|
"url": "git@github.com:langchain-ai/langchainjs.git"
|
|
860
860
|
},
|
|
861
861
|
"scripts": {
|
|
862
|
-
"build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
|
|
862
|
+
"build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
|
|
863
|
+
"build:deps": "yarn run turbo:command build --filter=@langchain/core --filter=@langchain/anthropic --filter=@langchain/openai --filter=@langchain/community --concurrency=1",
|
|
863
864
|
"build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests",
|
|
864
865
|
"build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rimraf dist-cjs",
|
|
865
866
|
"build:watch": "node scripts/create-entrypoints.js && tsc --outDir dist/ --watch",
|
|
@@ -872,10 +873,10 @@
|
|
|
872
873
|
"clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
|
|
873
874
|
"prepack": "yarn build",
|
|
874
875
|
"release": "release-it --only-version --config .release-it.json",
|
|
875
|
-
"test": "
|
|
876
|
-
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
877
|
-
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
|
|
878
|
-
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
|
|
876
|
+
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
|
|
877
|
+
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
878
|
+
"test:integration": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
|
|
879
|
+
"test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
|
|
879
880
|
"format": "prettier --write \"src\"",
|
|
880
881
|
"format:check": "prettier --check \"src\""
|
|
881
882
|
},
|
|
@@ -914,7 +915,7 @@
|
|
|
914
915
|
"@vercel/kv": "^0.2.3",
|
|
915
916
|
"@xata.io/client": "^0.28.0",
|
|
916
917
|
"apify-client": "^2.7.1",
|
|
917
|
-
"assemblyai": "^
|
|
918
|
+
"assemblyai": "^4.0.0",
|
|
918
919
|
"axios": "^0.26.0",
|
|
919
920
|
"cheerio": "^1.0.0-rc.12",
|
|
920
921
|
"chromadb": "^1.5.3",
|
|
@@ -982,7 +983,7 @@
|
|
|
982
983
|
"@vercel/kv": "^0.2.3",
|
|
983
984
|
"@xata.io/client": "^0.28.0",
|
|
984
985
|
"apify-client": "^2.7.1",
|
|
985
|
-
"assemblyai": "^
|
|
986
|
+
"assemblyai": "^4.0.0",
|
|
986
987
|
"axios": "*",
|
|
987
988
|
"cheerio": "^1.0.0-rc.12",
|
|
988
989
|
"chromadb": "*",
|
|
@@ -1174,8 +1175,8 @@
|
|
|
1174
1175
|
},
|
|
1175
1176
|
"dependencies": {
|
|
1176
1177
|
"@anthropic-ai/sdk": "^0.9.1",
|
|
1177
|
-
"@langchain/community": "~0.0.
|
|
1178
|
-
"@langchain/core": "~0.1.
|
|
1178
|
+
"@langchain/community": "~0.0.5",
|
|
1179
|
+
"@langchain/core": "~0.1.1",
|
|
1179
1180
|
"@langchain/openai": "~0.0.5",
|
|
1180
1181
|
"binary-extensions": "^2.2.0",
|
|
1181
1182
|
"expr-eval": "^2.0.2",
|