MyChatGPTTurbo / app.py
Gopala Krishna
removed title
95ad623
raw
history blame
720 Bytes
import openai
import gradio as gr
openai.api_key = "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"
messages = [
{"role": "system", "content": "My AI Assistant"},
]
def chatbot(input):
if input:
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
inputs = gr.inputs.Textbox(lines=7, label="Query")
outputs = gr.outputs.Textbox(label="Response")
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="",
theme="compact").launch()