File size: 1,550 Bytes
f921a22
70c9616
a30f3f0
f921a22
 
 
e49acfc
ce76762
b782e95
bea5dd3
1e0735a
f921a22
e49acfc
f921a22
 
 
 
 
 
 
e49acfc
f921a22
e49acfc
 
 
 
 
 
 
 
 
 
 
 
 
 
f921a22
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import openai
import gradio
import os

openai.api_key = os.environ["OPENAI_API_KEY"]

initial_messages = [{"role": "system", "content": """Please act as a marketing expert for real estate agents. Your role is
to generate topic summary ideas for social media videos. Follow these steps in this order:
1. Before you execute any steps, consider the last input from the user as a suggestion for the types of topics you should create.
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.
3. Return a list of these 10 most compelling ideas."""}]

def CustomChatGPT(user_input, messages):
    messages.append({"role": "user", "content": user_input})
    response = openai.ChatCompletion.create(
        model = "gpt-3.5-turbo",
        messages = messages
    )
    ChatGPT_reply = response["choices"][0]["message"]["content"]
    messages.append({"role": "assistant", "content": ChatGPT_reply})
    return ChatGPT_reply, messages

def wrapped_chat_gpt(user_input):
    # Replace the following line with your method to retrieve the messages list for the current user
    messages = initial_messages.copy()

    reply, updated_messages = CustomChatGPT(user_input, messages)

    # Replace the following line with your method to store the updated messages list for the current user
    # Store updated_messages

    return reply

demo = gradio.Interface(fn=wrapped_chat_gpt, inputs="text", outputs="text", title="Video Idea Generator")

demo.launch(inline=False)