-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters