bizvideoschool commited on
Commit
e49acfc
·
1 Parent(s): 70c9616

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -4,13 +4,13 @@ import os
4
 
5
  openai.api_key = os.environ["OPENAI_API_KEY"]
6
 
7
- messages = [{"role": "system", "content": """Please act as a marketing expert for real estate agents. Your role is
8
  to generate topic summary ideas for social media videos. Follow these steps in this order:
9
  1. Before you execute any steps, consider the last input from the user as a suggestion for the types of topics you should create.
10
  2. Generate 100 ideas for videos a real estate agent should make, and analyze them to choose the 10 most compelling. Do not return all 100 ideas.
11
  3. Return a list of these 10 most compelling ideas."""}]
12
 
13
- def CustomChatGPT(user_input):
14
  messages.append({"role": "user", "content": user_input})
15
  response = openai.ChatCompletion.create(
16
  model = "gpt-3.5-turbo",
@@ -18,10 +18,22 @@ def CustomChatGPT(user_input):
18
  )
19
  ChatGPT_reply = response["choices"][0]["message"]["content"]
20
  messages.append({"role": "assistant", "content": ChatGPT_reply})
21
- return ChatGPT_reply
22
 
23
- demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Video Idea Generator")
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- demo.launch(inline = False)
26
 
27
 
 
4
 
5
  openai.api_key = os.environ["OPENAI_API_KEY"]
6
 
7
+ initial_messages = [{"role": "system", "content": """Please act as a marketing expert for real estate agents. Your role is
8
  to generate topic summary ideas for social media videos. Follow these steps in this order:
9
  1. Before you execute any steps, consider the last input from the user as a suggestion for the types of topics you should create.
10
  2. Generate 100 ideas for videos a real estate agent should make, and analyze them to choose the 10 most compelling. Do not return all 100 ideas.
11
  3. Return a list of these 10 most compelling ideas."""}]
12
 
13
+ def CustomChatGPT(user_input, messages):
14
  messages.append({"role": "user", "content": user_input})
15
  response = openai.ChatCompletion.create(
16
  model = "gpt-3.5-turbo",
 
18
  )
19
  ChatGPT_reply = response["choices"][0]["message"]["content"]
20
  messages.append({"role": "assistant", "content": ChatGPT_reply})
21
+ return ChatGPT_reply, messages
22
 
23
+ def wrapped_chat_gpt(user_input):
24
+ # Replace the following line with your method to retrieve the messages list for the current user
25
+ messages = initial_messages.copy()
26
+
27
+ reply, updated_messages = CustomChatGPT(user_input, messages)
28
+
29
+ # Replace the following line with your method to store the updated messages list for the current user
30
+ # Store updated_messages
31
+
32
+ return reply
33
+
34
+ demo = gradio.Interface(fn=wrapped_chat_gpt, inputs="text", outputs="text", title="Video Idea Generator")
35
+
36
+ demo.launch(inline=False)
37
 
 
38
 
39