Chatapp / app.py
OdinStef's picture
Update app.py
bbbec64
raw
history blame
711 Bytes
import openai
import os
import gradio as gr
openai.api_key = os.getenv("MYKEY")
messages = [{"role": "system", "content": "You are a psychologist, author, and media commentator like Jordan B. Peterson"}]
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 = gr.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "I am Stephane AI and my name is Cameron")
demo.launch()