Merge pull request #187 from priyanshm07/main

Added new demos
This commit is contained in:
Shubham Saboo 2025-04-17 09:40:40 -05:00 committed by GitHub
commit c04de2fa3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 289 additions and 0 deletions

View file

@ -0,0 +1,52 @@
## 📰 ➡️ 🎙️ Blog to Podcast Agent
This is a Streamlit-based application that allows users to convert any blog post into a podcast. The app uses OpenAI's GPT-4 model for summarization, Firecrawl for scraping blog content, and ElevenLabs API for generating audio. Users simply input a blog URL, and the app will generate a podcast episode based on the blog.
## Features
- **Blog Scraping**: Scrapes the full content of any public blog URL using Firecrawl API.
- **Summary Generation**: Creates an engaging and concise summary of the blog (within 2000 characters) using OpenAI GPT-4.
- **Podcast Generation**: Converts the summary into an audio podcast using the ElevenLabs voice API.
- **API Key Integration**: Requires OpenAI, Firecrawl, and ElevenLabs API keys to function, entered securely via the sidebar.
## Setup
### Requirements
1. **API Keys**:
- **OpenAI API Key**: Sign up at OpenAI to obtain your API key.
- **ElevenLabs API Key**: Get your ElevenLabs API key from ElevenLabs.
- **Firecrawl API Key**: Get your Firecrawl API key from Firecrawl.
2. **Python 3.8+**: Ensure you have Python 3.8 or higher installed.
### Installation
1. Clone this repository:
```bash
git clone https://github.com/Shubhamsaboo/awesome-llm-apps
cd ai_agent_tutorials/ai_blog_to_podcast_agent
```
2. Install the required Python packages:
```bash
pip install -r requirements.txt
```
### Running the App
1. Start the Streamlit app:
```bash
streamlit run blog_to_podcast_agent.py
```
2. In the app interface:
- Enter your OpenAI, ElevenLabs, and Firecrawl API keys in the sidebar.
- Input the blog URL you want to convert.
- Click "🎙️ Generate Podcast".
- Listen to the generated podcast or download it.

View file

@ -0,0 +1,100 @@
import os
from uuid import uuid4
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.eleven_labs import ElevenLabsTools
from agno.tools.firecrawl import FirecrawlTools
from agno.agent import Agent, RunResponse
from agno.utils.audio import write_audio_to_file
from agno.utils.log import logger
import streamlit as st
# Streamlit Page Setup
st.set_page_config(page_title="📰 ➡️ 🎙️ Blog to Podcast Agent", page_icon="🎙️")
st.title("📰 ➡️ 🎙️ Blog to Podcast Agent")
# Sidebar: API Keys
st.sidebar.header("🔑 API Keys")
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
elevenlabs_api_key = st.sidebar.text_input("ElevenLabs API Key", type="password")
firecrawl_api_key = st.sidebar.text_input("Firecrawl API Key", type="password")
# Check if all keys are provided
keys_provided = all([openai_api_key, elevenlabs_api_key, firecrawl_api_key])
# Input: Blog URL
url = st.text_input("Enter the Blog URL:", "")
# Button: Generate Podcast
generate_button = st.button("🎙️ Generate Podcast", disabled=not keys_provided)
if not keys_provided:
st.warning("Please enter all required API keys to enable podcast generation.")
if generate_button:
if url.strip() == "":
st.warning("Please enter a blog URL first.")
else:
# Set API keys as environment variables for Agno and Tools
os.environ["OPENAI_API_KEY"] = openai_api_key
os.environ["ELEVENLABS_API_KEY"] = elevenlabs_api_key
os.environ["FIRECRAWL_API_KEY"] = firecrawl_api_key
with st.spinner("Processing... Scraping blog, summarizing and generating podcast 🎶"):
try:
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",
),
FirecrawlTools(),
],
description="You are an AI agent that can generate audio using the ElevenLabs API.",
instructions=[
"When the user provides a blog URL:",
"1. Use FirecrawlTools to scrape the blog content",
"2. Create a concise summary of the blog content that is NO MORE than 2000 characters long",
"3. The summary should capture the main points while being engaging and conversational",
"4. Use the ElevenLabsTools to convert the summary to audio",
"Ensure the summary is within the 2000 character limit to avoid ElevenLabs API limits",
],
markdown=True,
debug_mode=True,
)
podcast: RunResponse = blog_to_podcast_agent.run(
f"Convert the blog content to a podcast: {url}"
)
save_dir = "audio_generations"
os.makedirs(save_dir, exist_ok=True)
if podcast.audio and len(podcast.audio) > 0:
filename = f"{save_dir}/podcast_{uuid4()}.wav"
write_audio_to_file(
audio=podcast.audio[0].base64_audio,
filename=filename
)
st.success("Podcast generated successfully! 🎧")
audio_bytes = open(filename, "rb").read()
st.audio(audio_bytes, format="audio/wav")
st.download_button(
label="Download Podcast",
data=audio_bytes,
file_name="generated_podcast.wav",
mime="audio/wav"
)
else:
st.error("No audio was generated. Please try again.")
except Exception as e:
st.error(f"An error occurred: {e}")
logger.error(f"Streamlit app error: {e}")

View file

@ -0,0 +1,6 @@
agno==1.2.8
streamlit==1.44.1
openai
Requests
firecrawl-py
elevenlabs

View file

@ -0,0 +1,43 @@
## ModelsLab Music Generator
This is a Streamlit-based application that allows users to generate music using the ModelsLab API and OpenAI's GPT-4 model. Users can input a prompt describing the type of music they want to generate, and the application will generate a music track in MP3 format based on the given prompt.
## Features
- **Generate Music**: Enter a detailed prompt for music generation (genre, instruments, mood, etc.), and the app will generate a music track.
- **MP3 Output**: The generated music will be in MP3 format, available for listening or download.
- **User-Friendly Interface**: Simple and clean Streamlit UI for ease of use.
- **API Key Integration**: Requires both OpenAI and ModelsLab API keys to function. API keys are entered in the sidebar for authentication.
## Setup
### Requirements
1. **API Keys**:
- **OpenAI API Key**: Sign up at [OpenAI](https://platform.openai.com/api-keys) to obtain your API key.
- **ModelsLab API Key**: Sign up at [ModelsLab](https://modelslab.com/dashboard/api-keys) to get your API key.
2. **Python 3.8+**: Ensure you have Python 3.8 or higher installed.
### Installation
1. Clone this repository:
```bash
git clone https://github.com/Shubhamsaboo/awesome-llm-apps
cd ai_agent_tutorials/ai_models_lab_music_generator_agent
```
2. Install the required Python packages:
```bash
pip install -r requirements.txt
```
### Running the App
1. Start the Streamlit app:
```bash
streamlit run models_lab_music_generator_agent.py
```
2. In the app interface:
- Enter a music generation prompt
- Click "Generate Music"
- Play the music & Download it.

View file

@ -0,0 +1,85 @@
import os
from uuid import uuid4
import requests
from agno.agent import Agent, RunResponse
from agno.models.openai import OpenAIChat
from agno.tools.models_labs import FileType, ModelsLabTools
from agno.utils.log import logger
import streamlit as st
# Sidebar: User enters the API keys
st.sidebar.title("API Key Configuration")
openai_api_key = st.sidebar.text_input("Enter your OpenAI API Key", type="password")
models_lab_api_key = st.sidebar.text_input("Enter your ModelsLab API Key", type="password")
# Streamlit App UI
st.title("🎶 ModelsLab Music Generator")
prompt = st.text_area("Enter a music generation prompt:", "Generate a 30 second classical music piece", height=100)
# Initialize agent only if both API keys are provided
if openai_api_key and models_lab_api_key:
agent = Agent(
name="ModelsLab Music Agent",
agent_id="ml_music_agent",
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key), # Pass OpenAI API key here
show_tool_calls=True,
tools=[ModelsLabTools(api_key=models_lab_api_key, wait_for_completion=True, file_type=FileType.MP3)], # Pass ModelsLab API key here
description="You are an AI agent that can generate music using the ModelsLabs API.",
instructions=[
"When generating music, use the `generate_media` tool with detailed prompts that specify:",
"- The genre and style of music (e.g., classical, jazz, electronic)",
"- The instruments and sounds to include",
"- The tempo, mood and emotional qualities",
"- The structure (intro, verses, chorus, bridge, etc.)",
"Create rich, descriptive prompts that capture the desired musical elements.",
"Focus on generating high-quality, complete instrumental pieces.",
],
markdown=True,
debug_mode=True,
)
# Disable the button if either API key is missing
disable_button = not openai_api_key or not models_lab_api_key
if st.button("Generate Music", disabled=disable_button):
if prompt.strip() == "":
st.warning("Please enter a prompt first.")
else:
with st.spinner("Generating music... 🎵"):
try:
music: RunResponse = agent.run(prompt)
if music.audio and len(music.audio) > 0:
save_dir = "audio_generations"
os.makedirs(save_dir, exist_ok=True)
# Download the generated audio
url = music.audio[0].url
response = requests.get(url)
filename = f"{save_dir}/music_{uuid4()}.mp3"
with open(filename, "wb") as f:
f.write(response.content)
# Streamlit audio player
st.success("Music generated successfully! 🎶")
audio_bytes = open(filename, "rb").read()
st.audio(audio_bytes, format="audio/mp3")
# Optional download button
st.download_button(
label="Download Music",
data=audio_bytes,
file_name="generated_music.mp3",
mime="audio/mp3"
)
else:
st.error("No audio generated. Please try again.")
except Exception as e:
st.error(f"An error occurred: {e}")
logger.error(f"Streamlit app error: {e}")
else:
# Show warning if keys are not entered
st.sidebar.warning("Please enter both the OpenAI and ModelsLab API keys to use the app.")

View file

@ -0,0 +1,3 @@
agno==1.2.8
Requests==2.32.3
streamlit==1.44.1