File size: 1,059 Bytes
387f58f c2c8cd7 387f58f 1497e34 387f58f 9f6597d b9b9108 387f58f 966b72d 387f58f 9f6597d 387f58f d8c47c8 e598dc4 63e4c82 8ab3021 241c805 5102182 8c44628 e598dc4 0c5ed2c |
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 |
import openai
import gradio as gr
openai.api_key = os.getenv("ChatGPT-API-Key")
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
WebGPT3 = gr.Interface(
fn=CustomChatGPT,
inputs=gr.Textbox(label="Ask a question:", placeholder="E.g. What are gas fees? ...Can you simplify that with an analogy?"),
outputs=gr.Textbox(label="Answer:"),
title=""
)
WebGPT3.launch()
|