-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.py
29 lines (21 loc) · 904 Bytes
/
tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import Type
from langchain.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
from services import VideoTranscriberService
class VideoTranscriberInput(BaseModel):
url: str = Field(description="Public video URL")
class VideoTranscriber(BaseTool):
"""Tool that transcribe video or audio on demand"""
name: str = "video_transcription"
description: str = (
"Useful for when you need to transcript a video or audio content."
"Input should be a URL. "
"This returns only the transcription - not the original source data."
)
args_schema: Type[BaseModel] = VideoTranscriberInput
service_klass_wrapper: VideoTranscriberService = Field(
default=VideoTranscriberService
)
def _run(self, url: str, **kwargs) -> str:
"""Use the tool."""
return self.service_klass_wrapper(url=url).run()