universalRobot / app.py
shuanglei's picture
Update app.py
b484394
# -*- coding: utf-8-*-
import openai
import gradio as gr
import os
#机器人女友
openai.api_key = os.environ.get("OPENAI_API_KEY")
prompt= "You are a helpful assistant."
messages = [
{"role": "system", "content": prompt},
]
def chatbot(input):
if input:
global messages
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)
reply = chat.choices[0].message.content
messages = [{"role": "system", "content": prompt}]
return reply
inputs = gr.inputs.Textbox(lines=7, label="通用机器人")
outputs = gr.outputs.Textbox(label="通用机器人")
app=gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI机器人",
description="你面前的是一个通用机器人,你可以向他提问。",
theme="compact")
app.launch()