File size: 1,655 Bytes
387f58f
c2c8cd7
387f58f
 
 
9f6597d
 
b9b9108
 
387f58f
966b72d
 
387f58f
 
9f6597d
387f58f
5200c78
63e4c82
 
 
 
41fff30
 
82e448f
 
 
 
 
 
 
 
 
 
02b550a
82e448f
 
 
 
 
02b550a
82e448f
 
 
 
41fff30
9f6597d
7334998
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
45
46
47
48
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(Question):
    messages.append({"role": "user", "content": Question})
    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=gr.Textbox(label="Insert jargon here (ask a question):", placeholder="E.g. What are gas fees?"),
    outputs=gr.Textbox(label="Get a simple answer in return:"),
    title="Web(GPT)3",
    function handle_lightmode() {
		let url = new URL(window.location.toString());

          
		const color_mode: "light" | "dark" | "system" | null = url.searchParams.get(
			"__theme"
		) as "light" | "dark" | "system" | null;

          
		if (color_mode !== null) {
			if (color_mode === "light") {
				lightmode();
			} else if (color_mode === "system") {
				use_system_theme();
			}
			// light is default, so we don't need to do anything else
		} else if (url.searchParams.get("__light-theme") === "true") {
			lightmode();
		} else {
			use_system_theme();
		}
	}
    )

demo.launch()