Skip to content

feat: Add Twelve Labs Video tools #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wbrennan899
Copy link

Description

Added two new video analysis tools using TwelveLabs' AI models:

  1. search_video: Semantic video search using TwelveLabs' Marengo model for natural language queries against video content
  2. chat_video: Interactive video analysis using TwelveLabs' Pegasus model for Q&A about video content

Both tools support multi-modal analysis (visual and audio), with chat_video offering video upload capabilities and caching.

Related Issues

Documentation PR

Documentation PR not made

Type of Change

  • Bug fix
  • New Tool
  • Breaking change
  • Other (please describe):

Testing

Comprehensive testing implemented for both video tools:

  • Added test suites covering success cases, error handling, and edge cases
  • Mock TwelveLabs API interactions for reliable testing
  • Video upload caching functionality tested
  • All video tool tests pass consistently (20/20)
  • hatch fmt --linter ✅ (line length issues resolved)
  • hatch fmt --formatter
  • hatch test --all ✅ (All tests passing - 20/20 video tool tests now pass)

Checklist

  • I have read the CONTRIBUTING document

  • I have added tests that prove my fix is effective or my feature works

  • I have updated the documentation accordingly

  • I have added an appropriate example to the documentation to outline the feature

  • My changes generate no new warnings

  • Any dependent changes have been merged and published

  • By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@wbrennan899 wbrennan899 requested a review from a team as a code owner July 3, 2025 21:39
@jer96
Copy link
Member

jer96 commented Jul 9, 2025

hi @wbrennan899 thank you for the contribution. can you please rebase the PR? also regarding testing do you have any details you can share about testing outside of unit tests that you've done?

@jer96
Copy link
Member

jer96 commented Jul 11, 2025

hi @wbrennan899 following up once more as i've been able to pull down the code and run a couple tests.

i can't seem to get the basic functionality working when following the instructions in this PR.

for example:

(with TWELVELABS_API_KEY set to a valid api key)

import uuid

from strands import Agent

from strands_tools import chat_video

agent = Agent(tools=[chat_video])
result = agent.tool.chat_video(
    prompt="Describe what happens in this video",
    video_path="/Users/jerebill/Desktop/test.mp4",
    index_id=str(uuid.uuid4()),
)
print(result)
{'toolUseId': 'tooluse_chat_video_674640038', 'status': 'error', 'content': [{'text': "Error chatting with video: Error code: 400 - {'code': 'parameter_invalid', 'message': 'The index_id parameter is invalid. 6c587d27-1355-4d60-a32f-721f65f4c67e is not a valid id type'}\n\nMake sure the index_id is valid and you have access to it. For video uploads, index_id is required."}]}

i've also tested with the index_id as a fixed string and the same error arises. can you please advise on the correct way to interact with the twelve labs API? i believe the tool will require modification to function correctly.

@wbrennan899
Copy link
Author

@jer96 Your example looks good. You need to create a pegasus index on the twelve labs dashboard (https://playground.twelvelabs.io/indexes) and use that as your index_id.

I have a python script I used to test all the functionality. Would you like me to add that in a comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants