bizvideoschool commited on
Commit
13ad448
·
verified ·
1 Parent(s): 72a3054

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -1,10 +1,12 @@
1
  import openai
2
- import gradio
3
  import os
 
4
  from tenacity import retry, wait_fixed, stop_after_attempt
5
 
 
6
  openai.api_key = os.environ["OPENAI_API_KEY"]
7
 
 
8
  initial_messages = [{"role": "system", "content": """Please act as a marketing expert for real estate agents. Your role is
9
  to generate topic summary ideas for social media videos. Follow these steps in this order:
10
  1. Before you execute any steps, consider the last input from the user as a suggestion for the types of topics you should create if
@@ -27,17 +29,15 @@ def CustomChatGPT(user_input, messages):
27
  messages.append({"role": "assistant", "content": ChatGPT_reply})
28
  return ChatGPT_reply, messages
29
 
30
- def wrapped_chat_gpt(user_input):
31
- # Replace the following line with your method to retrieve the messages list for the current user
32
- messages = initial_messages.copy()
33
-
34
- reply, updated_messages = CustomChatGPT(user_input, messages)
35
-
36
- # Replace the following line with your method to store the updated messages list for the current user
37
- # Store updated_messages
38
 
39
- return reply
 
40
 
41
- demo = gradio.Interface(fn=wrapped_chat_gpt, inputs=gradio.inputs.Textbox(label="Enter a topic"), outputs="text", title="Video Idea Generator")
42
-
43
- demo.launch(inline=False)
 
 
 
1
  import openai
 
2
  import os
3
+ import streamlit as st
4
  from tenacity import retry, wait_fixed, stop_after_attempt
5
 
6
+ # Set OpenAI API key from environment variables
7
  openai.api_key = os.environ["OPENAI_API_KEY"]
8
 
9
+ # Define the initial system message
10
  initial_messages = [{"role": "system", "content": """Please act as a marketing expert for real estate agents. Your role is
11
  to generate topic summary ideas for social media videos. Follow these steps in this order:
12
  1. Before you execute any steps, consider the last input from the user as a suggestion for the types of topics you should create if
 
29
  messages.append({"role": "assistant", "content": ChatGPT_reply})
30
  return ChatGPT_reply, messages
31
 
32
+ # Streamlit app setup
33
+ st.title("Video Idea Generator for Real Estate Agents")
34
+ st.write("Enter a topic suggestion or leave it blank for general video ideas.")
 
 
 
 
 
35
 
36
+ user_input = st.text_input("Enter a topic:")
37
+ generate_button = st.button("Generate Ideas")
38
 
39
+ if generate_button:
40
+ messages = initial_messages.copy()
41
+ reply, _ = CustomChatGPT(user_input, messages)
42
+ st.write("Here are the top video ideas:")
43
+ st.write(reply)