vidnavigator 2.6.0 → 3.0.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/README.md +105 -111
- package/dist/index.d.ts +19 -109
- package/dist/index.js +16 -54
- package/dist/models/AsyncJob.d.ts +7 -3
- package/dist/models/AsyncJob.js +1 -0
- package/dist/models/Extraction.d.ts +14 -0
- package/dist/models/SearchResult.d.ts +5 -1
- package/dist/models/TweetStatement.d.ts +10 -0
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -1
- package/dist/webhooks.d.ts +8 -2
- package/package.json +1 -1
- package/src/index.ts +32 -172
- package/src/models/AsyncJob.ts +8 -3
- package/src/models/Extraction.ts +16 -0
- package/src/models/SearchResult.ts +6 -1
- package/src/models/TweetStatement.ts +10 -0
- package/src/models/index.ts +0 -1
- package/src/webhooks.ts +3 -3
- package/src/models/AnalysisResult.ts +0 -51
package/src/index.ts
CHANGED
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
transcriptFromJSON,
|
|
10
10
|
FileInfo,
|
|
11
11
|
FileInfoJSON,
|
|
12
|
-
AnalysisResult,
|
|
13
|
-
AnalysisResultJSON,
|
|
14
12
|
VideoSearchResult,
|
|
15
13
|
VideoSearchResultJSON,
|
|
16
14
|
FileSearchResult,
|
|
@@ -21,6 +19,7 @@ import {
|
|
|
21
19
|
NamespaceJSON,
|
|
22
20
|
NamespaceRef,
|
|
23
21
|
NamespaceRefJSON,
|
|
22
|
+
ExtractionEvidence,
|
|
24
23
|
ExtractionSchema,
|
|
25
24
|
UsageBlock,
|
|
26
25
|
UsageBlockJSON,
|
|
@@ -72,7 +71,7 @@ export { Job } from './jobs';
|
|
|
72
71
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
73
72
|
|
|
74
73
|
/** SDK version (keep in sync with package.json) */
|
|
75
|
-
export const SDK_VERSION = '
|
|
74
|
+
export const SDK_VERSION = '3.0.0';
|
|
76
75
|
|
|
77
76
|
/**
|
|
78
77
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
@@ -145,20 +144,6 @@ export type WatchInput = {
|
|
|
145
144
|
/** Payload of {@link VidNavigatorClient.watchVideo}: a {@link WatchInput} with `include_usage`. */
|
|
146
145
|
export type WatchVideoPayload = WatchInput & { include_usage?: boolean };
|
|
147
146
|
|
|
148
|
-
/** Input for {@link VidNavigatorClient.analyze}. A plain string is treated as `video_url`. */
|
|
149
|
-
export type AnalyzeVideoInput = {
|
|
150
|
-
video_url: string;
|
|
151
|
-
/** Optional question about the video. */
|
|
152
|
-
query?: string;
|
|
153
|
-
/**
|
|
154
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
155
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
156
|
-
*/
|
|
157
|
-
include_scenes?: boolean;
|
|
158
|
-
/** Return the transcript as a single string instead of segments. */
|
|
159
|
-
transcript_text?: boolean;
|
|
160
|
-
} & WebhookOption;
|
|
161
|
-
|
|
162
147
|
/**
|
|
163
148
|
* Input for {@link VidNavigatorClient.extractVideo}: a JSON Schema `schema`, or a JSON/YAML
|
|
164
149
|
* `schemaFilePath`, or neither with `what_to_extract`: the schema is then written from that text
|
|
@@ -189,7 +174,15 @@ export type ExtractVideoInput =
|
|
|
189
174
|
} & WebhookOption);
|
|
190
175
|
|
|
191
176
|
/** Input for {@link VidNavigatorClient.tweetStatement}. A plain string is treated as `tweet_id`. */
|
|
192
|
-
export type TweetStatementInput = {
|
|
177
|
+
export type TweetStatementInput = {
|
|
178
|
+
tweet_id: string;
|
|
179
|
+
/**
|
|
180
|
+
* Default false. `true` also reads what the post's video and the quoted post's video show (their
|
|
181
|
+
* scenes, with the text readable on screen) and uses it with their transcripts. The result then
|
|
182
|
+
* has `frames_analyzed`, and `scenes_error` when a video's picture could not be read.
|
|
183
|
+
*/
|
|
184
|
+
include_scenes?: boolean;
|
|
185
|
+
} & WebhookOption;
|
|
193
186
|
|
|
194
187
|
export type TranscriptResult = {
|
|
195
188
|
video_info: VideoInfo;
|
|
@@ -217,9 +210,6 @@ export type TranscribeAsyncJob = AsyncJob<TranscribeVideoResult>;
|
|
|
217
210
|
/** Snapshot of a watch task. `result` is a {@link WatchResult}. */
|
|
218
211
|
export type WatchAsyncJob = AsyncJob<WatchResult>;
|
|
219
212
|
|
|
220
|
-
/** Snapshot of a video analysis task. `result` has the same shape as {@link VidNavigatorClient.analyzeVideo}'s return value. */
|
|
221
|
-
export type AnalyzeVideoAsyncJob = AsyncJob<AnalyzeVideoResult>;
|
|
222
|
-
|
|
223
213
|
/** Snapshot of an extraction task. `result` is the extracted object, shaped like your schema. */
|
|
224
214
|
export type ExtractVideoAsyncJob = AsyncJob<Record<string, unknown>>;
|
|
225
215
|
|
|
@@ -242,7 +232,6 @@ export interface TranscribeOperation extends JobOperation<string | TranscribeInp
|
|
|
242
232
|
submit(input: string | TranscribeInput, options?: SubmitOptions): Promise<Job<TranscribeAsyncJob, TranscribeVideoResult>>;
|
|
243
233
|
}
|
|
244
234
|
export type WatchJob = Job<WatchAsyncJob, WatchResult>;
|
|
245
|
-
export type AnalyzeVideoJob = Job<AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
246
235
|
export type ExtractVideoJob = Job<ExtractVideoAsyncJob, ExtractDataResult>;
|
|
247
236
|
export type TweetStatementJob = Job<TweetStatementAsyncJob, TweetStatement>;
|
|
248
237
|
/** `result()` resolves to the completed task with **all** pages of `videos` collected. */
|
|
@@ -294,6 +283,8 @@ export interface ExtractDataResult {
|
|
|
294
283
|
data: Record<string, unknown>;
|
|
295
284
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
296
285
|
schema?: ExtractionSchema;
|
|
286
|
+
/** For each field of `data` that has a value, the moments of the video it comes from. */
|
|
287
|
+
evidence?: ExtractionEvidence;
|
|
297
288
|
video_info?: VideoInfo;
|
|
298
289
|
file_info?: FileInfo;
|
|
299
290
|
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
@@ -353,65 +344,6 @@ export type SearchFilesResult = {
|
|
|
353
344
|
usage?: UsageBlock;
|
|
354
345
|
};
|
|
355
346
|
|
|
356
|
-
export type AnalyzeVideoPayload = {
|
|
357
|
-
video_url: string;
|
|
358
|
-
query?: string;
|
|
359
|
-
/**
|
|
360
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
361
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
362
|
-
*/
|
|
363
|
-
include_scenes?: boolean;
|
|
364
|
-
transcript_text?: boolean;
|
|
365
|
-
include_usage?: boolean;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
export type AnalyzeFilePayload = {
|
|
369
|
-
file_id: string;
|
|
370
|
-
query?: string;
|
|
371
|
-
/**
|
|
372
|
-
* Default false. `true` analyzes the file from its transcript and its scenes together. The
|
|
373
|
-
* scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or with
|
|
374
|
-
* {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
375
|
-
* `ScenesNotAvailableError`.
|
|
376
|
-
*/
|
|
377
|
-
include_scenes?: boolean;
|
|
378
|
-
transcript_text?: boolean;
|
|
379
|
-
include_usage?: boolean;
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
export type AnalyzeVideoResult = {
|
|
383
|
-
video_info: VideoInfo;
|
|
384
|
-
transcript: TranscriptOutput;
|
|
385
|
-
transcript_analysis: AnalysisResult;
|
|
386
|
-
/**
|
|
387
|
-
* With `include_scenes: true`: what the video shows, in chronological order. Empty when the
|
|
388
|
-
* picture could not be read (see `scenes_error`).
|
|
389
|
-
*/
|
|
390
|
-
scenes?: VideoScene[];
|
|
391
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
392
|
-
frames_analyzed?: number;
|
|
393
|
-
/** With `include_scenes: true`, when the picture could not be read: the analysis was made from the transcript alone. */
|
|
394
|
-
scenes_error?: ScenesError;
|
|
395
|
-
/** With `include_scenes: true`, when there is no transcript: the analysis was made from the scenes alone. */
|
|
396
|
-
transcript_error?: WatchTranscriptError;
|
|
397
|
-
usage?: UsageBlock;
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
export type AnalyzeFileResult = {
|
|
401
|
-
file_info: FileInfo;
|
|
402
|
-
transcript: TranscriptOutput;
|
|
403
|
-
transcript_analysis: AnalysisResult;
|
|
404
|
-
/** With `include_scenes: true`: what the file shows, in chronological order. */
|
|
405
|
-
scenes?: VideoScene[];
|
|
406
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
407
|
-
frames_analyzed?: number;
|
|
408
|
-
/** Why the scenes could not be read, when the answer carries it. A file that has no scenes at all is refused with `ScenesNotAvailableError` instead. */
|
|
409
|
-
scenes_error?: ScenesError;
|
|
410
|
-
/** With `include_scenes: true`, when the file has no speech: the analysis was made from the scenes alone. */
|
|
411
|
-
transcript_error?: WatchTranscriptError;
|
|
412
|
-
usage?: UsageBlock;
|
|
413
|
-
};
|
|
414
|
-
|
|
415
347
|
export type ExtractVideoDataPayload = {
|
|
416
348
|
video_url: string;
|
|
417
349
|
/** A standard JSON Schema. Optional when `what_to_extract` is given. */
|
|
@@ -436,7 +368,8 @@ export type ExtractVideoDataMultipartPayload = {
|
|
|
436
368
|
include_usage?: boolean;
|
|
437
369
|
} & WebhookOption;
|
|
438
370
|
|
|
439
|
-
|
|
371
|
+
/** Payload of {@link VidNavigatorClient.getTweetStatement}: the same fields as {@link TweetStatementInput}. */
|
|
372
|
+
export type TweetStatementPayload = TweetStatementInput;
|
|
440
373
|
|
|
441
374
|
export type ExtractFileDataPayload = {
|
|
442
375
|
file_id: string;
|
|
@@ -504,13 +437,6 @@ interface SceneNotes {
|
|
|
504
437
|
transcript_error?: WatchTranscriptError;
|
|
505
438
|
}
|
|
506
439
|
|
|
507
|
-
/** The `data` block of an analysis: the same for a video, its background job and an uploaded file. */
|
|
508
|
-
interface AnalysisDataJSON extends SceneNotes {
|
|
509
|
-
transcript: TranscriptSegmentJSON[] | string;
|
|
510
|
-
transcript_analysis: AnalysisResultJSON;
|
|
511
|
-
scenes?: VideoSceneJSON[];
|
|
512
|
-
}
|
|
513
|
-
|
|
514
440
|
// The scene fields are set only when the response carries them, so a result asked without
|
|
515
441
|
// `include_scenes` keeps the shape it always had.
|
|
516
442
|
function pickSceneNotes(raw: SceneNotes): SceneNotes {
|
|
@@ -525,20 +451,11 @@ function parseScenes(raw: VideoSceneJSON[] | undefined): { scenes?: VideoScene[]
|
|
|
525
451
|
return raw ? { scenes: raw.map((scene) => VideoScene.fromJSON(scene)) } : {};
|
|
526
452
|
}
|
|
527
453
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
...pickSceneNotes(raw),
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function parseAnalyzeVideoData(
|
|
538
|
-
raw: AnalysisDataJSON & { video_info: VideoInfoJSON },
|
|
539
|
-
usage?: UsageBlock
|
|
540
|
-
): AnalyzeVideoResult {
|
|
541
|
-
return { video_info: VideoInfo.fromJSON(raw.video_info), ...parseAnalysisData(raw), usage };
|
|
454
|
+
/** The body of a tweet analysis. `include_scenes` is sent only when true: left out, the API default (false) applies. */
|
|
455
|
+
function tweetStatementBody(input: string | TweetStatementInput): Record<string, unknown> {
|
|
456
|
+
if (typeof input === 'string') return { tweet_id: input };
|
|
457
|
+
const { include_scenes, ...rest } = input;
|
|
458
|
+
return include_scenes === true ? { ...rest, include_scenes: true } : rest;
|
|
542
459
|
}
|
|
543
460
|
|
|
544
461
|
function buildAsyncJobParams(options?: SubmitOptions): Record<string, string> | undefined {
|
|
@@ -642,14 +559,6 @@ export class VidNavigatorClient {
|
|
|
642
559
|
*/
|
|
643
560
|
readonly watch: JobOperation<string | WatchInput, WatchAsyncJob, WatchResult>;
|
|
644
561
|
|
|
645
|
-
/**
|
|
646
|
-
* Analysis of an online video as a background job, built on `POST /analyze/video/async`: the
|
|
647
|
-
* same analysis and the same result as {@link VidNavigatorClient.analyzeVideo}, without holding
|
|
648
|
-
* a connection open while it runs. Use it with `include_scenes: true` on a video longer than
|
|
649
|
-
* about 10 minutes. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
650
|
-
*/
|
|
651
|
-
readonly analyze: JobOperation<string | AnalyzeVideoInput, AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
652
|
-
|
|
653
562
|
/**
|
|
654
563
|
* Structured-data extraction from a video of any length, built on `POST /extract/video/async`.
|
|
655
564
|
* The schema is validated when you submit. With `include_scenes: true` the fields are extracted
|
|
@@ -660,7 +569,8 @@ export class VidNavigatorClient {
|
|
|
660
569
|
|
|
661
570
|
/**
|
|
662
571
|
* Structured claim analysis of an X/Twitter tweet (attached media of any length), built on
|
|
663
|
-
* `POST /tweet/statement/async`.
|
|
572
|
+
* `POST /tweet/statement/async`. With `include_scenes: true`, what the post's video and the quoted
|
|
573
|
+
* post's video show is read as well. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
664
574
|
*/
|
|
665
575
|
readonly tweetStatement: JobOperation<string | TweetStatementInput, TweetStatementAsyncJob, TweetStatement>;
|
|
666
576
|
|
|
@@ -721,17 +631,6 @@ export class VidNavigatorClient {
|
|
|
721
631
|
},
|
|
722
632
|
});
|
|
723
633
|
|
|
724
|
-
this.analyze = this.defineOperation({
|
|
725
|
-
jobType: 'analyze_video',
|
|
726
|
-
submit: (input: string | AnalyzeVideoInput) =>
|
|
727
|
-
this.submitAsyncJob('/analyze/video/async', typeof input === 'string' ? { video_url: input } : input),
|
|
728
|
-
fetchTask: (task_id, options) =>
|
|
729
|
-
this.getAsyncJob(`/analyze/video/${encodeURIComponent(task_id)}`, options, (raw) =>
|
|
730
|
-
parseAnalyzeVideoData(raw)
|
|
731
|
-
),
|
|
732
|
-
toResult: async (task) => ({ ...requireResult(task), usage: task.usage }),
|
|
733
|
-
});
|
|
734
|
-
|
|
735
634
|
this.extractVideo = this.defineOperation({
|
|
736
635
|
jobType: 'extract_video',
|
|
737
636
|
submit: (input: ExtractVideoInput) => this.submitExtractVideo(input),
|
|
@@ -746,6 +645,7 @@ export class VidNavigatorClient {
|
|
|
746
645
|
video_info: task.video_info,
|
|
747
646
|
...pickSceneNotes(task),
|
|
748
647
|
...(task.schema ? { schema: task.schema } : {}),
|
|
648
|
+
...(task.evidence ? { evidence: task.evidence } : {}),
|
|
749
649
|
usage: task.usage,
|
|
750
650
|
}),
|
|
751
651
|
});
|
|
@@ -753,7 +653,7 @@ export class VidNavigatorClient {
|
|
|
753
653
|
this.tweetStatement = this.defineOperation({
|
|
754
654
|
jobType: 'tweet_statement',
|
|
755
655
|
submit: (input: string | TweetStatementInput) =>
|
|
756
|
-
this.submitAsyncJob('/tweet/statement/async',
|
|
656
|
+
this.submitAsyncJob('/tweet/statement/async', tweetStatementBody(input)),
|
|
757
657
|
fetchTask: (task_id, options) =>
|
|
758
658
|
this.getAsyncJob(`/tweet/statement/${encodeURIComponent(task_id)}`, options, (raw) =>
|
|
759
659
|
TweetStatement.fromJSON(raw)
|
|
@@ -1225,7 +1125,7 @@ export class VidNavigatorClient {
|
|
|
1225
1125
|
* The answer has `scenes_status` `processing` when the analysis was started or is already
|
|
1226
1126
|
* running, and `completed` when the scenes are already there (nothing new is started). Follow
|
|
1227
1127
|
* `file_info.scenes_status` with {@link VidNavigatorClient.getFile}, which returns the scenes
|
|
1228
|
-
* once it is `completed`; `
|
|
1128
|
+
* once it is `completed`; `extractFileData` reads them with `include_scenes: true`.
|
|
1229
1129
|
*
|
|
1230
1130
|
* An audio file has no picture: the call throws `BadRequestError` with `error_code`
|
|
1231
1131
|
* `frames_not_available`.
|
|
@@ -1293,53 +1193,12 @@ export class VidNavigatorClient {
|
|
|
1293
1193
|
}
|
|
1294
1194
|
//endregion
|
|
1295
1195
|
|
|
1296
|
-
//region ---
|
|
1297
|
-
/**
|
|
1298
|
-
* Analyze an online video: a summary, the people, places and key subjects, and the answer to
|
|
1299
|
-
* an optional `query`. With `include_scenes: true` the analysis is made from the transcript and
|
|
1300
|
-
* from what the video shows, and the result also has `scenes` and `frames_analyzed`, as
|
|
1301
|
-
* {@link VidNavigatorClient.watch} returns them. When the picture cannot be read, the analysis
|
|
1302
|
-
* is made from the transcript alone and `scenes_error` says why; a video without a transcript
|
|
1303
|
-
* is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
|
|
1304
|
-
*
|
|
1305
|
-
* This call waits on one HTTP request. With `include_scenes` on a video longer than about
|
|
1306
|
-
* 10 minutes, use {@link VidNavigatorClient.analyze}, which runs the same analysis as a
|
|
1307
|
-
* background job.
|
|
1308
|
-
*/
|
|
1309
|
-
async analyzeVideo(payload: AnalyzeVideoPayload): Promise<AnalyzeVideoResult> {
|
|
1310
|
-
const response = await this.request<ApiSuccessResponse<AnalysisDataJSON & { video_info: VideoInfoJSON }>>(
|
|
1311
|
-
'POST',
|
|
1312
|
-
'/analyze/video',
|
|
1313
|
-
payload
|
|
1314
|
-
);
|
|
1315
|
-
|
|
1316
|
-
return parseAnalyzeVideoData(response.data, response.usage ? UsageBlock.fromJSON(response.usage) : undefined);
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
/**
|
|
1320
|
-
* Analyze an uploaded file. With `include_scenes: true` the analysis is made from the transcript
|
|
1321
|
-
* of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`.
|
|
1322
|
-
* The scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or
|
|
1323
|
-
* with {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
1324
|
-
* `ScenesNotAvailableError` (HTTP 409), whose `scenes_status` says where their analysis stands.
|
|
1325
|
-
*/
|
|
1326
|
-
async analyzeFile(payload: AnalyzeFilePayload): Promise<AnalyzeFileResult> {
|
|
1327
|
-
const response = await this.request<ApiSuccessResponse<AnalysisDataJSON & { file_info: FileInfoJSON }>>(
|
|
1328
|
-
'POST',
|
|
1329
|
-
'/analyze/file',
|
|
1330
|
-
payload
|
|
1331
|
-
);
|
|
1332
|
-
|
|
1333
|
-
return {
|
|
1334
|
-
file_info: FileInfo.fromJSON(response.data.file_info),
|
|
1335
|
-
...parseAnalysisData(response.data),
|
|
1336
|
-
usage: response.usage ? UsageBlock.fromJSON(response.usage) : undefined,
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1196
|
+
//region --- X posts ---
|
|
1340
1197
|
/**
|
|
1341
1198
|
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
1342
1199
|
* {@link VidNavigatorClient.tweetStatement}: submits to `POST /tweet/statement/async` and polls.
|
|
1200
|
+
* With `include_scenes: true`, what the post's video and the quoted post's video show is read
|
|
1201
|
+
* as well, and the result has `frames_analyzed`.
|
|
1343
1202
|
*/
|
|
1344
1203
|
async getTweetStatement(
|
|
1345
1204
|
payload: TweetStatementPayload,
|
|
@@ -1381,6 +1240,7 @@ export class VidNavigatorClient {
|
|
|
1381
1240
|
data: Record<string, unknown>;
|
|
1382
1241
|
file_info?: FileInfoJSON;
|
|
1383
1242
|
schema?: ExtractionSchema;
|
|
1243
|
+
evidence?: ExtractionEvidence;
|
|
1384
1244
|
usage?: UsageBlockJSON;
|
|
1385
1245
|
} & SceneNotes;
|
|
1386
1246
|
let body: ExtractFileBody;
|
|
@@ -1402,6 +1262,7 @@ export class VidNavigatorClient {
|
|
|
1402
1262
|
file_info: body.file_info ? FileInfo.fromJSON(body.file_info) : undefined,
|
|
1403
1263
|
...pickSceneNotes(body),
|
|
1404
1264
|
...(body.schema ? { schema: body.schema } : {}),
|
|
1265
|
+
...(body.evidence ? { evidence: body.evidence } : {}),
|
|
1405
1266
|
usage: body.usage ? UsageBlock.fromJSON(body.usage) : undefined,
|
|
1406
1267
|
};
|
|
1407
1268
|
}
|
|
@@ -1452,9 +1313,8 @@ export class VidNavigatorClient {
|
|
|
1452
1313
|
}
|
|
1453
1314
|
|
|
1454
1315
|
/**
|
|
1455
|
-
* @deprecated
|
|
1456
|
-
*
|
|
1457
|
-
* `searchYouTube` and will be removed in a future release.
|
|
1316
|
+
* @deprecated Use {@link VidNavigatorClient.searchYouTube} instead. This alias forwards to
|
|
1317
|
+
* `searchYouTube` (`POST /youtube/search`) and will be removed in a future release.
|
|
1458
1318
|
*/
|
|
1459
1319
|
async searchVideos(payload: SearchYouTubePayload): Promise<SearchYouTubeResult> {
|
|
1460
1320
|
warnDeprecated('searchVideos', 'searchYouTube');
|
package/src/models/AsyncJob.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtractionSchema } from './Extraction';
|
|
1
|
+
import type { ExtractionEvidence, ExtractionSchema } from './Extraction';
|
|
2
2
|
import { UsageBlock } from './Usage';
|
|
3
3
|
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
4
4
|
import { ScenesError, WatchTranscriptError } from './Watch';
|
|
5
5
|
|
|
6
|
-
/** Async job kinds returned by the `/transcribe/async`, `/watch/async`, `/
|
|
7
|
-
export type AsyncJobType = 'transcribe' | 'watch' | '
|
|
6
|
+
/** Async job kinds returned by the `/transcribe/async`, `/watch/async`, `/extract/video/async` and `/tweet/statement/async` endpoints. */
|
|
7
|
+
export type AsyncJobType = 'transcribe' | 'watch' | 'extract_video' | 'tweet_statement';
|
|
8
8
|
|
|
9
9
|
/** `processing` = accepted and being worked on. `completed` and `failed` are terminal. */
|
|
10
10
|
export type AsyncTaskStatus = 'processing' | 'completed' | 'failed';
|
|
@@ -94,6 +94,8 @@ export interface AsyncJobJSON {
|
|
|
94
94
|
transcript_error?: WatchTranscriptError;
|
|
95
95
|
/** `extract_video` jobs, once completed, when the request had no schema: the schema written from `what_to_extract`. */
|
|
96
96
|
schema?: ExtractionSchema;
|
|
97
|
+
/** `extract_video` jobs, once completed: the moments each value of `result` comes from. */
|
|
98
|
+
evidence?: ExtractionEvidence;
|
|
97
99
|
error?: AsyncJobError | null;
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -126,6 +128,8 @@ export class AsyncJob<TResult> {
|
|
|
126
128
|
transcript_error?: WatchTranscriptError;
|
|
127
129
|
/** `extract_video` jobs, once completed, when the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
128
130
|
schema?: ExtractionSchema;
|
|
131
|
+
/** `extract_video` jobs, once completed: the moments each value of `result` comes from. */
|
|
132
|
+
evidence?: ExtractionEvidence;
|
|
129
133
|
error: AsyncJobError | null;
|
|
130
134
|
/** Per-call usage, populated only when polled with `include_usage: true` and `task_status === 'completed'`. */
|
|
131
135
|
usage?: UsageBlock;
|
|
@@ -147,6 +151,7 @@ export class AsyncJob<TResult> {
|
|
|
147
151
|
this.scenes_error = data.scenes_error;
|
|
148
152
|
this.transcript_error = data.transcript_error;
|
|
149
153
|
this.schema = data.schema;
|
|
154
|
+
this.evidence = data.evidence;
|
|
150
155
|
this.error = data.error ?? null;
|
|
151
156
|
}
|
|
152
157
|
|
package/src/models/Extraction.ts
CHANGED
|
@@ -37,6 +37,20 @@ export interface ExtractionTokenUsageJSON {
|
|
|
37
37
|
total_tokens?: number;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* A moment an extracted value was taken from. `in` is `'speech'` (said in the video), `'picture'`
|
|
42
|
+
* (shown or written on screen) or `'post'` (the post's own text: title, channel, description;
|
|
43
|
+
* no `start`/`end` then).
|
|
44
|
+
*/
|
|
45
|
+
export interface FieldEvidence {
|
|
46
|
+
start?: number;
|
|
47
|
+
end?: number;
|
|
48
|
+
in: 'speech' | 'picture' | 'post';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** For each field of `data` that has a value, the moments of the video it comes from (at most 5). */
|
|
52
|
+
export type ExtractionEvidence = Record<string, FieldEvidence[]>;
|
|
53
|
+
|
|
40
54
|
export interface ExtractionResponseJSON {
|
|
41
55
|
status: 'success';
|
|
42
56
|
data: Record<string, unknown>;
|
|
@@ -48,6 +62,8 @@ export interface ExtractionResponseJSON {
|
|
|
48
62
|
transcript_error?: WatchTranscriptError;
|
|
49
63
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
50
64
|
schema?: ExtractionSchema;
|
|
65
|
+
/** Where each value of `data` comes from. */
|
|
66
|
+
evidence?: ExtractionEvidence;
|
|
51
67
|
usage?: ExtractionTokenUsageJSON;
|
|
52
68
|
}
|
|
53
69
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { NamedEntity } from './AnalysisResult';
|
|
2
1
|
import { FileInfo, FileInfoJSON } from './FileInfo';
|
|
3
2
|
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
4
3
|
|
|
4
|
+
/** A person or a place a search result mentions, with the context it appears in. */
|
|
5
|
+
export interface NamedEntity {
|
|
6
|
+
name?: string;
|
|
7
|
+
context?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
export interface SearchKeySubject {
|
|
6
11
|
name?: string;
|
|
7
12
|
description?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UsageBlock } from './Usage';
|
|
2
|
+
import { ScenesError } from './Watch';
|
|
2
3
|
|
|
3
4
|
export type TweetClaimType =
|
|
4
5
|
| 'factual_claim'
|
|
@@ -58,6 +59,8 @@ export interface TweetStatementJSON {
|
|
|
58
59
|
tweet_media_summary?: string | null;
|
|
59
60
|
quoted_tweet_text?: string | null;
|
|
60
61
|
quoted_media_summary?: string | null;
|
|
62
|
+
frames_analyzed?: number;
|
|
63
|
+
scenes_error?: ScenesError;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
export class TweetStatement {
|
|
@@ -76,6 +79,13 @@ export class TweetStatement {
|
|
|
76
79
|
tweet_media_summary?: string | null;
|
|
77
80
|
quoted_tweet_text?: string | null;
|
|
78
81
|
quoted_media_summary?: string | null;
|
|
82
|
+
/** With `include_scenes: true`: number of frames analyzed to read the scenes of the post's videos. */
|
|
83
|
+
frames_analyzed?: number;
|
|
84
|
+
/**
|
|
85
|
+
* With `include_scenes: true`, when a video's picture could not be read (e.g. `frames_not_available`).
|
|
86
|
+
* The analysis still succeeds: that video is used through its transcript alone, when it has one.
|
|
87
|
+
*/
|
|
88
|
+
scenes_error?: ScenesError;
|
|
79
89
|
/** Per-call usage, populated when requested with include_usage. */
|
|
80
90
|
usage?: UsageBlock;
|
|
81
91
|
|
package/src/models/index.ts
CHANGED
package/src/webhooks.ts
CHANGED
|
@@ -8,8 +8,6 @@ export type WebhookEventType =
|
|
|
8
8
|
| 'transcribe.failed'
|
|
9
9
|
| 'watch.completed'
|
|
10
10
|
| 'watch.failed'
|
|
11
|
-
| 'analyze_video.completed'
|
|
12
|
-
| 'analyze_video.failed'
|
|
13
11
|
| 'extract_video.completed'
|
|
14
12
|
| 'extract_video.failed'
|
|
15
13
|
| 'tweet_statement.completed'
|
|
@@ -42,7 +40,7 @@ export interface WebhookEvent {
|
|
|
42
40
|
job_type?: string;
|
|
43
41
|
check_status_url?: string;
|
|
44
42
|
/**
|
|
45
|
-
* Raw (unparsed) result of the completed job. For transcription, watch,
|
|
43
|
+
* Raw (unparsed) result of the completed job. For transcription, watch, extraction and tweet
|
|
46
44
|
* jobs it is the same data the job's `result()` parses. For TikTok tasks it is a summary only,
|
|
47
45
|
* {@link TikTokWebhookResult} (a scrape can hold thousands of videos); fetch the videos with
|
|
48
46
|
* `vn.tiktokProfile.resume(task_id).result()`. Omitted when `result_truncated` is true.
|
|
@@ -54,6 +52,8 @@ export interface WebhookEvent {
|
|
|
54
52
|
video_info?: Record<string, unknown>;
|
|
55
53
|
/** `extract_video.completed` only, when the request had no schema: the schema written from `what_to_extract`. */
|
|
56
54
|
schema?: Record<string, unknown>;
|
|
55
|
+
/** `extract_video.completed` only: the moments each value of `result` comes from. */
|
|
56
|
+
evidence?: Record<string, Array<{ start?: number; end?: number; in: 'speech' | 'picture' | 'post' }>>;
|
|
57
57
|
error?: AsyncJobError | null;
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export interface NamedEntity {
|
|
2
|
-
name?: string;
|
|
3
|
-
context?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface KeySubject {
|
|
7
|
-
name?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
importance?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface QueryAnswer {
|
|
13
|
-
answer?: string;
|
|
14
|
-
best_segment_index?: number;
|
|
15
|
-
relevant_segments?: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface AnalysisResultJSON {
|
|
19
|
-
summary?: string;
|
|
20
|
-
people?: NamedEntity[];
|
|
21
|
-
places?: NamedEntity[];
|
|
22
|
-
key_subjects?: KeySubject[];
|
|
23
|
-
timestamp?: number;
|
|
24
|
-
relevant_text?: string;
|
|
25
|
-
query_answer?: QueryAnswer;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Represents the result of an AI analysis on a video or file.
|
|
30
|
-
*/
|
|
31
|
-
export class AnalysisResult {
|
|
32
|
-
summary?: string;
|
|
33
|
-
people?: NamedEntity[];
|
|
34
|
-
places?: NamedEntity[];
|
|
35
|
-
key_subjects?: KeySubject[];
|
|
36
|
-
timestamp?: number;
|
|
37
|
-
relevant_text?: string;
|
|
38
|
-
query_answer?: QueryAnswer;
|
|
39
|
-
|
|
40
|
-
constructor(data: Partial<AnalysisResultJSON>) {
|
|
41
|
-
Object.assign(this, data);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static fromJSON(json: AnalysisResultJSON): AnalysisResult {
|
|
45
|
-
return new AnalysisResult(json);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
toJSON(): AnalysisResultJSON {
|
|
49
|
-
return { ...this };
|
|
50
|
-
}
|
|
51
|
-
}
|