vidnavigator 2.7.0 → 3.0.1
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 +97 -109
- package/dist/index.d.ts +17 -109
- package/dist/index.js +14 -54
- package/dist/models/AsyncJob.d.ts +2 -2
- package/dist/models/SearchResult.d.ts +13 -7
- package/dist/models/SearchResult.js +16 -6
- 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 +2 -2
- package/package.json +1 -1
- package/src/index.ts +26 -172
- package/src/models/AsyncJob.ts +2 -2
- package/src/models/SearchResult.ts +31 -14
- package/src/models/TweetStatement.ts +10 -0
- package/src/models/index.ts +0 -1
- package/src/webhooks.ts +1 -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,
|
|
@@ -73,7 +71,7 @@ export { Job } from './jobs';
|
|
|
73
71
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
74
72
|
|
|
75
73
|
/** SDK version (keep in sync with package.json) */
|
|
76
|
-
export const SDK_VERSION = '
|
|
74
|
+
export const SDK_VERSION = '3.0.1';
|
|
77
75
|
|
|
78
76
|
/**
|
|
79
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
|
|
@@ -146,20 +144,6 @@ export type WatchInput = {
|
|
|
146
144
|
/** Payload of {@link VidNavigatorClient.watchVideo}: a {@link WatchInput} with `include_usage`. */
|
|
147
145
|
export type WatchVideoPayload = WatchInput & { include_usage?: boolean };
|
|
148
146
|
|
|
149
|
-
/** Input for {@link VidNavigatorClient.analyze}. A plain string is treated as `video_url`. */
|
|
150
|
-
export type AnalyzeVideoInput = {
|
|
151
|
-
video_url: string;
|
|
152
|
-
/** Optional question about the video. */
|
|
153
|
-
query?: string;
|
|
154
|
-
/**
|
|
155
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
156
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
157
|
-
*/
|
|
158
|
-
include_scenes?: boolean;
|
|
159
|
-
/** Return the transcript as a single string instead of segments. */
|
|
160
|
-
transcript_text?: boolean;
|
|
161
|
-
} & WebhookOption;
|
|
162
|
-
|
|
163
147
|
/**
|
|
164
148
|
* Input for {@link VidNavigatorClient.extractVideo}: a JSON Schema `schema`, or a JSON/YAML
|
|
165
149
|
* `schemaFilePath`, or neither with `what_to_extract`: the schema is then written from that text
|
|
@@ -190,7 +174,15 @@ export type ExtractVideoInput =
|
|
|
190
174
|
} & WebhookOption);
|
|
191
175
|
|
|
192
176
|
/** Input for {@link VidNavigatorClient.tweetStatement}. A plain string is treated as `tweet_id`. */
|
|
193
|
-
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;
|
|
194
186
|
|
|
195
187
|
export type TranscriptResult = {
|
|
196
188
|
video_info: VideoInfo;
|
|
@@ -218,9 +210,6 @@ export type TranscribeAsyncJob = AsyncJob<TranscribeVideoResult>;
|
|
|
218
210
|
/** Snapshot of a watch task. `result` is a {@link WatchResult}. */
|
|
219
211
|
export type WatchAsyncJob = AsyncJob<WatchResult>;
|
|
220
212
|
|
|
221
|
-
/** Snapshot of a video analysis task. `result` has the same shape as {@link VidNavigatorClient.analyzeVideo}'s return value. */
|
|
222
|
-
export type AnalyzeVideoAsyncJob = AsyncJob<AnalyzeVideoResult>;
|
|
223
|
-
|
|
224
213
|
/** Snapshot of an extraction task. `result` is the extracted object, shaped like your schema. */
|
|
225
214
|
export type ExtractVideoAsyncJob = AsyncJob<Record<string, unknown>>;
|
|
226
215
|
|
|
@@ -243,7 +232,6 @@ export interface TranscribeOperation extends JobOperation<string | TranscribeInp
|
|
|
243
232
|
submit(input: string | TranscribeInput, options?: SubmitOptions): Promise<Job<TranscribeAsyncJob, TranscribeVideoResult>>;
|
|
244
233
|
}
|
|
245
234
|
export type WatchJob = Job<WatchAsyncJob, WatchResult>;
|
|
246
|
-
export type AnalyzeVideoJob = Job<AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
247
235
|
export type ExtractVideoJob = Job<ExtractVideoAsyncJob, ExtractDataResult>;
|
|
248
236
|
export type TweetStatementJob = Job<TweetStatementAsyncJob, TweetStatement>;
|
|
249
237
|
/** `result()` resolves to the completed task with **all** pages of `videos` collected. */
|
|
@@ -356,65 +344,6 @@ export type SearchFilesResult = {
|
|
|
356
344
|
usage?: UsageBlock;
|
|
357
345
|
};
|
|
358
346
|
|
|
359
|
-
export type AnalyzeVideoPayload = {
|
|
360
|
-
video_url: string;
|
|
361
|
-
query?: string;
|
|
362
|
-
/**
|
|
363
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
364
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
365
|
-
*/
|
|
366
|
-
include_scenes?: boolean;
|
|
367
|
-
transcript_text?: boolean;
|
|
368
|
-
include_usage?: boolean;
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
export type AnalyzeFilePayload = {
|
|
372
|
-
file_id: string;
|
|
373
|
-
query?: string;
|
|
374
|
-
/**
|
|
375
|
-
* Default false. `true` analyzes the file from its transcript and its scenes together. The
|
|
376
|
-
* scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or with
|
|
377
|
-
* {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
378
|
-
* `ScenesNotAvailableError`.
|
|
379
|
-
*/
|
|
380
|
-
include_scenes?: boolean;
|
|
381
|
-
transcript_text?: boolean;
|
|
382
|
-
include_usage?: boolean;
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
export type AnalyzeVideoResult = {
|
|
386
|
-
video_info: VideoInfo;
|
|
387
|
-
transcript: TranscriptOutput;
|
|
388
|
-
transcript_analysis: AnalysisResult;
|
|
389
|
-
/**
|
|
390
|
-
* With `include_scenes: true`: what the video shows, in chronological order. Empty when the
|
|
391
|
-
* picture could not be read (see `scenes_error`).
|
|
392
|
-
*/
|
|
393
|
-
scenes?: VideoScene[];
|
|
394
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
395
|
-
frames_analyzed?: number;
|
|
396
|
-
/** With `include_scenes: true`, when the picture could not be read: the analysis was made from the transcript alone. */
|
|
397
|
-
scenes_error?: ScenesError;
|
|
398
|
-
/** With `include_scenes: true`, when there is no transcript: the analysis was made from the scenes alone. */
|
|
399
|
-
transcript_error?: WatchTranscriptError;
|
|
400
|
-
usage?: UsageBlock;
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
export type AnalyzeFileResult = {
|
|
404
|
-
file_info: FileInfo;
|
|
405
|
-
transcript: TranscriptOutput;
|
|
406
|
-
transcript_analysis: AnalysisResult;
|
|
407
|
-
/** With `include_scenes: true`: what the file shows, in chronological order. */
|
|
408
|
-
scenes?: VideoScene[];
|
|
409
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
410
|
-
frames_analyzed?: number;
|
|
411
|
-
/** 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. */
|
|
412
|
-
scenes_error?: ScenesError;
|
|
413
|
-
/** With `include_scenes: true`, when the file has no speech: the analysis was made from the scenes alone. */
|
|
414
|
-
transcript_error?: WatchTranscriptError;
|
|
415
|
-
usage?: UsageBlock;
|
|
416
|
-
};
|
|
417
|
-
|
|
418
347
|
export type ExtractVideoDataPayload = {
|
|
419
348
|
video_url: string;
|
|
420
349
|
/** A standard JSON Schema. Optional when `what_to_extract` is given. */
|
|
@@ -439,7 +368,8 @@ export type ExtractVideoDataMultipartPayload = {
|
|
|
439
368
|
include_usage?: boolean;
|
|
440
369
|
} & WebhookOption;
|
|
441
370
|
|
|
442
|
-
|
|
371
|
+
/** Payload of {@link VidNavigatorClient.getTweetStatement}: the same fields as {@link TweetStatementInput}. */
|
|
372
|
+
export type TweetStatementPayload = TweetStatementInput;
|
|
443
373
|
|
|
444
374
|
export type ExtractFileDataPayload = {
|
|
445
375
|
file_id: string;
|
|
@@ -507,13 +437,6 @@ interface SceneNotes {
|
|
|
507
437
|
transcript_error?: WatchTranscriptError;
|
|
508
438
|
}
|
|
509
439
|
|
|
510
|
-
/** The `data` block of an analysis: the same for a video, its background job and an uploaded file. */
|
|
511
|
-
interface AnalysisDataJSON extends SceneNotes {
|
|
512
|
-
transcript: TranscriptSegmentJSON[] | string;
|
|
513
|
-
transcript_analysis: AnalysisResultJSON;
|
|
514
|
-
scenes?: VideoSceneJSON[];
|
|
515
|
-
}
|
|
516
|
-
|
|
517
440
|
// The scene fields are set only when the response carries them, so a result asked without
|
|
518
441
|
// `include_scenes` keeps the shape it always had.
|
|
519
442
|
function pickSceneNotes(raw: SceneNotes): SceneNotes {
|
|
@@ -528,20 +451,11 @@ function parseScenes(raw: VideoSceneJSON[] | undefined): { scenes?: VideoScene[]
|
|
|
528
451
|
return raw ? { scenes: raw.map((scene) => VideoScene.fromJSON(scene)) } : {};
|
|
529
452
|
}
|
|
530
453
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
...pickSceneNotes(raw),
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
function parseAnalyzeVideoData(
|
|
541
|
-
raw: AnalysisDataJSON & { video_info: VideoInfoJSON },
|
|
542
|
-
usage?: UsageBlock
|
|
543
|
-
): AnalyzeVideoResult {
|
|
544
|
-
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;
|
|
545
459
|
}
|
|
546
460
|
|
|
547
461
|
function buildAsyncJobParams(options?: SubmitOptions): Record<string, string> | undefined {
|
|
@@ -645,14 +559,6 @@ export class VidNavigatorClient {
|
|
|
645
559
|
*/
|
|
646
560
|
readonly watch: JobOperation<string | WatchInput, WatchAsyncJob, WatchResult>;
|
|
647
561
|
|
|
648
|
-
/**
|
|
649
|
-
* Analysis of an online video as a background job, built on `POST /analyze/video/async`: the
|
|
650
|
-
* same analysis and the same result as {@link VidNavigatorClient.analyzeVideo}, without holding
|
|
651
|
-
* a connection open while it runs. Use it with `include_scenes: true` on a video longer than
|
|
652
|
-
* about 10 minutes. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
653
|
-
*/
|
|
654
|
-
readonly analyze: JobOperation<string | AnalyzeVideoInput, AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
655
|
-
|
|
656
562
|
/**
|
|
657
563
|
* Structured-data extraction from a video of any length, built on `POST /extract/video/async`.
|
|
658
564
|
* The schema is validated when you submit. With `include_scenes: true` the fields are extracted
|
|
@@ -663,7 +569,8 @@ export class VidNavigatorClient {
|
|
|
663
569
|
|
|
664
570
|
/**
|
|
665
571
|
* Structured claim analysis of an X/Twitter tweet (attached media of any length), built on
|
|
666
|
-
* `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}.
|
|
667
574
|
*/
|
|
668
575
|
readonly tweetStatement: JobOperation<string | TweetStatementInput, TweetStatementAsyncJob, TweetStatement>;
|
|
669
576
|
|
|
@@ -724,17 +631,6 @@ export class VidNavigatorClient {
|
|
|
724
631
|
},
|
|
725
632
|
});
|
|
726
633
|
|
|
727
|
-
this.analyze = this.defineOperation({
|
|
728
|
-
jobType: 'analyze_video',
|
|
729
|
-
submit: (input: string | AnalyzeVideoInput) =>
|
|
730
|
-
this.submitAsyncJob('/analyze/video/async', typeof input === 'string' ? { video_url: input } : input),
|
|
731
|
-
fetchTask: (task_id, options) =>
|
|
732
|
-
this.getAsyncJob(`/analyze/video/${encodeURIComponent(task_id)}`, options, (raw) =>
|
|
733
|
-
parseAnalyzeVideoData(raw)
|
|
734
|
-
),
|
|
735
|
-
toResult: async (task) => ({ ...requireResult(task), usage: task.usage }),
|
|
736
|
-
});
|
|
737
|
-
|
|
738
634
|
this.extractVideo = this.defineOperation({
|
|
739
635
|
jobType: 'extract_video',
|
|
740
636
|
submit: (input: ExtractVideoInput) => this.submitExtractVideo(input),
|
|
@@ -757,7 +653,7 @@ export class VidNavigatorClient {
|
|
|
757
653
|
this.tweetStatement = this.defineOperation({
|
|
758
654
|
jobType: 'tweet_statement',
|
|
759
655
|
submit: (input: string | TweetStatementInput) =>
|
|
760
|
-
this.submitAsyncJob('/tweet/statement/async',
|
|
656
|
+
this.submitAsyncJob('/tweet/statement/async', tweetStatementBody(input)),
|
|
761
657
|
fetchTask: (task_id, options) =>
|
|
762
658
|
this.getAsyncJob(`/tweet/statement/${encodeURIComponent(task_id)}`, options, (raw) =>
|
|
763
659
|
TweetStatement.fromJSON(raw)
|
|
@@ -1229,7 +1125,7 @@ export class VidNavigatorClient {
|
|
|
1229
1125
|
* The answer has `scenes_status` `processing` when the analysis was started or is already
|
|
1230
1126
|
* running, and `completed` when the scenes are already there (nothing new is started). Follow
|
|
1231
1127
|
* `file_info.scenes_status` with {@link VidNavigatorClient.getFile}, which returns the scenes
|
|
1232
|
-
* once it is `completed`; `
|
|
1128
|
+
* once it is `completed`; `extractFileData` reads them with `include_scenes: true`.
|
|
1233
1129
|
*
|
|
1234
1130
|
* An audio file has no picture: the call throws `BadRequestError` with `error_code`
|
|
1235
1131
|
* `frames_not_available`.
|
|
@@ -1297,53 +1193,12 @@ export class VidNavigatorClient {
|
|
|
1297
1193
|
}
|
|
1298
1194
|
//endregion
|
|
1299
1195
|
|
|
1300
|
-
//region ---
|
|
1301
|
-
/**
|
|
1302
|
-
* Analyze an online video: a summary, the people, places and key subjects, and the answer to
|
|
1303
|
-
* an optional `query`. With `include_scenes: true` the analysis is made from the transcript and
|
|
1304
|
-
* from what the video shows, and the result also has `scenes` and `frames_analyzed`, as
|
|
1305
|
-
* {@link VidNavigatorClient.watch} returns them. When the picture cannot be read, the analysis
|
|
1306
|
-
* is made from the transcript alone and `scenes_error` says why; a video without a transcript
|
|
1307
|
-
* is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
|
|
1308
|
-
*
|
|
1309
|
-
* This call waits on one HTTP request. With `include_scenes` on a video longer than about
|
|
1310
|
-
* 10 minutes, use {@link VidNavigatorClient.analyze}, which runs the same analysis as a
|
|
1311
|
-
* background job.
|
|
1312
|
-
*/
|
|
1313
|
-
async analyzeVideo(payload: AnalyzeVideoPayload): Promise<AnalyzeVideoResult> {
|
|
1314
|
-
const response = await this.request<ApiSuccessResponse<AnalysisDataJSON & { video_info: VideoInfoJSON }>>(
|
|
1315
|
-
'POST',
|
|
1316
|
-
'/analyze/video',
|
|
1317
|
-
payload
|
|
1318
|
-
);
|
|
1319
|
-
|
|
1320
|
-
return parseAnalyzeVideoData(response.data, response.usage ? UsageBlock.fromJSON(response.usage) : undefined);
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
/**
|
|
1324
|
-
* Analyze an uploaded file. With `include_scenes: true` the analysis is made from the transcript
|
|
1325
|
-
* of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`.
|
|
1326
|
-
* The scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or
|
|
1327
|
-
* with {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
1328
|
-
* `ScenesNotAvailableError` (HTTP 409), whose `scenes_status` says where their analysis stands.
|
|
1329
|
-
*/
|
|
1330
|
-
async analyzeFile(payload: AnalyzeFilePayload): Promise<AnalyzeFileResult> {
|
|
1331
|
-
const response = await this.request<ApiSuccessResponse<AnalysisDataJSON & { file_info: FileInfoJSON }>>(
|
|
1332
|
-
'POST',
|
|
1333
|
-
'/analyze/file',
|
|
1334
|
-
payload
|
|
1335
|
-
);
|
|
1336
|
-
|
|
1337
|
-
return {
|
|
1338
|
-
file_info: FileInfo.fromJSON(response.data.file_info),
|
|
1339
|
-
...parseAnalysisData(response.data),
|
|
1340
|
-
usage: response.usage ? UsageBlock.fromJSON(response.usage) : undefined,
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1196
|
+
//region --- X posts ---
|
|
1344
1197
|
/**
|
|
1345
1198
|
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
1346
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`.
|
|
1347
1202
|
*/
|
|
1348
1203
|
async getTweetStatement(
|
|
1349
1204
|
payload: TweetStatementPayload,
|
|
@@ -1458,9 +1313,8 @@ export class VidNavigatorClient {
|
|
|
1458
1313
|
}
|
|
1459
1314
|
|
|
1460
1315
|
/**
|
|
1461
|
-
* @deprecated
|
|
1462
|
-
*
|
|
1463
|
-
* `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.
|
|
1464
1318
|
*/
|
|
1465
1319
|
async searchVideos(payload: SearchYouTubePayload): Promise<SearchYouTubeResult> {
|
|
1466
1320
|
warnDeprecated('searchVideos', 'searchYouTube');
|
package/src/models/AsyncJob.ts
CHANGED
|
@@ -3,8 +3,8 @@ 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';
|
|
@@ -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. */
|
|
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;
|
|
@@ -12,10 +17,21 @@ export interface BaseSearchResult {
|
|
|
12
17
|
transcript_summary?: string;
|
|
13
18
|
}
|
|
14
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The API sends `people`, `places` and `key_subjects` as lists of names
|
|
22
|
+
* (`["Sam Altman"]`). Each name is turned into `{ name }`, so `.name` reads the
|
|
23
|
+
* same whatever the API sent; an entry that is already an object is kept.
|
|
24
|
+
*/
|
|
25
|
+
function toNamed<T extends { name?: string }>(values?: Array<T | string> | null): T[] | undefined {
|
|
26
|
+
if (!Array.isArray(values)) return undefined;
|
|
27
|
+
return values.map((value) => (typeof value === 'string' ? ({ name: value } as T) : value));
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
export interface VideoSearchResultJSON extends VideoInfoJSON, BaseSearchResult {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
/** Names, as the API sends them. */
|
|
32
|
+
people?: Array<string | NamedEntity>;
|
|
33
|
+
places?: Array<string | NamedEntity>;
|
|
34
|
+
key_subjects?: Array<string | SearchKeySubject>;
|
|
19
35
|
timestamp?: number;
|
|
20
36
|
relevant_text?: string;
|
|
21
37
|
query_relevance?: string;
|
|
@@ -23,9 +39,10 @@ export interface VideoSearchResultJSON extends VideoInfoJSON, BaseSearchResult {
|
|
|
23
39
|
|
|
24
40
|
export interface FileSearchResultJSON extends FileInfoJSON, BaseSearchResult {
|
|
25
41
|
file_url?: string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
/** Names, as the API sends them. */
|
|
43
|
+
people?: Array<string | NamedEntity>;
|
|
44
|
+
places?: Array<string | NamedEntity>;
|
|
45
|
+
key_subjects?: Array<string | SearchKeySubject>;
|
|
29
46
|
timestamps?: number[];
|
|
30
47
|
relevant_text?: string;
|
|
31
48
|
query_answer?: string;
|
|
@@ -48,9 +65,9 @@ export class VideoSearchResult extends VideoInfo implements BaseSearchResult {
|
|
|
48
65
|
super(data);
|
|
49
66
|
this.relevance_score = data.relevance_score;
|
|
50
67
|
this.transcript_summary = data.transcript_summary;
|
|
51
|
-
this.people = data.people;
|
|
52
|
-
this.places = data.places;
|
|
53
|
-
this.key_subjects = data.key_subjects;
|
|
68
|
+
this.people = toNamed<NamedEntity>(data.people);
|
|
69
|
+
this.places = toNamed<NamedEntity>(data.places);
|
|
70
|
+
this.key_subjects = toNamed<SearchKeySubject>(data.key_subjects);
|
|
54
71
|
this.timestamp = data.timestamp;
|
|
55
72
|
this.relevant_text = data.relevant_text;
|
|
56
73
|
this.query_relevance = data.query_relevance;
|
|
@@ -80,9 +97,9 @@ export class FileSearchResult extends FileInfo implements BaseSearchResult {
|
|
|
80
97
|
this.relevance_score = data.relevance_score;
|
|
81
98
|
this.transcript_summary = data.transcript_summary;
|
|
82
99
|
this.file_url = data.file_url;
|
|
83
|
-
this.people = data.people;
|
|
84
|
-
this.places = data.places;
|
|
85
|
-
this.key_subjects = data.key_subjects;
|
|
100
|
+
this.people = toNamed<NamedEntity>(data.people);
|
|
101
|
+
this.places = toNamed<NamedEntity>(data.places);
|
|
102
|
+
this.key_subjects = toNamed<SearchKeySubject>(data.key_subjects);
|
|
86
103
|
this.timestamps = data.timestamps;
|
|
87
104
|
this.relevant_text = data.relevant_text;
|
|
88
105
|
this.query_answer = data.query_answer;
|
|
@@ -91,4 +108,4 @@ export class FileSearchResult extends FileInfo implements BaseSearchResult {
|
|
|
91
108
|
static fromJSON(json: FileSearchResultJSON): FileSearchResult {
|
|
92
109
|
return new FileSearchResult(json);
|
|
93
110
|
}
|
|
94
|
-
}
|
|
111
|
+
}
|
|
@@ -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.
|
|
@@ -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
|
-
}
|