bizvideoschool commited on
Commit
41ca7d6
·
1 Parent(s): 085d4ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -4,7 +4,7 @@ import os
4
 
5
  openai.api_key = os.environ["OPENAI_API_KEY"]
6
 
7
- messages = [{"role": "system", "content": """Please create engaging and informative video scripts for real
8
  estate agents to use on social media. The target audience is potential homebuyers and sellers.
9
  The tone should be professional and friendly, with a focus on building trust and showcasing the agent's expertise.
10
  Please incorporate a strong call-to-action at the end of each script,
@@ -13,7 +13,7 @@ Write only the words the agent should read into the camera. Once you create the
13
  engaging hooks that could replace the first sentence. Analyze those 5 hooks, pick the best one, and replace the
14
  existing hook in the script you wrote with the new one. Deliver the script with the new hook included."""}]
15
 
16
- def CustomChatGPT(user_input):
17
  messages.append({"role": "user", "content": user_input})
18
  response = openai.ChatCompletion.create(
19
  model = "gpt-3.5-turbo",
@@ -21,10 +21,19 @@ def CustomChatGPT(user_input):
21
  )
22
  ChatGPT_reply = response["choices"][0]["message"]["content"]
23
  messages.append({"role": "assistant", "content": ChatGPT_reply})
24
- return ChatGPT_reply
25
 
26
- demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Real Estate Video Script Writer")
 
 
27
 
28
- demo.launch(inline = False)
29
 
 
 
30
 
 
 
 
 
 
 
4
 
5
  openai.api_key = os.environ["OPENAI_API_KEY"]
6
 
7
+ initial_messages = [{"role": "system", "content": """Please create engaging and informative video scripts for real
8
  estate agents to use on social media. The target audience is potential homebuyers and sellers.
9
  The tone should be professional and friendly, with a focus on building trust and showcasing the agent's expertise.
10
  Please incorporate a strong call-to-action at the end of each script,
 
13
  engaging hooks that could replace the first sentence. Analyze those 5 hooks, pick the best one, and replace the
14
  existing hook in the script you wrote with the new one. Deliver the script with the new hook included."""}]
15
 
16
+ def CustomChatGPT(user_input, messages):
17
  messages.append({"role": "user", "content": user_input})
18
  response = openai.ChatCompletion.create(
19
  model = "gpt-3.5-turbo",
 
21
  )
22
  ChatGPT_reply = response["choices"][0]["message"]["content"]
23
  messages.append({"role": "assistant", "content": ChatGPT_reply})
24
+ return ChatGPT_reply, messages
25
 
26
+ def wrapped_chat_gpt(user_input):
27
+ # Replace the following line with your method to retrieve the messages list for the current user
28
+ messages = initial_messages.copy()
29
 
30
+ reply, updated_messages = CustomChatGPT(user_input, messages)
31
 
32
+ # Replace the following line with your method to store the updated messages list for the current user
33
+ # Store updated_messages
34
 
35
+ return reply
36
+
37
+ demo = gradio.Interface(fn=wrapped_chat_gpt, inputs="text", outputs="text", title="Real Estate Video Script Writer")
38
+
39
+ demo.launch(inline=False)