MindsDB - The TwelveLabs handler
Summary: The TwelveLabs handler for MindsDB allows you to search and summarize video content directly within MindsDB, streamlining the integration of these features into your applications.
Description: This guide outlines how you can use the handler and how the handler interfaces with the TwelveLabs Video Understanding Platform to combine TwelveLabs’ state-of-the-art foundation models for video understanding with MindsDB’s platform for building customized AI solutions.
Step-by-step guide: Our blog post, Build a Powerful Video Summarization Tool with Twelve Lans, MindsDB, and Slack, walks you through the steps required to configure the TwelveLabs integration in MindsDB, deploy the TwelveLabs model for summarization within MindsDB, and automate the whole flow through a Slack bot that will periodically post the video summarizations as announcements.
GitHub: TwelveLabs Handler.
Use the handler
This section assumes the following:
- You have an API key. To retrieve your API key, go to the API Key page and select the Copy icon to the right of the key to copy it to your clipboard.
- You have a running MindsDB database inside of a Docker container. If not, see the Docker for MindsDB section of the MindsDB documentation
Typically, the steps for using the handler are as follows:
-
Install the required dependencies inside the Docker container:
-
Open the MindsDB SQL Editor.
-
Create an ML engine. Use the
CREATE ML_ENGINE
statement, replacing the placeholders surrounded by<>
with your values:
-
The example below creates an ML engine named
twelve_labs_engine
: -
Create a model. Use the
CREATE_MODEL
statement to create a model. ThePREDICT
clause specifies the name of the column that will contain the results of the task. TheUSING
clause specifies the parameters for the model. The parameters depend on the task you want to perform. The available tasks aresearch
andsummarization
, and the parameters for each task are described in the Creating Models section of the handler’s GitHub Readme file.
The example below creates a model for thesearch
task:The example below creates a model for the
summarization
task: -
(Optional) Check the status of the video indexing process. The TwelveLabs Video Understanding Platform requires some time to index videos. You can search or summarize your videos only after the indexing process is complete. Use the
DESCRIBE
statement to check the status of the indexing process, replacing the placeholder surrounded by<>
with your the name your model:The example below checks the status of a model named
twelve_labs_summarization
:You should see the status as
complete
in theSTATUS
column. In case of an error, check theERROR
column, which contains detailed information about the error. -
Retrieve the identifiers of the indexed videos. Perform this step if you want to summarize a video. To retrieve the identifiers, use the
DESCRIBE
statement on theindexed_videos
table of your model, replacing the placeholder surrounded by<>
with the name of your model:The example below retrieves the identifiers of the videos uploaded to a model named
twelve_labs_summarization
: -
Make predictions. Use the
SELECT
statement to make predictions using the model created in the previous step. TheWHERE
clause specifies the condition for the prediction. The condition depends on the task you want to perform. The available tasks aresearch
andsummarization
, and the conditions for each task are described in the Making Predictions section of the handler’s GitHub Readme file:
The example below performs a search request. Ensure you replace the placeholder surrounded by<>
with your querySearch:
In the SQL query below, ensure you replace the placeholders surrounded by<>
with your values:The example below makes predictions for the search task using a model named
twelve_labs_search
:Summarize:
In the SQL query below, ensure you replace the placeholders surrounded by
<>
with your values:The example below makes predictions for the summarization task using a model named
twelve_labs_summarization
:
Integration with TwelveLabs
For brevity, the sections below outline the key components for integrating MindsDB with the TwelveLabs Video Understanding Platform:
- Initialize a client
- Create indexes
- Upload videos
- Perform downstream tasks such as search or classification.
For all the components, refer to the TwelveLabs Handler page on GitHub.
Initialize a client
The constructor sets up a new TwelveLabsAPIClient
object that establishes a connection to the TwelveLabs Video Understanding Platform:
Create indexes
To create indexes, the create_index
method invokes the POST
method of the /indexes
endpoint:
Upload videos
To upload videos to the TwelveLabs Video Understanding Platform and index them, the handler invokes the POST method of the /tasks
endpoint:
Once the video has been uploaded to the platform, the handler monitors the indexing process using the GET method of the /tasks/{task_id}
endpoint:
Perform downstream tasks
The handler supports the following downstream tasks - search and summarize videos. See the sections below for details.
Search videos
To perform search requests, the handler invokes the POST
method of the /search
endpoint:
Summarize videos
To summarize videos, the handler invokes the POST
method of the summarize
endpoint:
Next steps
After reading this page, you have several options:
- Use the handler: Inspect the TwelveLabs Handler page on GitHub to better understand its features and start using it in your applications.
- Explore further: Try the applications built by the community or our sample applications to get more insights into the TwelveLabs Video Understanding Platform’s diverse capabilities and learn more about integrating the platform into your applications.