Spaces:
Build error
Build error
Upload 2 files
Browse files- app.py +54 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from g4f.client import Client
|
| 3 |
+
|
| 4 |
+
client = Client()
|
| 5 |
+
|
| 6 |
+
def generate_response(messages):
|
| 7 |
+
response = client.chat.completions.create(
|
| 8 |
+
model="gpt-4o",
|
| 9 |
+
messages=messages,
|
| 10 |
+
)
|
| 11 |
+
return response.choices[0].message.content
|
| 12 |
+
|
| 13 |
+
def title_template(topic):
|
| 14 |
+
return f"Write me a YouTube video title about {topic}"
|
| 15 |
+
|
| 16 |
+
def script_template(title, wikipedia_search):
|
| 17 |
+
return f"Write me a YouTube script based on this title: TITLE: {title} while leveraging this Wikipedia research: {wikipedia_search}."
|
| 18 |
+
|
| 19 |
+
def wikipedia_search(topic):
|
| 20 |
+
search_response = generate_response([{"role": "user", "content": f"Search Wikipedia for {topic} and summarize the information."}])
|
| 21 |
+
return search_response
|
| 22 |
+
|
| 23 |
+
st.title("📝 YouTube GPT")
|
| 24 |
+
input_text = st.chat_input("Enter a topic for your YouTube video...")
|
| 25 |
+
|
| 26 |
+
if input_text:
|
| 27 |
+
with st.spinner('Generating title and script ⌛...'):
|
| 28 |
+
title_prompt = title_template(input_text)
|
| 29 |
+
title = generate_response([{"role": "user", "content": title_prompt}])
|
| 30 |
+
|
| 31 |
+
with st.spinner('Searching Wikipedia...'):
|
| 32 |
+
wiki_research = wikipedia_search(input_text)
|
| 33 |
+
|
| 34 |
+
with st.spinner('Generating script...'):
|
| 35 |
+
script_prompt = script_template(title, wiki_research)
|
| 36 |
+
script = generate_response([{"role": "user", "content": script_prompt}])
|
| 37 |
+
|
| 38 |
+
st.subheader("Generated Title")
|
| 39 |
+
st.write(title)
|
| 40 |
+
|
| 41 |
+
st.subheader("Generated Script")
|
| 42 |
+
st.write(script)
|
| 43 |
+
|
| 44 |
+
st.subheader("Wikipedia Research")
|
| 45 |
+
st.write(wiki_research)
|
| 46 |
+
|
| 47 |
+
with st.expander("Title History"):
|
| 48 |
+
st.info(f"Topic: {input_text}\nTitle: {title}")
|
| 49 |
+
|
| 50 |
+
with st.expander("Script History"):
|
| 51 |
+
st.info(script)
|
| 52 |
+
|
| 53 |
+
with st.expander("Wikipedia Research Details"):
|
| 54 |
+
st.info(wiki_research)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
g4f[all]
|