Joanna30 commited on
Commit
1b5de56
·
verified ·
1 Parent(s): 31b9a3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -9,9 +9,9 @@ load_dotenv()
9
  st.title("YouTube Scriptwriting Tool")
10
  st.header("Generate a video script by specifying a topic, length, and creativity level.")
11
 
12
- # Sidebar to capture API key (use the Google API Key here)
13
  st.sidebar.title("API Configuration")
14
- st.sidebar.text_input("Enter your Google API key:", type="password", key="google_api_key")
15
 
16
  # Main input fields for the video script
17
  prompt = st.text_input("Provide the topic of the video:")
@@ -23,14 +23,17 @@ generate_script_button = st.button("Generate Script")
23
 
24
  # When the button is clicked, the script will be generated
25
  if generate_script_button:
26
- google_api_key = st.session_state.google_api_key
27
- if not google_api_key:
28
- st.error("Please provide a valid Google API key.")
29
  else:
30
  # Generate the script using the utility function
31
- title, script, search_data = generate_script(prompt, video_length, creativity, google_api_key)
32
- st.success("Script generated successfully!")
33
- st.subheader(f"Title: {title}")
34
- st.write(f"Script:\n\n{script}")
35
- with st.expander("Show search data used for the script"):
36
- st.write(search_data)
 
 
 
 
9
  st.title("YouTube Scriptwriting Tool")
10
  st.header("Generate a video script by specifying a topic, length, and creativity level.")
11
 
12
+ # Sidebar to capture API key (use the SerpAPI Key here)
13
  st.sidebar.title("API Configuration")
14
+ st.sidebar.text_input("Enter your SerpAPI key:", type="password", key="serpapi_key")
15
 
16
  # Main input fields for the video script
17
  prompt = st.text_input("Provide the topic of the video:")
 
23
 
24
  # When the button is clicked, the script will be generated
25
  if generate_script_button:
26
+ serpapi_key = st.session_state.serpapi_key
27
+ if not serpapi_key:
28
+ st.error("Please provide a valid SerpAPI key.")
29
  else:
30
  # Generate the script using the utility function
31
+ try:
32
+ title, script, search_data = generate_script(prompt, video_length, creativity, serpapi_key)
33
+ st.success("Script generated successfully!")
34
+ st.subheader(f"Title: {title}")
35
+ st.write(f"Script:\n\n{script}")
36
+ with st.expander("Show search data used for the script"):
37
+ st.write(search_data)
38
+ except Exception as e:
39
+ st.error(f"An error occurred: {e}")