|
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", |
|
css=""".gradio-container, .svelte-drgfj5, .svelte-1jsbsph, .scroll-hide.svelte-drgfj5, .svelte-1ed2p3z, .main.svelte-v63enf, |
|
.wrap.svelte-ujkds4, .contain, .svelte-1adap6y.gap, .block.svelte-1scc9gv.padded, .wrap.center.svelte-1d50qkz.hide, .prose.svelte-1yrv54, |
|
.flex.svelte-1btyfsc.unequal-height, .svelte-1adap6y.gap.panel, .svelte-1adap6y.gap, .form.svelte-w3fdu4, .block.svelte-1scc9gv.padded, |
|
.svelte-drgfj5, .svelte-1jsbsph, .scroll-hide.svelte-drgfj5, . { |
|
background-color: #FFFFFF; |
|
border-color: #FFFFFF; |
|
color: black}""" |
|
) |
|
|
|
|
|
|
|
demo.launch() |
|
|