File size: 2,165 Bytes
3484a3c
3620f53
f5512c6
4eeb41c
cf8da98
4eeb41c
41ca7d6
96d71a8
cb94a33
8ab5ef1
 
 
 
 
 
 
 
 
4eeb41c
41ca7d6
fec0c5b
3620f53
 
 
4eeb41c
3620f53
 
41ca7d6
4eeb41c
41ca7d6
 
 
4eeb41c
41ca7d6
4eeb41c
41ca7d6
 
4eeb41c
41ca7d6
 
 
 
 
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
41
42
43
44
import openai
import gradio
import os

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

initial_messages = [{"role": "system", "content": """Please create engaging and informative video scripts for real 
estate agents to use on social media. The target audience is potential homebuyers and sellers.
The tone should be professional and friendly, with a focus on building trust and showcasing the agent's expertise. 
Your scripts do not include the agents name, they don't have any sort of greeting, and they are optomized to be used to create
videos that will be shared on social media.
Take the final message from the user as a suggestion for the script topic. Then follow these steps:
1. Write a draft of the script that includes a strong call to action at the end that asks viewers to reach out to the agent.
2. Review the draft to find the most compelling or engaging aspect of the script.
3. Write 5 alternative hooks for the script. A hook is the first one or two sentences that grab the attention
of the viewer and summarize what they can expect to hear in the rest of the script.
4. Choose the best hook and replace the beginning of the script draft with that hook.
5. Return just the words the agent should read into the camera."""}]

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="Real Estate Video Script Writer")

demo.launch(inline=False)