Spaces:
Runtime error
Runtime error
File size: 802 Bytes
6649cea 59368e0 6649cea 59368e0 6649cea 59368e0 6649cea 8b02647 6649cea 59368e0 6649cea 59368e0 6649cea 731fba9 |
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 |
import openai
import gradio as gr
openai.api_key = "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"
messages = [
{"role": "system", "content": "You are a helpful and kind AI Assistant."},
]
def chatbot(input):
if input:
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model=gpt-4-32k", messages=messages
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
inputs = gr.inputs.Textbox(lines=7, label="Chat with AI")
outputs = gr.outputs.Textbox(label="Reply")
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI Chatbot",
description="Ask anything you want",
theme="compact").launch() |