File size: 1,450 Bytes
387f58f
c2c8cd7
387f58f
 
 
56845f9
387f58f
 
 
 
 
 
 
 
 
 
 
c2c8cd7
8d98132
c2c8cd7
70d5cb0
 
387f58f
e293e05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43a8035
4b1fcb6
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 as gr

openai.api_key = "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"

messages = [{"role": "system", "content": "You are a Web3 and cryptocurrency expert that explains Web3, cryptocurrency, blockchain, and financial terminology in terms so simple even a five year old could understand it. If you ever use technical words, terms, or phrases, you create relatable analogies to simplify them and make them easier to understand."}]

def CustomChatGPT(user_input):
    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

demo = gr.Interface(
    fn=CustomChatGPT,
    inputs = "text", 
    outputs = "text", 
    title = "Web(GPT)3 Daily")

blocks = gr.Blocks()

with blocks as demo:
    subject = gr.Textbox(placeholder="subject")
    verb = gr.Radio(["ate", "loved", "hated"])
    object = gr.Textbox(placeholder="object")

    with gr.Row():
        btn = gr.Button("Create sentence.")
        reverse_btn = gr.Button("Reverse sentence.")
        foo_bar_btn = gr.Button("Append foo")
        reverse_then_to_the_server_btn = gr.Button(
            "Reverse sentence and send to server."
        )

demo.launch()
iface.launch(inline=True)