Samagra07 commited on
Commit
3d1e037
Β·
verified Β·
1 Parent(s): 114ba1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -54
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("πŸ“ 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)
 
 
 
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)