Skip to content

Commit

Permalink
Merge pull request #77 from video-db/minor-fixes
Browse files Browse the repository at this point in the history
Send download link and rename summary agent
  • Loading branch information
ashish-spext authored Nov 25, 2024
2 parents 37b5b59 + 03dc1dc commit a19a014
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.env
.env.backup
venv
.venv
.vscode
Expand Down
30 changes: 25 additions & 5 deletions backend/director/agents/download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from director.agents.base import BaseAgent, AgentResponse, AgentStatus
from director.core.session import Session
from director.core.session import Session, TextContent, MsgStatus
from director.tools.videodb_tool import VideoDBTool

logger = logging.getLogger(__name__)
Expand All @@ -14,9 +14,7 @@ def __init__(self, session: Session, **kwargs):
self.parameters = self.get_parameters()
super().__init__(session=session, **kwargs)

def run(
self, stream_link: str, name: str = None, *args, **kwargs
) -> AgentResponse:
def run(self, stream_link: str, name: str = None, *args, **kwargs) -> AgentResponse:
"""
Downloads the video from the given stream link.
Expand All @@ -30,13 +28,35 @@ def run(
:rtype: AgentResponse
"""
try:
text_content = TextContent(agent_name=self.agent_name)
text_content.status_message = "Downloading.."
self.output_message.content.append(text_content)
self.output_message.push_update()
videodb_tool = VideoDBTool()
download_response = videodb_tool.download(stream_link, name)
if download_response.get("status") == "done":
download_url = download_response.get("download_url")
name = download_response.get("name")
text_content.text = (
f"<a href='{download_url}' target='_blank'>{name}</a>"
)
text_content.status = MsgStatus.success
text_content.status_message = "Here is the download link"
self.output_message.publish()
else:
text_content.status = MsgStatus.error
text_content.status_message = "Download failed"
return AgentResponse(
status=AgentStatus.ERROR,
message=f"Downloda failed with {download_response}",
)
except Exception as e:
text_content.status = MsgStatus.error
text_content.status_message = "Download failed"
logger.exception(f"error in {self.agent_name} agent: {e}")
return AgentResponse(status=AgentStatus.ERROR, message=str(e))
return AgentResponse(
status=AgentStatus.SUCCESS,
message="Download successful but not dispalyed, send it in the summary.",
message="Download successful.",
data=download_response,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
logger = logging.getLogger(__name__)


class VideoSummaryAgent(BaseAgent):
class SummarizeVideoAgent(BaseAgent):
def __init__(self, session=None, **kwargs):
self.agent_name = "video_summary"
self.agent_name = "summarize_video"
self.description = "This is an agent to summarize the given video of VideoDB, if the user wants a certain kind of summary the prompt is required."
self.llm = get_default_llm()
self.parameters = self.get_parameters()
Expand Down
6 changes: 2 additions & 4 deletions backend/director/handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
import logging

from dotenv import dotenv_values

from director.agents.thumbnail import ThumbnailAgent
from director.agents.video_summary import VideoSummaryAgent
from director.agents.summarize_video import SummarizeVideoAgent
from director.agents.download import DownloadAgent
from director.agents.pricing import PricingAgent
from director.agents.upload import UploadAgent
Expand Down Expand Up @@ -38,7 +36,7 @@ def __init__(self, db, **kwargs):
# Register the agents here
self.agents = [
ThumbnailAgent,
VideoSummaryAgent,
SummarizeVideoAgent,
DownloadAgent,
PricingAgent,
UploadAgent,
Expand Down

0 comments on commit a19a014

Please sign in to comment.