twelvelabs-js 0.3.3 → 0.4.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 +46 -39
- package/dist/README.md +46 -39
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -2
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/dist/models/embed/index.d.ts +6 -6
- package/dist/models/embed/index.d.ts.map +1 -1
- package/dist/models/embed/index.js +3 -3
- package/dist/models/embed/index.js.map +1 -1
- package/dist/models/embed/index.mjs +3 -3
- package/dist/models/embed/index.mjs.map +1 -1
- package/dist/models/generate/index.d.ts +0 -6
- package/dist/models/generate/index.d.ts.map +1 -1
- package/dist/models/generate/index.js.map +1 -1
- package/dist/models/generate/index.mjs.map +1 -1
- package/dist/models/index/index.d.ts +8 -9
- package/dist/models/index/index.d.ts.map +1 -1
- package/dist/models/index/index.js +4 -7
- package/dist/models/index/index.js.map +1 -1
- package/dist/models/index/index.mjs +4 -7
- package/dist/models/index/index.mjs.map +1 -1
- package/dist/models/index.d.ts +0 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +0 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/index.mjs +0 -2
- package/dist/models/interfaces.d.ts +1 -1
- package/dist/models/search/index.d.ts +0 -6
- package/dist/models/search/index.d.ts.map +1 -1
- package/dist/models/task/index.d.ts +2 -10
- package/dist/models/task/index.d.ts.map +1 -1
- package/dist/models/task/index.js +2 -6
- package/dist/models/task/index.js.map +1 -1
- package/dist/models/task/index.mjs +2 -6
- package/dist/models/task/index.mjs.map +1 -1
- package/dist/models/video/index.d.ts +6 -9
- package/dist/models/video/index.d.ts.map +1 -1
- package/dist/models/video/index.js +2 -16
- package/dist/models/video/index.js.map +1 -1
- package/dist/models/video/index.mjs +2 -16
- package/dist/models/video/index.mjs.map +1 -1
- package/dist/resources/embed/index.d.ts +3 -3
- package/dist/resources/embed/index.d.ts.map +1 -1
- package/dist/resources/embed/index.js +6 -6
- package/dist/resources/embed/index.js.map +1 -1
- package/dist/resources/embed/index.mjs +6 -6
- package/dist/resources/embed/index.mjs.map +1 -1
- package/dist/resources/embed/interfaces.d.ts +1 -1
- package/dist/resources/embed/interfaces.d.ts.map +1 -1
- package/dist/resources/generate/index.d.ts +1 -2
- package/dist/resources/generate/index.d.ts.map +1 -1
- package/dist/resources/generate/index.js +0 -8
- package/dist/resources/generate/index.js.map +1 -1
- package/dist/resources/generate/index.mjs +0 -8
- package/dist/resources/generate/index.mjs.map +1 -1
- package/dist/resources/generate/interfaces.d.ts +0 -1
- package/dist/resources/generate/interfaces.d.ts.map +1 -1
- package/dist/resources/index/index.d.ts +1 -1
- package/dist/resources/index/index.d.ts.map +1 -1
- package/dist/resources/index/index.js +3 -3
- package/dist/resources/index/index.js.map +1 -1
- package/dist/resources/index/index.mjs +3 -3
- package/dist/resources/index/index.mjs.map +1 -1
- package/dist/resources/index/interfaces.d.ts +5 -5
- package/dist/resources/index/interfaces.d.ts.map +1 -1
- package/dist/resources/index.d.ts +0 -3
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +0 -3
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/index.mjs +0 -3
- package/dist/resources/search/index.d.ts +1 -1
- package/dist/resources/search/index.d.ts.map +1 -1
- package/dist/resources/search/index.js +2 -32
- package/dist/resources/search/index.js.map +1 -1
- package/dist/resources/search/index.mjs +3 -33
- package/dist/resources/search/index.mjs.map +1 -1
- package/dist/resources/search/interfaces.d.ts +1 -3
- package/dist/resources/search/interfaces.d.ts.map +1 -1
- package/dist/resources/task/index.d.ts +4 -7
- package/dist/resources/task/index.d.ts.map +1 -1
- package/dist/resources/task/index.js +11 -26
- package/dist/resources/task/index.js.map +1 -1
- package/dist/resources/task/index.mjs +11 -26
- package/dist/resources/task/index.mjs.map +1 -1
- package/dist/resources/task/interfaces.d.ts +1 -3
- package/dist/resources/task/interfaces.d.ts.map +1 -1
- package/dist/resources/video/index.d.ts +4 -8
- package/dist/resources/video/index.d.ts.map +1 -1
- package/dist/resources/video/index.js +20 -32
- package/dist/resources/video/index.js.map +1 -1
- package/dist/resources/video/index.mjs +20 -32
- package/dist/resources/video/index.mjs.map +1 -1
- package/dist/resources/video/interfaces.d.ts +2 -8
- package/dist/resources/video/interfaces.d.ts.map +1 -1
- package/dist/src/constants.ts +1 -1
- package/dist/src/index.ts +8 -11
- package/dist/src/models/embed/index.ts +9 -9
- package/dist/src/models/generate/index.ts +0 -7
- package/dist/src/models/index/index.ts +12 -15
- package/dist/src/models/index.ts +0 -2
- package/dist/src/models/interfaces.ts +1 -1
- package/dist/src/models/search/index.ts +0 -7
- package/dist/src/models/task/index.ts +4 -17
- package/dist/src/models/video/index.ts +8 -34
- package/dist/src/resources/embed/index.ts +6 -6
- package/dist/src/resources/embed/interfaces.ts +1 -1
- package/dist/src/resources/generate/index.ts +1 -14
- package/dist/src/resources/generate/interfaces.ts +0 -1
- package/dist/src/resources/index/index.ts +3 -3
- package/dist/src/resources/index/interfaces.ts +3 -3
- package/dist/src/resources/index.ts +0 -3
- package/dist/src/resources/search/index.ts +2 -41
- package/dist/src/resources/search/interfaces.ts +1 -3
- package/dist/src/resources/task/index.ts +11 -32
- package/dist/src/resources/task/interfaces.ts +1 -3
- package/dist/src/resources/video/index.ts +19 -68
- package/dist/src/resources/video/interfaces.ts +2 -9
- package/package.json +1 -1
- package/dist/models/classify/index.d.ts +0 -38
- package/dist/models/classify/index.d.ts.map +0 -1
- package/dist/models/classify/index.js +0 -21
- package/dist/models/classify/index.js.map +0 -1
- package/dist/models/classify/index.mjs +0 -17
- package/dist/models/classify/index.mjs.map +0 -1
- package/dist/models/engine/index.d.ts +0 -16
- package/dist/models/engine/index.d.ts.map +0 -1
- package/dist/models/engine/index.js +0 -14
- package/dist/models/engine/index.js.map +0 -1
- package/dist/models/engine/index.mjs +0 -10
- package/dist/models/engine/index.mjs.map +0 -1
- package/dist/resources/classify/index.d.ts +0 -10
- package/dist/resources/classify/index.d.ts.map +0 -1
- package/dist/resources/classify/index.js +0 -53
- package/dist/resources/classify/index.js.map +0 -1
- package/dist/resources/classify/index.mjs +0 -26
- package/dist/resources/classify/index.mjs.map +0 -1
- package/dist/resources/classify/interfaces.d.ts +0 -21
- package/dist/resources/classify/interfaces.d.ts.map +0 -1
- package/dist/resources/classify/interfaces.js +0 -3
- package/dist/resources/classify/interfaces.js.map +0 -1
- package/dist/resources/classify/interfaces.mjs +0 -2
- package/dist/resources/classify/interfaces.mjs.map +0 -1
- package/dist/resources/engine/index.d.ts +0 -8
- package/dist/resources/engine/index.d.ts.map +0 -1
- package/dist/resources/engine/index.js +0 -42
- package/dist/resources/engine/index.js.map +0 -1
- package/dist/resources/engine/index.mjs +0 -15
- package/dist/resources/engine/index.mjs.map +0 -1
- package/dist/src/models/classify/index.ts +0 -57
- package/dist/src/models/engine/index.ts +0 -23
- package/dist/src/resources/classify/index.ts +0 -44
- package/dist/src/resources/classify/interfaces.ts +0 -22
- package/dist/src/resources/engine/index.ts +0 -17
package/README.md
CHANGED
|
@@ -19,6 +19,27 @@ Install the `twelvelabs-js` package:
|
|
|
19
19
|
yarn add twelvelabs-js # or npm i twelvelabs-js
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
````
|
|
23
|
+
|
|
24
|
+
The current SDK version is compatible with API version 1.3. If you wish to use API version 1.2, please use version 0.3.x or earlier of the SDK. Below are the SDK versions and the corresponding supported API versions.
|
|
25
|
+
|
|
26
|
+
| SDK Version | Supported API Version |
|
|
27
|
+
| ----------- | --------------------- |
|
|
28
|
+
| 0.4.x | 1.3 |
|
|
29
|
+
| 0.3.x | 1.2 |
|
|
30
|
+
|
|
31
|
+
How to install the latest 0.3.x version of the SDK:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install twelvelabs-js@0.3.x
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
How to install the SDK with a specific version:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install twelvelabs-js@0.3.x # replace 0.3.x with the version you want
|
|
41
|
+
```
|
|
42
|
+
|
|
22
43
|
# Initialize the SDK
|
|
23
44
|
|
|
24
45
|
1. Import the required packages into your application:
|
|
@@ -50,39 +71,39 @@ To create an index, use the example code below, replacing '<YOUR_INDEX_NAME>' wi
|
|
|
50
71
|
```js
|
|
51
72
|
let index = await client.index.create({
|
|
52
73
|
name: '<YOUR_INDEX_NAME>',
|
|
53
|
-
|
|
74
|
+
models: [
|
|
54
75
|
{
|
|
55
|
-
name: 'marengo2.
|
|
56
|
-
options: ['visual', '
|
|
76
|
+
name: 'marengo2.7',
|
|
77
|
+
options: ['visual', 'audio'],
|
|
57
78
|
},
|
|
58
79
|
{
|
|
59
80
|
name: 'pegasus1.1',
|
|
60
|
-
options: ['visual', '
|
|
81
|
+
options: ['visual', 'audio'],
|
|
61
82
|
},
|
|
62
83
|
],
|
|
63
84
|
});
|
|
64
85
|
|
|
65
|
-
console.log(`Created index: id=${index.id} name=${index.name}
|
|
86
|
+
console.log(`Created index: id=${index.id} name=${index.name} models=${JSON.stringify(index.models)}`);
|
|
66
87
|
```
|
|
67
88
|
|
|
68
89
|
Note the following about this example:
|
|
69
90
|
|
|
70
|
-
- The platform provides two distinct
|
|
71
|
-
- **Embedding
|
|
72
|
-
- **Generative
|
|
91
|
+
- The platform provides two distinct model types - embedding and generative, each serving unique purposes in multimodal video understanding.
|
|
92
|
+
- **Embedding models (Marengo)**: These models are proficient at performing tasks such as search and classification, enabling enhanced video understanding.
|
|
93
|
+
- **Generative models (Pegasus)**: These models generate text based on your videos.
|
|
73
94
|
For your index, both Marengo and Pegasus are enabled.
|
|
74
|
-
- The `
|
|
75
|
-
- The
|
|
95
|
+
- The `models.options` fields specify the types of information each video understanding model will process. For details, see the [model options](https://docs.twelvelabs.io/v1.3/docs/model-options) page.
|
|
96
|
+
- The models and the model options specified when you create an index apply to all the videos you upload to that index and cannot be changed. For details, see the [model options](https://docs.twelvelabs.io/v1.3/docs/model-options) page.
|
|
76
97
|
|
|
77
98
|
The output should look similar to the following:
|
|
78
99
|
|
|
79
100
|
```
|
|
80
|
-
Created index: id=65e71802bb29f13bdd6f38d8 name=2024-03-05T13:02:57.938Z
|
|
101
|
+
Created index: id=65e71802bb29f13bdd6f38d8 name=2024-03-05T13:02:57.938Z models=[{"name":"pegasus1.1","options":["visual","audio"]},{"name":"marengo2.7","options":["visual","audio"]}]
|
|
81
102
|
```
|
|
82
103
|
|
|
83
104
|
Note that the API returns, among other information, a field named `id`, representing the unique identifier of your new index.
|
|
84
105
|
|
|
85
|
-
For a description of each field in the request and response, see the [Create an index](https://docs.twelvelabs.io/v1.
|
|
106
|
+
For a description of each field in the request and response, see the [Create an index](https://docs.twelvelabs.io/v1.3/reference/create-index) page.
|
|
86
107
|
|
|
87
108
|
## Upload videos
|
|
88
109
|
|
|
@@ -92,7 +113,7 @@ Before you upload a video to the platform, ensure that it meets the following re
|
|
|
92
113
|
- **Video and audio formats**: The video files you wish to upload must be encoded in the video and audio formats listed on the [FFmpeg Formats Documentation](https://ffmpeg.org/ffmpeg-formats.html) page. For videos in other formats, contact us at [support@twelvelabs.io](mailto:support@twelvelabs.io).
|
|
93
114
|
- **Duration**: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 30 minutes (1,800s).
|
|
94
115
|
- **File size**: Must not exceed 2 GB. If you require different options, send us an email at support@twelvelabs.io.
|
|
95
|
-
- **Audio track**: If the `
|
|
116
|
+
- **Audio track**: If the `audio` [model option](https://docs.twelvelabs.io/v1.3/docs/model-options) is selected, the video you're uploading must contain an audio track.
|
|
96
117
|
|
|
97
118
|
To upload videos, use the example code below, replacing the following:
|
|
98
119
|
|
|
@@ -140,7 +161,7 @@ To perform search requests using text queries, use the example code below, repla
|
|
|
140
161
|
|
|
141
162
|
- **`<YOUR_INDEX_ID>`**: with a string representing the unique identifier of your index.
|
|
142
163
|
- **`<YOUR_QUERY>`**: with a string representing your search query. Note that the API supports full natural language-based search. The following examples are valid queries: "birds flying near a castle," "sun shining on water," and "an officer holding a child's hand."
|
|
143
|
-
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual and
|
|
164
|
+
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual and audio cues, use `["visual", "audio"]`. Note that the search options you specify must be a subset of the model options used when you created the index. For more details, see the [Search options](https://docs.twelvelabs.io/docs/search-options) page.
|
|
144
165
|
|
|
145
166
|
```js
|
|
146
167
|
let searchResults = await client.search.query({
|
|
@@ -176,16 +197,15 @@ The results are returned one page at a time, with a default limit of 10 results
|
|
|
176
197
|
Note that the response contains, among other information, the following fields:
|
|
177
198
|
|
|
178
199
|
- `videoId`: The unique identifier of the video that matched your search terms.
|
|
179
|
-
- `score`: A quantitative value determined by the AI
|
|
200
|
+
- `score`: A quantitative value determined by the AI model representing the level of confidence that the results match your search terms.
|
|
180
201
|
- `start`: The start time of the matching video clip, expressed in seconds.
|
|
181
202
|
- `end`: The end time of the matching video clip, expressed in seconds.
|
|
182
203
|
- `confidence`: A qualitative indicator based on the value of the score field. This field can take one of the following values:
|
|
183
204
|
- `high`
|
|
184
205
|
- `medium`
|
|
185
206
|
- `low`
|
|
186
|
-
- `extremely low`
|
|
187
207
|
|
|
188
|
-
For a description of each field in the request and response, see the [Make a search request](https://docs.twelvelabs.io/v1.
|
|
208
|
+
For a description of each field in the request and response, see the [Make a search request](https://docs.twelvelabs.io/v1.3/reference/make-search-request) page.
|
|
189
209
|
|
|
190
210
|
**Search using image queries**
|
|
191
211
|
|
|
@@ -195,7 +215,7 @@ To perform a search request using image queries, use the example code below, rep
|
|
|
195
215
|
|
|
196
216
|
- **`<YOUR_INDEX_ID>`**: with a string representing the unique identifier of your index.
|
|
197
217
|
- **`<YOUR_FILE_PATH>`**: with a string representing the path of the image file you wish to provide.
|
|
198
|
-
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual cues, use `["visual"]`. Note that the search options you specify must be a subset of the
|
|
218
|
+
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual cues, use `["visual"]`. Note that the search options you specify must be a subset of the model options used when you created the index. For more details, see the [Search options](https://docs.twelvelabs.io/docs/search-options) page.
|
|
199
219
|
|
|
200
220
|
```js
|
|
201
221
|
let searchResults = await client.search.query({
|
|
@@ -214,24 +234,10 @@ The Twelve Labs Video Understanding Platform offers three distinct endpoints tai
|
|
|
214
234
|
|
|
215
235
|
Note the following about using these endpoints:
|
|
216
236
|
|
|
217
|
-
- The Pegasus video understanding
|
|
237
|
+
- The Pegasus video understanding model must be enabled for the index to which your video has been uploaded.
|
|
218
238
|
- Your prompts must be instructive or descriptive, and you can also phrase them as questions.
|
|
219
239
|
- The maximum length of a prompt is 1500 characters.
|
|
220
240
|
|
|
221
|
-
#### Topics, titles, and hashtags
|
|
222
|
-
|
|
223
|
-
To generate topics, titles, and hashtags, use the example code below, replacing the following:
|
|
224
|
-
|
|
225
|
-
- **`<YOUR_VIDEO_ID>`**: with a string representing the unique identifier of your video.
|
|
226
|
-
- **`[<TYPES>]`**: with an array of strings representing the type of text the platform should generate. Example: `["title", "topic", "hashtag"]`.
|
|
227
|
-
|
|
228
|
-
```js
|
|
229
|
-
const gist = await client.generate.gist('<YOUR_VIDEO_ID>', ['<TYPES>']);
|
|
230
|
-
console.log(`Title: ${gist.title}\nTopics=${gist.topics}\nHashtags=${gist.hashtags}`);
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
For a description of each field in the request and response, see the [Titles, topics, or hashtags](https://docs.twelvelabs.io/v1.2/reference/generate-gist) page.
|
|
234
|
-
|
|
235
241
|
#### Summaries, chapters, and highlights
|
|
236
242
|
|
|
237
243
|
To generate summaries, chapters, and highlights, use the example code below, replacing the following:
|
|
@@ -245,14 +251,14 @@ const summary = await client.generate.summarize('<YOUR_VIDEO_ID>', '<TYPE>');
|
|
|
245
251
|
console.log(`Summary: ${summary.summary}`);
|
|
246
252
|
```
|
|
247
253
|
|
|
248
|
-
For a description of each field in the request and response, see the [Summaries, chapters, or highlights](https://docs.twelvelabs.io/v1.
|
|
254
|
+
For a description of each field in the request and response, see the [Summaries, chapters, or highlights](https://docs.twelvelabs.io/v1.3/docs/generate-summaries-chapters-highlights) page.
|
|
249
255
|
|
|
250
256
|
#### Open-ended texts
|
|
251
257
|
|
|
252
258
|
To generate open-ended texts, use the example code below, replacing the following:
|
|
253
259
|
|
|
254
260
|
- **`<YOUR_VIDEO_ID>`**: with a string representing the unique identifier of your video.
|
|
255
|
-
- **`<YOUR_PROMPT>`**: with a string that guides the model on the desired format or content. The maximum length of the prompt is 1500 characters. Example:
|
|
261
|
+
- **`<YOUR_PROMPT>`**: with a string that guides the model on the desired format or content. The maximum length of the prompt is 1500 characters. Example: "I want to generate a description for my video with the following format: Title of the video, followed by a summary in 2-3 sentences, highlighting the main topic, key events, and concluding remarks."
|
|
256
262
|
|
|
257
263
|
```js
|
|
258
264
|
const text = await client.generate.text('<YOUR_VIDEO_ID>', '<YOUR_PROMPT>');
|
|
@@ -280,14 +286,14 @@ The following example shows how you can handle specific HTTP errors in your appl
|
|
|
280
286
|
try {
|
|
281
287
|
let index = await client.index.create({
|
|
282
288
|
name: '<YOUR_INDEX_NAME>',
|
|
283
|
-
|
|
289
|
+
models: [
|
|
284
290
|
{
|
|
285
|
-
name: 'marengo2.
|
|
286
|
-
options: ['visual', '
|
|
291
|
+
name: 'marengo2.7',
|
|
292
|
+
options: ['visual', 'audio'],
|
|
287
293
|
},
|
|
288
294
|
],
|
|
289
295
|
});
|
|
290
|
-
console.log(`Created index: id=${index.id} name=${index.name}
|
|
296
|
+
console.log(`Created index: id=${index.id} name=${index.name} models=${JSON.stringify(index.models)}`);
|
|
291
297
|
} catch (e) {
|
|
292
298
|
console.log(e);
|
|
293
299
|
}
|
|
@@ -305,3 +311,4 @@ You can sign your commit automatically with Git by using `git commit -s` if you
|
|
|
305
311
|
We ask that you use your real name (please, no anonymous contributions or pseudonyms). By signing your commitment, you are certifying that you have the right have the right to submit it under the open-source license used by that particular project. You must use your real name (no pseudonyms or anonymous contributions are allowed.)
|
|
306
312
|
We use the Probot DCO GitHub app to check for DCO signoffs of every commit.
|
|
307
313
|
If you forget to sign your commits, the DCO bot will remind you and give you detailed instructions for how to amend your commits to add a signature.
|
|
314
|
+
````
|
package/dist/README.md
CHANGED
|
@@ -19,6 +19,27 @@ Install the `twelvelabs-js` package:
|
|
|
19
19
|
yarn add twelvelabs-js # or npm i twelvelabs-js
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
````
|
|
23
|
+
|
|
24
|
+
The current SDK version is compatible with API version 1.3. If you wish to use API version 1.2, please use version 0.3.x or earlier of the SDK. Below are the SDK versions and the corresponding supported API versions.
|
|
25
|
+
|
|
26
|
+
| SDK Version | Supported API Version |
|
|
27
|
+
| ----------- | --------------------- |
|
|
28
|
+
| 0.4.x | 1.3 |
|
|
29
|
+
| 0.3.x | 1.2 |
|
|
30
|
+
|
|
31
|
+
How to install the latest 0.3.x version of the SDK:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install twelvelabs-js@0.3.x
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
How to install the SDK with a specific version:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install twelvelabs-js@0.3.x # replace 0.3.x with the version you want
|
|
41
|
+
```
|
|
42
|
+
|
|
22
43
|
# Initialize the SDK
|
|
23
44
|
|
|
24
45
|
1. Import the required packages into your application:
|
|
@@ -50,39 +71,39 @@ To create an index, use the example code below, replacing '<YOUR_INDEX_NAME>' wi
|
|
|
50
71
|
```js
|
|
51
72
|
let index = await client.index.create({
|
|
52
73
|
name: '<YOUR_INDEX_NAME>',
|
|
53
|
-
|
|
74
|
+
models: [
|
|
54
75
|
{
|
|
55
|
-
name: 'marengo2.
|
|
56
|
-
options: ['visual', '
|
|
76
|
+
name: 'marengo2.7',
|
|
77
|
+
options: ['visual', 'audio'],
|
|
57
78
|
},
|
|
58
79
|
{
|
|
59
80
|
name: 'pegasus1.1',
|
|
60
|
-
options: ['visual', '
|
|
81
|
+
options: ['visual', 'audio'],
|
|
61
82
|
},
|
|
62
83
|
],
|
|
63
84
|
});
|
|
64
85
|
|
|
65
|
-
console.log(`Created index: id=${index.id} name=${index.name}
|
|
86
|
+
console.log(`Created index: id=${index.id} name=${index.name} models=${JSON.stringify(index.models)}`);
|
|
66
87
|
```
|
|
67
88
|
|
|
68
89
|
Note the following about this example:
|
|
69
90
|
|
|
70
|
-
- The platform provides two distinct
|
|
71
|
-
- **Embedding
|
|
72
|
-
- **Generative
|
|
91
|
+
- The platform provides two distinct model types - embedding and generative, each serving unique purposes in multimodal video understanding.
|
|
92
|
+
- **Embedding models (Marengo)**: These models are proficient at performing tasks such as search and classification, enabling enhanced video understanding.
|
|
93
|
+
- **Generative models (Pegasus)**: These models generate text based on your videos.
|
|
73
94
|
For your index, both Marengo and Pegasus are enabled.
|
|
74
|
-
- The `
|
|
75
|
-
- The
|
|
95
|
+
- The `models.options` fields specify the types of information each video understanding model will process. For details, see the [model options](https://docs.twelvelabs.io/v1.3/docs/model-options) page.
|
|
96
|
+
- The models and the model options specified when you create an index apply to all the videos you upload to that index and cannot be changed. For details, see the [model options](https://docs.twelvelabs.io/v1.3/docs/model-options) page.
|
|
76
97
|
|
|
77
98
|
The output should look similar to the following:
|
|
78
99
|
|
|
79
100
|
```
|
|
80
|
-
Created index: id=65e71802bb29f13bdd6f38d8 name=2024-03-05T13:02:57.938Z
|
|
101
|
+
Created index: id=65e71802bb29f13bdd6f38d8 name=2024-03-05T13:02:57.938Z models=[{"name":"pegasus1.1","options":["visual","audio"]},{"name":"marengo2.7","options":["visual","audio"]}]
|
|
81
102
|
```
|
|
82
103
|
|
|
83
104
|
Note that the API returns, among other information, a field named `id`, representing the unique identifier of your new index.
|
|
84
105
|
|
|
85
|
-
For a description of each field in the request and response, see the [Create an index](https://docs.twelvelabs.io/v1.
|
|
106
|
+
For a description of each field in the request and response, see the [Create an index](https://docs.twelvelabs.io/v1.3/reference/create-index) page.
|
|
86
107
|
|
|
87
108
|
## Upload videos
|
|
88
109
|
|
|
@@ -92,7 +113,7 @@ Before you upload a video to the platform, ensure that it meets the following re
|
|
|
92
113
|
- **Video and audio formats**: The video files you wish to upload must be encoded in the video and audio formats listed on the [FFmpeg Formats Documentation](https://ffmpeg.org/ffmpeg-formats.html) page. For videos in other formats, contact us at [support@twelvelabs.io](mailto:support@twelvelabs.io).
|
|
93
114
|
- **Duration**: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 30 minutes (1,800s).
|
|
94
115
|
- **File size**: Must not exceed 2 GB. If you require different options, send us an email at support@twelvelabs.io.
|
|
95
|
-
- **Audio track**: If the `
|
|
116
|
+
- **Audio track**: If the `audio` [model option](https://docs.twelvelabs.io/v1.3/docs/model-options) is selected, the video you're uploading must contain an audio track.
|
|
96
117
|
|
|
97
118
|
To upload videos, use the example code below, replacing the following:
|
|
98
119
|
|
|
@@ -140,7 +161,7 @@ To perform search requests using text queries, use the example code below, repla
|
|
|
140
161
|
|
|
141
162
|
- **`<YOUR_INDEX_ID>`**: with a string representing the unique identifier of your index.
|
|
142
163
|
- **`<YOUR_QUERY>`**: with a string representing your search query. Note that the API supports full natural language-based search. The following examples are valid queries: "birds flying near a castle," "sun shining on water," and "an officer holding a child's hand."
|
|
143
|
-
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual and
|
|
164
|
+
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual and audio cues, use `["visual", "audio"]`. Note that the search options you specify must be a subset of the model options used when you created the index. For more details, see the [Search options](https://docs.twelvelabs.io/docs/search-options) page.
|
|
144
165
|
|
|
145
166
|
```js
|
|
146
167
|
let searchResults = await client.search.query({
|
|
@@ -176,16 +197,15 @@ The results are returned one page at a time, with a default limit of 10 results
|
|
|
176
197
|
Note that the response contains, among other information, the following fields:
|
|
177
198
|
|
|
178
199
|
- `videoId`: The unique identifier of the video that matched your search terms.
|
|
179
|
-
- `score`: A quantitative value determined by the AI
|
|
200
|
+
- `score`: A quantitative value determined by the AI model representing the level of confidence that the results match your search terms.
|
|
180
201
|
- `start`: The start time of the matching video clip, expressed in seconds.
|
|
181
202
|
- `end`: The end time of the matching video clip, expressed in seconds.
|
|
182
203
|
- `confidence`: A qualitative indicator based on the value of the score field. This field can take one of the following values:
|
|
183
204
|
- `high`
|
|
184
205
|
- `medium`
|
|
185
206
|
- `low`
|
|
186
|
-
- `extremely low`
|
|
187
207
|
|
|
188
|
-
For a description of each field in the request and response, see the [Make a search request](https://docs.twelvelabs.io/v1.
|
|
208
|
+
For a description of each field in the request and response, see the [Make a search request](https://docs.twelvelabs.io/v1.3/reference/make-search-request) page.
|
|
189
209
|
|
|
190
210
|
**Search using image queries**
|
|
191
211
|
|
|
@@ -195,7 +215,7 @@ To perform a search request using image queries, use the example code below, rep
|
|
|
195
215
|
|
|
196
216
|
- **`<YOUR_INDEX_ID>`**: with a string representing the unique identifier of your index.
|
|
197
217
|
- **`<YOUR_FILE_PATH>`**: with a string representing the path of the image file you wish to provide.
|
|
198
|
-
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual cues, use `["visual"]`. Note that the search options you specify must be a subset of the
|
|
218
|
+
- **`[<YOUR_SEARCH_OPTIONS>]`**: with an array of strings that specifies the sources of information the platform uses when performing a search. For example, to search based on visual cues, use `["visual"]`. Note that the search options you specify must be a subset of the model options used when you created the index. For more details, see the [Search options](https://docs.twelvelabs.io/docs/search-options) page.
|
|
199
219
|
|
|
200
220
|
```js
|
|
201
221
|
let searchResults = await client.search.query({
|
|
@@ -214,24 +234,10 @@ The Twelve Labs Video Understanding Platform offers three distinct endpoints tai
|
|
|
214
234
|
|
|
215
235
|
Note the following about using these endpoints:
|
|
216
236
|
|
|
217
|
-
- The Pegasus video understanding
|
|
237
|
+
- The Pegasus video understanding model must be enabled for the index to which your video has been uploaded.
|
|
218
238
|
- Your prompts must be instructive or descriptive, and you can also phrase them as questions.
|
|
219
239
|
- The maximum length of a prompt is 1500 characters.
|
|
220
240
|
|
|
221
|
-
#### Topics, titles, and hashtags
|
|
222
|
-
|
|
223
|
-
To generate topics, titles, and hashtags, use the example code below, replacing the following:
|
|
224
|
-
|
|
225
|
-
- **`<YOUR_VIDEO_ID>`**: with a string representing the unique identifier of your video.
|
|
226
|
-
- **`[<TYPES>]`**: with an array of strings representing the type of text the platform should generate. Example: `["title", "topic", "hashtag"]`.
|
|
227
|
-
|
|
228
|
-
```js
|
|
229
|
-
const gist = await client.generate.gist('<YOUR_VIDEO_ID>', ['<TYPES>']);
|
|
230
|
-
console.log(`Title: ${gist.title}\nTopics=${gist.topics}\nHashtags=${gist.hashtags}`);
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
For a description of each field in the request and response, see the [Titles, topics, or hashtags](https://docs.twelvelabs.io/v1.2/reference/generate-gist) page.
|
|
234
|
-
|
|
235
241
|
#### Summaries, chapters, and highlights
|
|
236
242
|
|
|
237
243
|
To generate summaries, chapters, and highlights, use the example code below, replacing the following:
|
|
@@ -245,14 +251,14 @@ const summary = await client.generate.summarize('<YOUR_VIDEO_ID>', '<TYPE>');
|
|
|
245
251
|
console.log(`Summary: ${summary.summary}`);
|
|
246
252
|
```
|
|
247
253
|
|
|
248
|
-
For a description of each field in the request and response, see the [Summaries, chapters, or highlights](https://docs.twelvelabs.io/v1.
|
|
254
|
+
For a description of each field in the request and response, see the [Summaries, chapters, or highlights](https://docs.twelvelabs.io/v1.3/docs/generate-summaries-chapters-highlights) page.
|
|
249
255
|
|
|
250
256
|
#### Open-ended texts
|
|
251
257
|
|
|
252
258
|
To generate open-ended texts, use the example code below, replacing the following:
|
|
253
259
|
|
|
254
260
|
- **`<YOUR_VIDEO_ID>`**: with a string representing the unique identifier of your video.
|
|
255
|
-
- **`<YOUR_PROMPT>`**: with a string that guides the model on the desired format or content. The maximum length of the prompt is 1500 characters. Example:
|
|
261
|
+
- **`<YOUR_PROMPT>`**: with a string that guides the model on the desired format or content. The maximum length of the prompt is 1500 characters. Example: "I want to generate a description for my video with the following format: Title of the video, followed by a summary in 2-3 sentences, highlighting the main topic, key events, and concluding remarks."
|
|
256
262
|
|
|
257
263
|
```js
|
|
258
264
|
const text = await client.generate.text('<YOUR_VIDEO_ID>', '<YOUR_PROMPT>');
|
|
@@ -280,14 +286,14 @@ The following example shows how you can handle specific HTTP errors in your appl
|
|
|
280
286
|
try {
|
|
281
287
|
let index = await client.index.create({
|
|
282
288
|
name: '<YOUR_INDEX_NAME>',
|
|
283
|
-
|
|
289
|
+
models: [
|
|
284
290
|
{
|
|
285
|
-
name: 'marengo2.
|
|
286
|
-
options: ['visual', '
|
|
291
|
+
name: 'marengo2.7',
|
|
292
|
+
options: ['visual', 'audio'],
|
|
287
293
|
},
|
|
288
294
|
],
|
|
289
295
|
});
|
|
290
|
-
console.log(`Created index: id=${index.id} name=${index.name}
|
|
296
|
+
console.log(`Created index: id=${index.id} name=${index.name} models=${JSON.stringify(index.models)}`);
|
|
291
297
|
} catch (e) {
|
|
292
298
|
console.log(e);
|
|
293
299
|
}
|
|
@@ -305,3 +311,4 @@ You can sign your commit automatically with Git by using `git commit -s` if you
|
|
|
305
311
|
We ask that you use your real name (please, no anonymous contributions or pseudonyms). By signing your commitment, you are certifying that you have the right have the right to submit it under the open-source license used by that particular project. You must use your real name (no pseudonyms or anonymous contributions are allowed.)
|
|
306
312
|
We use the Probot DCO GitHub app to check for DCO signoffs of every commit.
|
|
307
313
|
If you forget to sign your commits, the DCO bot will remind you and give you detailed instructions for how to amend your commits to add a signature.
|
|
314
|
+
````
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,8BAA8B,CAAC;AACpD,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,8BAA8B,CAAC;AACpD,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,kBAAkB,SAAS,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LATEST_API_VERSION = exports.API_KEY_HEADER = exports.BASE_URL = void 0;
|
|
4
4
|
exports.BASE_URL = 'https://api.twelvelabs.io';
|
|
5
5
|
exports.API_KEY_HEADER = 'x-api-key';
|
|
6
|
-
exports.
|
|
6
|
+
exports.LATEST_API_VERSION = 'v1.3';
|
|
7
7
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,2BAA2B,CAAC;AACvC,QAAA,cAAc,GAAG,WAAW,CAAC;AAC7B,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,2BAA2B,CAAC;AACvC,QAAA,cAAc,GAAG,WAAW,CAAC;AAC7B,QAAA,kBAAkB,GAAG,MAAM,CAAC"}
|
package/dist/constants.mjs
CHANGED
package/dist/constants.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AACpD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AACpD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,21 +2,19 @@ import { APIClient } from './core';
|
|
|
2
2
|
import * as Resources from './resources';
|
|
3
3
|
export interface ClientOptions {
|
|
4
4
|
apiKey: string;
|
|
5
|
-
version?: 'v1.1' | 'v1.2';
|
|
5
|
+
version?: 'v1.1' | 'v1.2' | 'v1.3';
|
|
6
6
|
}
|
|
7
7
|
export declare class TwelveLabs extends APIClient {
|
|
8
|
-
engine: Resources.Engine;
|
|
9
8
|
index: Resources.Index;
|
|
10
9
|
task: Resources.Task;
|
|
11
10
|
search: Resources.Search;
|
|
12
|
-
classify: Resources.Classify;
|
|
13
11
|
generate: Resources.Generate;
|
|
14
12
|
embed: Resources.Embed;
|
|
15
13
|
baseUrl: string;
|
|
16
14
|
apiKey: string;
|
|
17
15
|
constructor({ apiKey, version }: ClientOptions);
|
|
18
16
|
}
|
|
19
|
-
export {
|
|
20
|
-
export { CreateIndexParams, CreateTaskParams, ListIndexParams, ListTaskParams, RetrieveVideoParams, ListVideoParams, SearchOptions, UpdateVideoParams,
|
|
17
|
+
export { Index, IndexListWithPagination, Video, VideoListWithPagination, Task, TaskListWithPagination, TransferImportResponse, TransferImportStatusResponse, TransferImportLog, TaskStatus, SearchResult, SearchData, GroupByVideoSearchData, GenerateSummarizeResult, GenerateOpenEndedTextResult, EmbeddingsTask, EmbeddingsTaskListWithPagination, EmbeddingsTaskStatus, CreateEmbeddingsResult, Embedding, SegmentEmbedding, PageInfo, } from './models';
|
|
18
|
+
export { CreateIndexParams, CreateTaskParams, ListIndexParams, ListTaskParams, RetrieveVideoParams, ListVideoParams, SearchOptions, UpdateVideoParams, GenerateSummarizeType, CreateEmbedParams, CreateEmbeddingsTaskVideoParams, ListEmbeddingsTaskParams, } from './resources';
|
|
21
19
|
export { TwelveLabsError, APIConnectionError, APITimeoutError, BadRequestError, ConflictError, ForbiddenError, MethodNotAllowedError, NotFoundError, TooManyRequestsError, UnauthorizedError, InternalServerError, } from './error';
|
|
22
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACpC;AAED,qBAAa,UAAW,SAAQ,SAAS;IACvC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC;IAC7B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC;IAEvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;gBAEH,EAAE,MAAM,EAAE,OAA4B,EAAE,EAAE,aAAa;CA0BpE;AAED,OAAO,EACL,KAAK,EACL,uBAAuB,EACvB,KAAK,EACL,uBAAuB,EACvB,IAAI,EACJ,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,cAAc,EACd,gCAAgC,EAChC,oBAAoB,EACpB,sBAAsB,EACtB,SAAS,EACT,gBAAgB,EAChB,QAAQ,GACT,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,12 +23,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.InternalServerError = exports.UnauthorizedError = exports.TooManyRequestsError = exports.NotFoundError = exports.MethodNotAllowedError = exports.ForbiddenError = exports.ConflictError = exports.BadRequestError = exports.APITimeoutError = exports.APIConnectionError = exports.TwelveLabsError = exports.SegmentEmbedding = exports.Embedding = exports.CreateEmbeddingsResult = exports.EmbeddingsTaskStatus = exports.EmbeddingsTaskListWithPagination = exports.EmbeddingsTask = exports.SearchResult = exports.TaskListWithPagination = exports.Task = exports.VideoListWithPagination = exports.Video = exports.IndexListWithPagination = exports.Index = exports.
|
|
26
|
+
exports.InternalServerError = exports.UnauthorizedError = exports.TooManyRequestsError = exports.NotFoundError = exports.MethodNotAllowedError = exports.ForbiddenError = exports.ConflictError = exports.BadRequestError = exports.APITimeoutError = exports.APIConnectionError = exports.TwelveLabsError = exports.SegmentEmbedding = exports.Embedding = exports.CreateEmbeddingsResult = exports.EmbeddingsTaskStatus = exports.EmbeddingsTaskListWithPagination = exports.EmbeddingsTask = exports.SearchResult = exports.TaskListWithPagination = exports.Task = exports.VideoListWithPagination = exports.Video = exports.IndexListWithPagination = exports.Index = exports.TwelveLabs = void 0;
|
|
27
27
|
const core_1 = require("./core.js");
|
|
28
28
|
const Resources = __importStar(require("./resources/index.js"));
|
|
29
29
|
const constants_1 = require("./constants.js");
|
|
30
30
|
class TwelveLabs extends core_1.APIClient {
|
|
31
|
-
constructor({ apiKey, version = constants_1.
|
|
31
|
+
constructor({ apiKey, version = constants_1.LATEST_API_VERSION }) {
|
|
32
|
+
if (version !== constants_1.LATEST_API_VERSION) {
|
|
33
|
+
throw new Error(`[Warning] You manually set the API version to ${version}, but this SDK version is not fully compatible with current API version, please use version 0.3.x or earlier`);
|
|
34
|
+
}
|
|
32
35
|
if (!apiKey) {
|
|
33
36
|
throw new Error('Provide `apiKey` to initialize a client. You can see the API Key in the Dashboard page: https://dashboard.playground.io');
|
|
34
37
|
}
|
|
@@ -37,18 +40,15 @@ class TwelveLabs extends core_1.APIClient {
|
|
|
37
40
|
super({ baseUrl, apiKey });
|
|
38
41
|
this.baseUrl = baseUrl;
|
|
39
42
|
this.apiKey = apiKey;
|
|
40
|
-
this.engine = new Resources.Engine(this);
|
|
41
43
|
this.index = new Resources.Index(this);
|
|
42
44
|
this.task = new Resources.Task(this);
|
|
43
45
|
this.search = new Resources.Search(this);
|
|
44
|
-
this.classify = new Resources.Classify(this);
|
|
45
46
|
this.generate = new Resources.Generate(this);
|
|
46
47
|
this.embed = new Resources.Embed(this);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
exports.TwelveLabs = TwelveLabs;
|
|
50
51
|
var models_1 = require("./models/index.js");
|
|
51
|
-
Object.defineProperty(exports, "Engine", { enumerable: true, get: function () { return models_1.Engine; } });
|
|
52
52
|
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return models_1.Index; } });
|
|
53
53
|
Object.defineProperty(exports, "IndexListWithPagination", { enumerable: true, get: function () { return models_1.IndexListWithPagination; } });
|
|
54
54
|
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return models_1.Video; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAmC;AACnC,gEAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAmC;AACnC,gEAAyC;AACzC,8CAA2D;AAO3D,MAAa,UAAW,SAAQ,gBAAS;IAUvC,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,8BAAkB,EAAiB;QACjE,IAAI,OAAO,KAAK,8BAAkB,EAAE;YAClC,MAAM,IAAI,KAAK,CACb,iDAAiD,OAAO,8GAA8G,CACvK,CAAC;SACH;QACD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CACb,yHAAyH,CAC1H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A,cAAc,OAAA;AACd,8GAAA,qBAAqB,OAAA;AACrB,sGAAA,aAAa,OAAA;AACb,6GAAA,oBAAoB,OAAA;AACpB,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { APIClient } from "./core.mjs";
|
|
2
2
|
import * as Resources from "./resources/index.mjs";
|
|
3
|
-
import { BASE_URL,
|
|
3
|
+
import { BASE_URL, LATEST_API_VERSION } from "./constants.mjs";
|
|
4
4
|
export class TwelveLabs extends APIClient {
|
|
5
|
-
constructor({ apiKey, version =
|
|
5
|
+
constructor({ apiKey, version = LATEST_API_VERSION }) {
|
|
6
|
+
if (version !== LATEST_API_VERSION) {
|
|
7
|
+
throw new Error(`[Warning] You manually set the API version to ${version}, but this SDK version is not fully compatible with current API version, please use version 0.3.x or earlier`);
|
|
8
|
+
}
|
|
6
9
|
if (!apiKey) {
|
|
7
10
|
throw new Error('Provide `apiKey` to initialize a client. You can see the API Key in the Dashboard page: https://dashboard.playground.io');
|
|
8
11
|
}
|
|
@@ -11,15 +14,13 @@ export class TwelveLabs extends APIClient {
|
|
|
11
14
|
super({ baseUrl, apiKey });
|
|
12
15
|
this.baseUrl = baseUrl;
|
|
13
16
|
this.apiKey = apiKey;
|
|
14
|
-
this.engine = new Resources.Engine(this);
|
|
15
17
|
this.index = new Resources.Index(this);
|
|
16
18
|
this.task = new Resources.Task(this);
|
|
17
19
|
this.search = new Resources.Search(this);
|
|
18
|
-
this.classify = new Resources.Classify(this);
|
|
19
20
|
this.generate = new Resources.Generate(this);
|
|
20
21
|
this.embed = new Resources.Embed(this);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
export {
|
|
24
|
+
export { Index, IndexListWithPagination, Video, VideoListWithPagination, Task, TaskListWithPagination, SearchResult, EmbeddingsTask, EmbeddingsTaskListWithPagination, EmbeddingsTaskStatus, CreateEmbeddingsResult, Embedding, SegmentEmbedding, } from "./models/index.mjs";
|
|
24
25
|
export { TwelveLabsError, APIConnectionError, APITimeoutError, BadRequestError, ConflictError, ForbiddenError, MethodNotAllowedError, NotFoundError, TooManyRequestsError, UnauthorizedError, InternalServerError, } from "./error.mjs";
|
|
25
26
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE;OACb,KAAK,SAAS;OACd,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE;OACb,KAAK,SAAS;OACd,EAAE,QAAQ,EAAE,kBAAkB,EAAE;AAOvC,MAAM,OAAO,UAAW,SAAQ,SAAS;IAUvC,YAAY,EAAE,MAAM,EAAE,OAAO,GAAG,kBAAkB,EAAiB;QACjE,IAAI,OAAO,KAAK,kBAAkB,EAAE;YAClC,MAAM,IAAI,KAAK,CACb,iDAAiD,OAAO,8GAA8G,CACvK,CAAC;SACH;QACD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CACb,yHAAyH,CAC1H,CAAC;SACH;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QACtD,MAAM,OAAO,GAAG,GAAG,aAAa,IAAI,QAAQ,IAAI,OAAO,GAAG,CAAC;QAE3D,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF;OAEM,EACL,KAAK,EACL,uBAAuB,EACvB,KAAK,EACL,uBAAuB,EACvB,IAAI,EACJ,sBAAsB,EAKtB,YAAY,EAKZ,cAAc,EACd,gCAAgC,EAChC,oBAAoB,EACpB,sBAAsB,EACtB,SAAS,EACT,gBAAgB,GAEjB;OAiBM,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB"}
|
|
@@ -33,14 +33,14 @@ export declare class SegmentEmbedding {
|
|
|
33
33
|
constructor(data: SegmentEmbeddingResponse);
|
|
34
34
|
}
|
|
35
35
|
export interface CreateEmbeddingsResultResponse {
|
|
36
|
-
|
|
36
|
+
modelName: string;
|
|
37
37
|
textEmbedding?: EmbeddingResponse;
|
|
38
38
|
imageEmbedding?: EmbeddingResponse;
|
|
39
39
|
videoEmbedding?: EmbeddingResponse;
|
|
40
40
|
audioEmbedding?: EmbeddingResponse;
|
|
41
41
|
}
|
|
42
42
|
export declare class CreateEmbeddingsResult {
|
|
43
|
-
|
|
43
|
+
modelName: string;
|
|
44
44
|
textEmbedding?: Embedding;
|
|
45
45
|
imageEmbedding?: Embedding;
|
|
46
46
|
videoEmbedding?: Embedding;
|
|
@@ -49,20 +49,20 @@ export declare class CreateEmbeddingsResult {
|
|
|
49
49
|
}
|
|
50
50
|
export interface EmbeddingsTaskStatusResponse {
|
|
51
51
|
id: string;
|
|
52
|
-
|
|
52
|
+
modelName: string;
|
|
53
53
|
status: string;
|
|
54
54
|
videoEmbedding?: EmbeddingResponse;
|
|
55
55
|
}
|
|
56
56
|
export declare class EmbeddingsTaskStatus {
|
|
57
57
|
id: string;
|
|
58
|
-
|
|
58
|
+
modelName: string;
|
|
59
59
|
status: string;
|
|
60
60
|
videoEmbedding?: Embedding;
|
|
61
61
|
constructor(data: EmbeddingsTaskStatusResponse);
|
|
62
62
|
}
|
|
63
63
|
export interface EmbeddingsTaskResponse {
|
|
64
64
|
id: string;
|
|
65
|
-
|
|
65
|
+
modelName: string;
|
|
66
66
|
status: string;
|
|
67
67
|
videoEmbedding?: EmbeddingResponse;
|
|
68
68
|
createdAt?: string;
|
|
@@ -70,7 +70,7 @@ export interface EmbeddingsTaskResponse {
|
|
|
70
70
|
export declare class EmbeddingsTask {
|
|
71
71
|
private readonly _resource;
|
|
72
72
|
id: string;
|
|
73
|
-
|
|
73
|
+
modelName: string;
|
|
74
74
|
status: string;
|
|
75
75
|
videoEmbedding?: Embedding;
|
|
76
76
|
createdAt?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/embed/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAA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