Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,54 +1,56 @@
|
|
| 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("
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
st.
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
st.
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 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 Script GPT")
|
| 24 |
+
st.caption("π Enter the topic you want for your Youtube Content and get the full script in detail")
|
| 25 |
+
st.caption("Made by Samagra Shrivastava with β₯")
|
| 26 |
+
input_text = st.chat_input("Enter a topic for your YouTube video...")
|
| 27 |
+
|
| 28 |
+
if input_text:
|
| 29 |
+
with st.spinner('Generating title and script β...'):
|
| 30 |
+
title_prompt = title_template(input_text)
|
| 31 |
+
title = generate_response([{"role": "user", "content": title_prompt}])
|
| 32 |
+
|
| 33 |
+
with st.spinner('Searching Wikipedia...'):
|
| 34 |
+
wiki_research = wikipedia_search(input_text)
|
| 35 |
+
|
| 36 |
+
with st.spinner('Generating script...'):
|
| 37 |
+
script_prompt = script_template(title, wiki_research)
|
| 38 |
+
script = generate_response([{"role": "user", "content": script_prompt}])
|
| 39 |
+
|
| 40 |
+
st.subheader("Generated Title π")
|
| 41 |
+
st.write(title)
|
| 42 |
+
|
| 43 |
+
st.subheader("Generated Script π")
|
| 44 |
+
st.write(script)
|
| 45 |
+
|
| 46 |
+
st.subheader("Wikipedia Research π")
|
| 47 |
+
st.write(wiki_research)
|
| 48 |
+
|
| 49 |
+
with st.expander("Title History"):
|
| 50 |
+
st.info(f"Topic: {input_text}\nTitle: {title}")
|
| 51 |
+
|
| 52 |
+
with st.expander("Script History"):
|
| 53 |
+
st.info(script)
|
| 54 |
+
|
| 55 |
+
with st.expander("Wikipedia Research Details"):
|
| 56 |
+
st.info(wiki_research)
|