|
import gradio as gr |
|
import openai |
|
import os |
|
|
|
openai.api_key = os.environ.get('openai_api_key') |
|
|
|
def chatbot(input): |
|
|
|
prompt = """You only answer questions about heart disease. If the question is not about heart disease, you politely respond that you are not designed to answer that kind of question.\n\n""" + input |
|
|
|
response = openai.Completion.create( |
|
engine="text-davinci-003", |
|
prompt=prompt, |
|
temperature=0.5, |
|
max_tokens=1000 |
|
) |
|
return response.choices[0].text.strip() |
|
|
|
iface = gr.Interface( |
|
fn=chatbot, |
|
inputs="text", |
|
outputs="text", |
|
theme = gr.themes.Monochrome( |
|
primary_hue="blue", |
|
secondary_hue="blue", |
|
neutral_hue="blue", |
|
), |
|
title="Heart Disease Information AI Chatbot", |
|
description="""This AI chatbot is designed to answer questions about heart disease. Ask about different types of heart diseases, symptoms, treatments, research advances, or any other heart disease-related queries. |
|
|
|
Not sure what to ask? Try questions like these: |
|
- "What is the latest research on heart disease?" |
|
- "What are the symptoms of heart failure?" |
|
- "Can you explain how a pacemaker works?" |
|
<br> |
|
<br>Go back to: <a href="https://aitechproducts.com/healthcare-products.html">Healthcare AI Samples</a>""", |
|
layout="vertical", |
|
inputs_css_class="custom-input-class", |
|
outputs_css_class="custom-output-class", |
|
examples=None, |
|
output_width="100%", |
|
output_height=400, |
|
css=""" |
|
.custom-input-class { |
|
/* Custom input component styles */ |
|
} |
|
.custom-output-class { |
|
/* Custom output component styles */ |
|
} |
|
.gradio-interface input[type="submit"] { |
|
background: linear-gradient(45deg, #FF0000, #FF4500); |
|
color: #FFFFFF; |
|
} |
|
/* Other custom CSS rules */ |
|
""" |
|
) |
|
|
|
iface.launch(auth=(os.environ['USERNAME1'],os.environ['PASSWORD1'])) |
|
|