WebGPT3 / app.py
Web3Daily's picture
Update app.py
70e44fb
raw
history blame
1.9 kB
import openai
import gradio
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 = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Web(GPT)3 Daily")
demo.launch(share=True)
iface.launch(inline=False)
if self.share:
if self.is_space:
raise RuntimeError("Share is not supported when you are in Spaces")
try:
if self.share_url is None:
self.share_url = networking.setup_tunnel(
self.server_name, self.server_port
)
print(strings.en["SHARE_LINK_DISPLAY"].format(self.share_url))
if not (quiet):
print('\u2714 Connected')
except RuntimeError:
if self.analytics_enabled:
utils.error_analytics(self.ip_address, "Not able to set up tunnel")
self.share_url = None
self.share = False
print(strings.en["COULD_NOT_GET_SHARE_LINK"])
else:
if not (quiet):
print('\u2714 Connected')
self.share_url = None