WebGPT3 / app.py
Web3Daily's picture
Update app.py
3c0eb01
raw
history blame
1.22 kB
import openai
import gradio as gr
import os
openai.api_key = os.getenv("OPENAI_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. In fact, you always open with an analogy when possible."}]
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
description = "Check for ChatGPT outages <a href=https://status.openai.com/>here.</a>"
demo = 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=""
)
demo.launch(inline=True)