File size: 852 Bytes
4eeb41c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import openai
import gradio as gr
import os

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

model_engine = "text-davinci-002"
openai.api_key = os.getenv("OPENAI_API_KEY")

def chatbot(prompt):
    completions = openai.Completion.create(
        engine=model_engine,
        prompt=prompt,
        max_tokens=1024,
        n=1,
        stop=None,
        temperature=0.5,
    )

    message = completions.choices[0].text.strip()
    return message

prompt_text = "Please describe the video you would like to create:"


interface = gr.Interface(
    fn=chatbot,
    inputs=gr.inputs.Textbox(label=prompt_text, lines=7),


    outputs=gr.outputs.Textbox(),
    title="Real Estate Video Script Writer",
    description="A simple chatbot based on GPT-3 that writes scripts for real estate videos.",
)


if __name__ == "__main__":
    interface.launch()