ChatbotAI / app.py
trttung1610's picture
Rename health.py to app.py
d51d319
raw
history blame
1.05 kB
import gradio as gr
import openai
DESCRIPTION = """
Hãy để trợ lý của AI Consultant hỗ trợ bạn !
"""
# Define inputs and outputs
inputs = [
gr.inputs.Textbox(label="Câu hỏi:"),
]
outputs = [
gr.outputs.Textbox(label="Câu trả lời:")
]
def chatbot(input):
openai.api_key = API_KEY
response = openai.Completion.create(
engine="text-davinci-003",
prompt=input,
max_tokens=60
)
return response.choices[0].text.strip()
# Create a Gradio interface with title, logo, and caption
interface = gr.Interface(
fn=chatbot,
inputs=inputs,
outputs=outputs,
title="AI Consultant", # Add the title here
theme="compact", # You can adjust the theme as needed
layout="vertical", # You can adjust the layout as needed
allow_flagging="never",
live=False, # Set live to False to display the title, logo, and caption immediately
description=DESCRIPTION, # Update the description here
css='style.css'
)
# Launch the interface
interface.launch()