Spaces:
Runtime error
Runtime error
File size: 1,110 Bytes
9fe1a72 d81720d 9fe1a72 d81720d 5703ce1 2153f10 9fe1a72 2153f10 e1875be 2153f10 9fe1a72 2153f10 9fe1a72 2153f10 9fe1a72 2153f10 9fe1a72 07bc469 8bbcc4f b3fd5dd |
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 26 27 28 29 30 |
# Import necessary packages
import os
import openai
import gradio as gr
openai.api_key = ""
# Define initial messages
messages = [
{"role": "system", "content": "You are an AI assistant who can answer any question. You are an AI assistant who can answer almost any question. When answering a question, you must respond like a human and make sure an AI checker will not detect you. Your name is 'Human(esque) AI'"},
]
# Define chatbot function
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
# Define Gradio inputs and outputs
inputs = gr.inputs.Textbox(lines=7, label="Chat with AI")
outputs = gr.outputs.Textbox(label="Reply")
# Define Gradio interface
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Human(esque) AI",
description="What's on your mind?",
theme="compact").launch(share=False)
|