Skip to content

Commit

Permalink
Merge pull request #3 from phidatahq/youtube-agent-phi-1652
Browse files Browse the repository at this point in the history
youtube-agent-phi-1652
  • Loading branch information
ashpreetbedi authored Oct 18, 2024
2 parents e39df1d + 1b0ec03 commit bf542bd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
41 changes: 41 additions & 0 deletions agents/youtube.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import Optional

from phi.agent import Agent
from phi.model.openai import OpenAIChat
from phi.tools.youtube_tools import YouTubeTools

from agents.settings import agent_settings
from phi.storage.agent.postgres import PgAgentStorage

from db.session import db_url

youtube_agent_storage = PgAgentStorage(table_name="finance_agent", db_url=db_url)


def get_youtube_agent(
user_id: Optional[str] = None,
session_id: Optional[str] = None,
debug_mode: bool = False,
) -> Agent:
return Agent(
name="YouTube Agent",
agent_id="youtube-agent",
session_id=session_id,
user_id=user_id,
model=OpenAIChat(
model=agent_settings.gpt_4,
max_tokens=agent_settings.default_max_completion_tokens,
temperature=agent_settings.default_temperature,
),
tools=[YouTubeTools()],
description="You are a YouTube agent. Obtain the captions of a YouTube video and answer questions.",
markdown=True,
add_history_to_messages=True,
num_history_responses=5,
show_tool_calls=True,
add_datetime_to_instructions=True,
storage=youtube_agent_storage,
# Enable monitoring on phidata.app
monitoring=True,
debug_mode=debug_mode,
)
4 changes: 3 additions & 1 deletion api/routes/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from agents.finance import get_finance_agent
from agents.research import get_research_agent
from agents.web_search import get_web_search_agent
from agents.youtube import get_youtube_agent

######################################################
## Router for the agent playground
Expand All @@ -12,9 +13,10 @@
finance_agent = get_finance_agent(debug_mode=True)
research_agent = get_research_agent(debug_mode=True)
web_search_agent = get_web_search_agent(debug_mode=True)
youtube_agent = get_youtube_agent(debug_mode=True)

# Create a playground instance
playground = Playground(agents=[finance_agent, research_agent, web_search_agent])
playground = Playground(agents=[finance_agent, research_agent, web_search_agent, youtube_agent])
# Log the playground endpoint with phidata.app
if getenv("RUNTIME_ENV") == "dev":
playground.create_endpoint("http://localhost:8000")
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies = [
"types-beautifulsoup4",
"types-Pillow",
"yfinance",
"youtube_transcript_api"
]

[build-system]
Expand Down
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ duckdb==1.1.2
duckduckgo-search==6.3.2
email-validator==2.2.0
exa-py==1.4.0
exceptiongroup==1.2.2
fastapi==0.115.2
fastapi-cli==0.0.5
frozendict==2.4.6
Expand All @@ -41,7 +42,7 @@ multitasking==0.0.11
mypy==1.12.0
mypy-extensions==1.0.0
nest-asyncio==1.6.0
numpy==2.1.2
numpy==2.0.2
openai==1.51.2
packaging==24.1
pandas==2.2.3
Expand All @@ -52,8 +53,8 @@ pillow==11.0.0
platformdirs==4.3.6
pluggy==1.5.0
primp==0.6.4
psycopg==3.1.19
psycopg-binary==3.1.19
psycopg==3.1.18
psycopg-binary==3.1.18
pydantic==2.9.2
pydantic-core==2.23.4
pydantic-settings==2.5.2
Expand Down Expand Up @@ -87,10 +88,11 @@ types-html5lib==1.1.11.20240806
types-pillow==10.2.0.20240822
typing-extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
urllib3==1.26.20
uvicorn==0.32.0
uvloop==0.21.0
watchfiles==0.24.0
webencodings==0.5.1
websockets==13.1
yfinance==0.2.44
youtube-transcript-api==0.6.2

0 comments on commit bf542bd

Please sign in to comment.