File size: 2,927 Bytes
47b4748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ba7e5b
 
 
 
 
 
 
 
 
 
 
47b4748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ba7e5b
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import gradio as gr
from app_functions import Get_DialoGPT_Response, Get_DistilGPT_Response, Get_MedGPT_Response

# Custom CSS for styling (optional)
custom_css = """
body {
    background-color: #121212;
    color: #E0E0E0;
    font-family: 'Poppins', sans-serif;
}
.gradio-container {
    width: 70%;
    margin: 0 auto;
    padding: 20px;
}
h1 {
    color: #FF6347;
    font-size: 50px;
    text-align: center;
    font-weight: bold;
}
h3 {
    color: #FF6347;
    text-align: center;
}
textarea, input, select {
    background-color: #1E1E2F;
    color: #E0E0E0;
    border: 1px solid #3D3D5C;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
}
button {
    background-color: #007BFF;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    width: 50%;
    margin: 0 auto;
}
button:hover {
    background-color: #0056b3;
}
.response-box {
    background-color: #1E1E2F;
    padding: 15px;
    border-radius: 6px;
    color: #E0E0E0;
    font-size: 16px;
    min-height: 100px;
    text-align: left;
}
"""

# Define the generate_response function
def generate_response(input_text, no_words, user_type, model_type):
    if model_type == "DialoGPT":
        return Get_DialoGPT_Response(input_text, no_words, user_type)
    elif model_type == "DistilGPT":
        return Get_DistilGPT_Response(input_text, no_words, user_type)
    elif model_type == "MedGPT":
        return Get_MedGPT_Response(input_text, no_words, user_type)
    else:
        return "Invalid model type selected."

# Build Gradio interface
with gr.Blocks(css=custom_css) as interface:
    gr.Markdown("<h1>Healthwise AI Assistant πŸš‘</h1>")
    gr.Markdown("<h3 style='color: #FF6347;'>Get accurate health-related advice tailored for your needs 😊</h3>")

    with gr.Row():
        with gr.Column(scale=1):
            gr.Markdown("<h3>Your Query</h3>")
            input_text = gr.Textbox(label="Question", placeholder="Type your health-related question...", lines=2)
            no_words = gr.Textbox(label="Max No. of Words", placeholder="Enter max words for the response (e.g., 100)")
        with gr.Column(scale=1):
            gr.Markdown("<h3>Preferences</h3>")
            user_type = gr.Radio(label="Answer For", choices=["Professional", "Practitioner", "General"], value="General")
            model_type = gr.Radio(label="Model Type", choices=["DialoGPT", "DistilGPT", "MedGPT"], value="DialoGPT")

    with gr.Row():
        submit_button = gr.Button("Generate Response")

    with gr.Row():
        gr.Markdown("<h3>AI Assistant's Advice πŸ‘‡</h3>")
    with gr.Row():
        response = gr.HTML("<div class='response-box'>The AI's response will appear here...</div>")

    submit_button.click(generate_response, inputs=[input_text, no_words, user_type, model_type], outputs=response)

interface.launch()