Skip to content

Commit

Permalink
fix: init
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragts committed Feb 12, 2025
1 parent e6435d8 commit f21b38f
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 2 deletions.
51 changes: 51 additions & 0 deletions cookbook/examples/agents/blog_to_podcast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from agno.agent import Agent
from agno.tools.eleven_labs import ElevenLabsTools
# from agno.storage import SqliteAgentStorage
from agno.tools.firecrawl import FirecrawlTools
from agno.models.openai import OpenAIChat
from agno.tools.browserless import BrowserlessTools
from agno.playground import Playground, serve_playground_app


agent_storage_file: str = "tmp/agents.db"
image_agent_storage_file: str = "tmp/image_agent.db"


blog_to_podcast_agent = Agent(
name="Blog to Podcast Agent",
agent_id="blog_to_podcast_agent",
model=OpenAIChat(id="gpt-4o"),
tools=[
ElevenLabsTools(
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_multilingual_v2",
target_directory="audio_generations",
),
# BrowserlessTools(),
FirecrawlTools(),
],
description="You are an AI agent that can generate audio using the ElevenLabs API.",
instructions=[
"When the user asks you to generate audio, use the `text_to_speech` tool to generate the audio.",
"You'll generate the appropriate prompt to send to the tool to generate audio.",
"You don't need to find the appropriate voice first, I already specified the voice to user."
"Don't return file name or file url in your response or markdown just tell the audio was created successfully.",
"The audio should be long and detailed.",
"You can use the `browserless` tool to scrape the blog post and get the text content.",
],
markdown=True,
debug_mode=True,
add_history_to_messages=True,
# storage=SqliteAgentStorage(
# table_name="audio_agent", db_file=image_agent_storage_file
# ),
)

app = Playground(
agents=[
blog_to_podcast_agent,
]
).get_app(use_async=False)

if __name__ == "__main__":
serve_playground_app("blog_to_podcast:app", reload=True)
1 change: 1 addition & 0 deletions cookbook/playground/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from agno.tools.yfinance import YFinanceTools
from agno.tools.youtube import YouTubeTools


agent_storage_file: str = "tmp/agents.db"
image_agent_storage_file: str = "tmp/image_agent.db"

Expand Down
2 changes: 1 addition & 1 deletion cookbook/tools/elevenlabs_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.eleven_labs import ElevenLabsTools
from agno.tools.eleven_la,bs import ElevenLabsTools

audio_agent = Agent(
model=OpenAIChat(id="gpt-4o"),
Expand Down
35 changes: 35 additions & 0 deletions libs/agno/agno/tools/browserless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import json
from os import getenv
from typing import Optional
import requests
from unstructured.partition.html import partition_html
from agno.tools import Toolkit
from agno.utils.log import logger

class BrowserlessTools(Toolkit):
def __init__(
self,
api_key: Optional[str] = None,
website_url: Optional[str] = None,
):
super().__init__(name="browserless")
self.api_key = api_key or getenv("BROWSERLESS_API_KEY")
if not self.api_key:
logger.error("BROWSERLESS_API_KEY not set. Please set the BROWSERLESS_API_KEY environment variable.")
self.website_url = website_url
self.register(self.scrape_website)

def scrape_website(self, website_url: str) -> str:
"""
Use this function to scrape a website.
"""
url = f"https://chrome.browserless.io/content?token={self.api_key}"
web_url = self.website_url or website_url
if not web_url:
logger.error("Website URL not provided.")
return "Please provide a website URL."
payload = json.dumps({"url": web_url})
headers = {"cache-control": "no-cache", "content-type": "application/json"}
response = requests.request("POST", url, headers=headers, data=payload)
content = partition_html(response.text)
return content
8 changes: 7 additions & 1 deletion libs/agno/agno/tools/firecrawl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json
from os import getenv
from typing import Any, Dict, List, Optional

from agno.tools import Toolkit
from agno.utils.log import logger

try:
from firecrawl import FirecrawlApp
Expand All @@ -20,7 +22,11 @@ def __init__(
):
super().__init__(name="firecrawl_tools")

self.api_key: Optional[str] = api_key
self.api_key = api_key or getenv("FIRECRAWL_API_KEY")
logger.info(f"FIRECRAWL_API_KEY: {self.api_key}")
if not self.api_key:
logger.error("FIRECRAWL_API_KEY not set. Please set the FIRECRAWL_API_KEY environment variable.")

self.formats: Optional[List[str]] = formats
self.limit: int = limit
self.app: FirecrawlApp = FirecrawlApp(api_key=self.api_key)
Expand Down

0 comments on commit f21b38f

Please sign in to comment.