Spaces:
Sleeping
Sleeping
Commit ·
70947b9
1
Parent(s): cfdca08
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import openai
|
| 3 |
+
|
| 4 |
+
openai.api_key = "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" # insert your own OpenAI key
|
| 5 |
+
|
| 6 |
+
def chatbot(input):
|
| 7 |
+
|
| 8 |
+
prompt = """You only answer questions about Chronic Kidney Disease (CKD). If the question is not about CKD, you politely respond that you are not designed to answer that kind of question.\n\n""" + input
|
| 9 |
+
|
| 10 |
+
response = openai.Completion.create(
|
| 11 |
+
engine="text-davinci-003",
|
| 12 |
+
prompt=prompt,
|
| 13 |
+
temperature=0.5,
|
| 14 |
+
max_tokens=1000
|
| 15 |
+
)
|
| 16 |
+
return response.choices[0].text.strip()
|
| 17 |
+
|
| 18 |
+
iface = gr.Interface(
|
| 19 |
+
fn=chatbot,
|
| 20 |
+
inputs="text",
|
| 21 |
+
outputs="text",
|
| 22 |
+
theme = gr.themes.Monochrome(
|
| 23 |
+
primary_hue="blue",
|
| 24 |
+
secondary_hue="blue",
|
| 25 |
+
neutral_hue="blue",
|
| 26 |
+
),
|
| 27 |
+
title="Chronic Kidney Disease Information AI Chatbot",
|
| 28 |
+
description="""This AI chatbot is designed to answer questions about Chronic Kidney Disease (CKD). Ask about the symptoms, treatments, research advances, or any other CKD-related queries.
|
| 29 |
+
|
| 30 |
+
Not sure what to ask? Try questions like these:
|
| 31 |
+
- "What is the latest research on CKD?"
|
| 32 |
+
- "What are the symptoms of CKD?"
|
| 33 |
+
- "Can you explain how dialysis works?"
|
| 34 |
+
<br>
|
| 35 |
+
<br>Go back to: <a href="https://aitechproducts.com">AI TECH PRODUCTS</a>""",
|
| 36 |
+
layout="vertical",
|
| 37 |
+
inputs_css_class="custom-input-class",
|
| 38 |
+
outputs_css_class="custom-output-class",
|
| 39 |
+
examples=None,
|
| 40 |
+
output_width="100%",
|
| 41 |
+
output_height=400,
|
| 42 |
+
css="""
|
| 43 |
+
.custom-input-class {
|
| 44 |
+
/* Custom input component styles */
|
| 45 |
+
}
|
| 46 |
+
.custom-output-class {
|
| 47 |
+
/* Custom output component styles */
|
| 48 |
+
}
|
| 49 |
+
.gradio-interface input[type="submit"] {
|
| 50 |
+
background: linear-gradient(45deg, #FF0000, #FF4500);
|
| 51 |
+
color: #FFFFFF;
|
| 52 |
+
}
|
| 53 |
+
/* Other custom CSS rules */
|
| 54 |
+
"""
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
iface.launch()
|