Spaces:
Sleeping
Sleeping
File size: 1,945 Bytes
3d1e037 a682e2e 3d1e037 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import streamlit as st
from g4f.client import Client
client = Client()
def generate_response(messages):
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages,
)
return response.choices[0].message.content
def title_template(topic):
return f"Write me a YouTube video title about {topic}"
def script_template(title, wikipedia_search):
return f"Write me a YouTube script based on this title: TITLE: {title} while leveraging this Wikipedia research: {wikipedia_search}."
def wikipedia_search(topic):
search_response = generate_response([{"role": "user", "content": f"Search Wikipedia for {topic} and summarize the information."}])
return search_response
st.title("π₯ YouTube Script GPT")
st.caption("π Enter the topic you want for your Youtube Content and get the full script in detail")
st.caption("Made by Samagra Shrivastava with β₯")
input_text = st.chat_input("Enter a topic for your YouTube video...")
if input_text:
with st.spinner('Generating title and script β...'):
title_prompt = title_template(input_text)
title = generate_response([{"role": "user", "content": title_prompt}])
with st.spinner('Searching Wikipedia...'):
wiki_research = wikipedia_search(input_text)
with st.spinner('Generating script...'):
script_prompt = script_template(title, wiki_research)
script = generate_response([{"role": "user", "content": script_prompt}])
st.subheader("Generated Title π")
st.write(title)
st.subheader("Generated Script π")
st.write(script)
st.subheader("Wikipedia Research π")
st.write(wiki_research)
with st.expander("Title History"):
st.info(f"Topic: {input_text}\nTitle: {title}")
with st.expander("Script History"):
st.info(script)
with st.expander("Wikipedia Research Details"):
st.info(wiki_research)
|