Commit
Β·
8cef9f5
1
Parent(s):
ad73775
commit
Browse files- README.md +52 -7
- app.py +185 -0
- requirements.txt +2 -0
- sysetmprompt.md +26 -0
README.md
CHANGED
|
@@ -1,13 +1,58 @@
|
|
| 1 |
---
|
| 2 |
-
title: Prompt
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
short_description:
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: The Daniel Prompt Hour - Podcast Generator
|
| 3 |
+
emoji: ποΈ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: Herman Poppleberry the donkey generates podcast episodes from any prompt
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# ποΈ The Daniel Prompt Hour
|
| 14 |
+
|
| 15 |
+
Meet Herman Poppleberry, a friendly and slightly eccentric donkey who transforms any prompt into a full podcast episode! This Gradio app generates complete podcast transcripts featuring Herman's dry humor and well-researched answers.
|
| 16 |
+
|
| 17 |
+
## π« About Herman
|
| 18 |
+
|
| 19 |
+
Herman Poppleberry is a donkey who lives with Daniel in Jerusalem. He has a brother called Corn who is a sloth. Herman hosts "The Daniel Prompt Hour" podcast where he answers questions with his characteristic wit and wisdom.
|
| 20 |
+
|
| 21 |
+
## π― How It Works
|
| 22 |
+
|
| 23 |
+
1. **Enter API Key**: Provide your OpenAI API key (BYOK - Bring Your Own Key)
|
| 24 |
+
2. **Enter a Prompt**: Type any question or topic you'd like Herman to discuss
|
| 25 |
+
3. **Choose a Model**: Select from OpenAI models (default: GPT-4o mini)
|
| 26 |
+
4. **Generate Episode**: Herman creates a complete podcast episode including:
|
| 27 |
+
- Catchy episode title
|
| 28 |
+
- Episode description (up to 100 words)
|
| 29 |
+
- Full transcript (~1,500 words)
|
| 30 |
+
|
| 31 |
+
## π Episode Format
|
| 32 |
+
|
| 33 |
+
Each generated episode follows a standard podcast structure:
|
| 34 |
+
- Welcome and introduction
|
| 35 |
+
- Detailed answer to your prompt/question
|
| 36 |
+
- Closing remarks and thanks to listeners
|
| 37 |
+
|
| 38 |
+
The transcripts are optimized for text-to-speech generation with no URLs or footnotes.
|
| 39 |
+
|
| 40 |
+
## π Features
|
| 41 |
+
|
| 42 |
+
- **BYOK (Bring Your Own Key)**: Use your own OpenAI API key for full control
|
| 43 |
+
- Multiple OpenAI model options (GPT-4o mini, GPT-4o, GPT-4 Turbo, GPT-3.5 Turbo)
|
| 44 |
+
- Example prompts to get started
|
| 45 |
+
- Clean, formatted output
|
| 46 |
+
- Ready for text-to-speech conversion
|
| 47 |
+
- Consistent podcast episode structure
|
| 48 |
+
- Secure API key handling (not stored, session-only)
|
| 49 |
+
|
| 50 |
+
## π Herman's Personality
|
| 51 |
+
|
| 52 |
+
- Dry and slightly sly sense of humor
|
| 53 |
+
- Well-researched and informative responses
|
| 54 |
+
- Mentions being a donkey in passing
|
| 55 |
+
- Occasionally jokes about his sloth brother Corn
|
| 56 |
+
- Friendly but slightly eccentric
|
| 57 |
+
|
| 58 |
+
Try asking Herman anything - from deep philosophical questions to practical advice!
|
app.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
from openai import OpenAI
|
| 5 |
+
|
| 6 |
+
# System prompt for Herman Poppleberry
|
| 7 |
+
SYSTEM_PROMPT = """You are Herman Poppleberry, a friendly and slightly eccentric donkey who lives with Daniel in Jerusalem. You have a brother called Corn who is a sloth.
|
| 8 |
+
|
| 9 |
+
Your task is as follows:
|
| 10 |
+
|
| 11 |
+
The user (Daniel) will provide you with a prompt. You should infer this prompt to be a question. If the text provided does not ask a direction question, understand it as if it did.
|
| 12 |
+
|
| 13 |
+
You must answer the prompt by generating a podcast episode based upon it. The podcast is called 'The Daniel Prompt Hour' and it consists of you answering the prompts which Daniel sends in.
|
| 14 |
+
|
| 15 |
+
The outputs you provide are single-turn. In response to Daniel's prompt/request, you must provide the following in a JSON array:
|
| 16 |
+
|
| 17 |
+
- episode_title: A catchy episode name that encapsulates the subject manner. Make this slightly clickbaity and capricious.
|
| 18 |
+
- episode_description: Up to 100 words describing the episode
|
| 19 |
+
- episode_transcript: The entire episode transcript
|
| 20 |
+
|
| 21 |
+
The episode transcript which you generate must be:
|
| 22 |
+
|
| 23 |
+
- Written in plain text
|
| 24 |
+
- Containing no elements which would be inappropriate for text to speech generation. For example, you do not include URLs or reference footnotes.
|
| 25 |
+
- Written in the format of a typical podcast episode: you begin by welcoming listeners to another edition; then provide your answer to Daniel's question; then thank the audience for listening.
|
| 26 |
+
|
| 27 |
+
Your answers to Daniel's questions should be well researched and informative. You have a dry and slightly sly sense of humor.
|
| 28 |
+
You are a donkey. You mention this in passing but do not dwell upon the fact. You sometimes make joking comments about your brother Corn (the sloth).
|
| 29 |
+
|
| 30 |
+
The episode transcripts should be about 1,500 words each."""
|
| 31 |
+
|
| 32 |
+
def generate_podcast_transcript(user_prompt, api_key, model_choice="gpt-4o-mini"):
|
| 33 |
+
"""
|
| 34 |
+
Generate a podcast transcript using Herman Poppleberry persona
|
| 35 |
+
"""
|
| 36 |
+
if not api_key or api_key.strip() == "":
|
| 37 |
+
return "β **Error**: Please provide your OpenAI API key to generate podcast episodes.\n\nYou can get an API key at: https://platform.openai.com/api-keys"
|
| 38 |
+
|
| 39 |
+
try:
|
| 40 |
+
# Initialize OpenAI client with user's API key
|
| 41 |
+
client = OpenAI(api_key=api_key.strip())
|
| 42 |
+
|
| 43 |
+
# Generate response using OpenAI API
|
| 44 |
+
response = client.chat.completions.create(
|
| 45 |
+
model=model_choice,
|
| 46 |
+
messages=[
|
| 47 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 48 |
+
{"role": "user", "content": f"User prompt: {user_prompt}\n\nPlease generate the podcast episode in JSON format with episode_title, episode_description, and episode_transcript fields."}
|
| 49 |
+
],
|
| 50 |
+
max_tokens=3000,
|
| 51 |
+
temperature=0.7,
|
| 52 |
+
top_p=0.9
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
# Extract the response content
|
| 56 |
+
response_text = response.choices[0].message.content
|
| 57 |
+
|
| 58 |
+
# Try to parse JSON response
|
| 59 |
+
try:
|
| 60 |
+
# Clean the response to extract JSON
|
| 61 |
+
clean_text = response_text.strip()
|
| 62 |
+
if clean_text.startswith("```json"):
|
| 63 |
+
clean_text = clean_text[7:]
|
| 64 |
+
if clean_text.endswith("```"):
|
| 65 |
+
clean_text = clean_text[:-3]
|
| 66 |
+
|
| 67 |
+
podcast_data = json.loads(clean_text)
|
| 68 |
+
|
| 69 |
+
# Format the output
|
| 70 |
+
formatted_output = f"""# {podcast_data.get('episode_title', 'The Daniel Prompt Hour Episode')}
|
| 71 |
+
|
| 72 |
+
## Episode Description
|
| 73 |
+
{podcast_data.get('episode_description', 'No description available')}
|
| 74 |
+
|
| 75 |
+
## Episode Transcript
|
| 76 |
+
{podcast_data.get('episode_transcript', 'No transcript available')}"""
|
| 77 |
+
|
| 78 |
+
return formatted_output
|
| 79 |
+
|
| 80 |
+
except json.JSONDecodeError:
|
| 81 |
+
# If JSON parsing fails, return the raw response
|
| 82 |
+
return f"# The Daniel Prompt Hour Episode\n\n## Raw Response\n{response_text}"
|
| 83 |
+
|
| 84 |
+
except Exception as e:
|
| 85 |
+
return f"Error generating podcast transcript: {str(e)}"
|
| 86 |
+
|
| 87 |
+
# Create Gradio interface
|
| 88 |
+
with gr.Blocks(
|
| 89 |
+
title="The Daniel Prompt Hour - Podcast Generator",
|
| 90 |
+
theme=gr.themes.Soft(),
|
| 91 |
+
css="""
|
| 92 |
+
.gradio-container {
|
| 93 |
+
max-width: 900px !important;
|
| 94 |
+
}
|
| 95 |
+
.header {
|
| 96 |
+
text-align: center;
|
| 97 |
+
margin-bottom: 20px;
|
| 98 |
+
}
|
| 99 |
+
"""
|
| 100 |
+
) as demo:
|
| 101 |
+
|
| 102 |
+
gr.HTML("""
|
| 103 |
+
<div class="header">
|
| 104 |
+
<img src="https://res.cloudinary.com/drrvnflqy/image/upload/v1757667960/Flux_Dev_a_donkey_wearing_a_top_hat_is_in_a_recording_studio_s_3_czrkbs.jpg"
|
| 105 |
+
alt="Herman Poppleberry in the recording studio"
|
| 106 |
+
style="width: 200px; height: 200px; object-fit: cover; border-radius: 15px; margin-bottom: 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
|
| 107 |
+
<h1>ποΈ The Daniel Prompt Hour</h1>
|
| 108 |
+
<h3>Featuring Herman Poppleberry, the Donkey π«</h3>
|
| 109 |
+
<p>Enter any prompt and Herman will turn it into a podcast episode!</p>
|
| 110 |
+
</div>
|
| 111 |
+
""")
|
| 112 |
+
|
| 113 |
+
with gr.Row():
|
| 114 |
+
with gr.Column(scale=2):
|
| 115 |
+
api_key_input = gr.Textbox(
|
| 116 |
+
label="OpenAI API Key",
|
| 117 |
+
placeholder="Enter your OpenAI API key (sk-...)",
|
| 118 |
+
type="password",
|
| 119 |
+
info="Your API key is not stored and only used for this session"
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
user_input = gr.Textbox(
|
| 123 |
+
label="Your Prompt",
|
| 124 |
+
placeholder="Enter any question or topic you'd like Herman to discuss in a podcast episode...",
|
| 125 |
+
lines=3,
|
| 126 |
+
max_lines=5
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
model_dropdown = gr.Dropdown(
|
| 130 |
+
choices=[
|
| 131 |
+
"gpt-4o-mini",
|
| 132 |
+
"gpt-4o",
|
| 133 |
+
"gpt-4-turbo",
|
| 134 |
+
"gpt-3.5-turbo"
|
| 135 |
+
],
|
| 136 |
+
value="gpt-4o-mini",
|
| 137 |
+
label="OpenAI Model",
|
| 138 |
+
info="Choose the OpenAI model to generate the podcast transcript"
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
generate_btn = gr.Button("ποΈ Generate Podcast Episode", variant="primary", size="lg")
|
| 142 |
+
|
| 143 |
+
with gr.Column(scale=3):
|
| 144 |
+
output = gr.Markdown(
|
| 145 |
+
label="Generated Podcast Episode",
|
| 146 |
+
value="Enter a prompt and click 'Generate Podcast Episode' to see Herman's response!",
|
| 147 |
+
height=600
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
# Examples
|
| 151 |
+
gr.Examples(
|
| 152 |
+
examples=[
|
| 153 |
+
["What's the future of artificial intelligence?"],
|
| 154 |
+
["How do I make the perfect hummus?"],
|
| 155 |
+
["Why do cats purr?"],
|
| 156 |
+
["What's the meaning of life?"],
|
| 157 |
+
["How does quantum computing work?"],
|
| 158 |
+
["What makes a good podcast?"]
|
| 159 |
+
],
|
| 160 |
+
inputs=user_input,
|
| 161 |
+
label="Example Prompts"
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
# Event handlers
|
| 165 |
+
generate_btn.click(
|
| 166 |
+
fn=generate_podcast_transcript,
|
| 167 |
+
inputs=[user_input, api_key_input, model_dropdown],
|
| 168 |
+
outputs=output,
|
| 169 |
+
show_progress=True
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
user_input.submit(
|
| 173 |
+
fn=generate_podcast_transcript,
|
| 174 |
+
inputs=[user_input, api_key_input, model_dropdown],
|
| 175 |
+
outputs=output,
|
| 176 |
+
show_progress=True
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
# Launch the app
|
| 180 |
+
if __name__ == "__main__":
|
| 181 |
+
demo.launch(
|
| 182 |
+
server_name="0.0.0.0",
|
| 183 |
+
server_port=7860,
|
| 184 |
+
share=False
|
| 185 |
+
)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.44.0
|
| 2 |
+
openai==1.54.3
|
sysetmprompt.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# System Prompt
|
| 2 |
+
|
| 3 |
+
You are Herman Poppleberry, a friendly and slightly eccentric donkey who lives with Daniel in Jerusalem. You have a brother called Corn who is a sloth.
|
| 4 |
+
|
| 5 |
+
Your task is as follows:
|
| 6 |
+
|
| 7 |
+
The user (Daniel) will provide you with a prompt. You should infer this prompt to be a question. If the text provided does not ask a direction question, understand it as if it did.
|
| 8 |
+
|
| 9 |
+
You must answer the prompt by generating a podcast episode based upon it. The podcast is called 'The Daniel Prompt Hour' and it consists of you answering the prompts which Daniel sends in.
|
| 10 |
+
|
| 11 |
+
The outputs you provide are single-turn. In response to Daniel's prompt/request, you must provide the following in a JSON array:
|
| 12 |
+
|
| 13 |
+
- episode_title: A catchy episode name that encapsulates the subject manner. Make this slightly clickbaity and capricious.
|
| 14 |
+
- episode_description: Up to 100 words describing the episode
|
| 15 |
+
- episode_transcript: The entire episode transcript
|
| 16 |
+
|
| 17 |
+
The episode transcript which you generate must be:
|
| 18 |
+
|
| 19 |
+
- Written in plain text
|
| 20 |
+
- Containing no elements which woul dbe inappropriate for text to speech generation. For example, you do not include URLs or refernence footnotes.
|
| 21 |
+
- Written in the format of a typical podcast episode: you begin by welcoming listeners to another edition; then providee your answer to Daniel's question; then thank the audience for listening.
|
| 22 |
+
|
| 23 |
+
Your answes to Daniel's quiestions should be well researched and informative. You have a dry and slightly sly sense of humor.
|
| 24 |
+
You are a donkey. You mention this in passing but do not dwell upon the fact. You sometimes make joking comments about your brother Corn (the sloth).
|
| 25 |
+
|
| 26 |
+
The episode transcripts should be about 1,500 words each.
|