Update app.py
Browse files
app.py
CHANGED
|
@@ -78,67 +78,8 @@ def transcribe_audio(audio):
|
|
| 78 |
except sr.RequestError:
|
| 79 |
return "Error processing the audio."
|
| 80 |
|
| 81 |
-
# ✅ Styling and Theme
|
| 82 |
-
theme = gr.themes.Base().set(
|
| 83 |
-
body_background_fill="linear-gradient(to right, #001F3F, #0052CC)", # Dark navy to royal blue
|
| 84 |
-
button_primary_background_fill="linear-gradient(135deg, #FFD700, #FFAA00)", # Golden gradient
|
| 85 |
-
button_primary_text_color="black"
|
| 86 |
-
)
|
| 87 |
-
|
| 88 |
-
custom_css = """
|
| 89 |
-
/* Title text with gold gradient */
|
| 90 |
-
.title-text {
|
| 91 |
-
background: linear-gradient(90deg, #FFD700, #FFAA00);
|
| 92 |
-
-webkit-background-clip: text;
|
| 93 |
-
background-clip: text;
|
| 94 |
-
color: transparent;
|
| 95 |
-
-webkit-text-fill-color: transparent;
|
| 96 |
-
font-weight: 700;
|
| 97 |
-
font-size: 42px;
|
| 98 |
-
text-align: center;
|
| 99 |
-
text-transform: uppercase;
|
| 100 |
-
letter-spacing: 1px;
|
| 101 |
-
text-shadow: 1px 1px 5px rgba(255, 215, 0, 0.3);
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
/* Body text - Gold on Dark Background */
|
| 105 |
-
body, .gradio-container {
|
| 106 |
-
color: #FFD700 !important;
|
| 107 |
-
font-family: 'Inter', sans-serif;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/* Chat messages - Minimalist design */
|
| 111 |
-
.chat-message {
|
| 112 |
-
background: rgba(255, 255, 255, 0.05);
|
| 113 |
-
border-radius: 12px;
|
| 114 |
-
padding: 12px;
|
| 115 |
-
backdrop-filter: blur(8px);
|
| 116 |
-
color: white !important;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
/* Buttons */
|
| 120 |
-
button.primary {
|
| 121 |
-
background: linear-gradient(135deg, #FFD700, #FFAA00);
|
| 122 |
-
border: none;
|
| 123 |
-
color: black !important;
|
| 124 |
-
font-weight: bold;
|
| 125 |
-
text-transform: uppercase;
|
| 126 |
-
border-radius: 20px;
|
| 127 |
-
padding: 10px 20px;
|
| 128 |
-
transition: all 0.3s ease-in-out;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
button.primary:hover {
|
| 132 |
-
transform: scale(1.1);
|
| 133 |
-
box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
|
| 134 |
-
}
|
| 135 |
-
"""
|
| 136 |
-
|
| 137 |
-
def clear_history():
|
| 138 |
-
return []
|
| 139 |
-
|
| 140 |
# ✅ Build Gradio Interface
|
| 141 |
-
with gr.Blocks(
|
| 142 |
gr.HTML("<h2 class='title-text'>AI Insurance Chatbot</h2>")
|
| 143 |
gr.Markdown("### Select your insurance type, country, and ask your question.")
|
| 144 |
|
|
@@ -165,13 +106,13 @@ with gr.Blocks(theme=theme, css=custom_css) as demo:
|
|
| 165 |
|
| 166 |
conversation_state = gr.State([])
|
| 167 |
|
| 168 |
-
chatbot = gr.Chatbot(label="Chat History")
|
| 169 |
|
| 170 |
clear_button = gr.Button("Clear Chat History")
|
| 171 |
clear_button.click(lambda: [], outputs=[conversation_state, chatbot])
|
| 172 |
|
| 173 |
question_input = gr.Textbox(label="Ask your question...", placeholder="Describe your insurance question...", interactive=True)
|
| 174 |
-
image_input = gr.File(label="Upload an image (optional)", type="
|
| 175 |
voice_input = gr.Audio(label="Speak your question (optional)", type="filepath")
|
| 176 |
|
| 177 |
submit_btn = gr.Button("Send")
|
|
|
|
| 78 |
except sr.RequestError:
|
| 79 |
return "Error processing the audio."
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
# ✅ Build Gradio Interface
|
| 82 |
+
with gr.Blocks() as demo:
|
| 83 |
gr.HTML("<h2 class='title-text'>AI Insurance Chatbot</h2>")
|
| 84 |
gr.Markdown("### Select your insurance type, country, and ask your question.")
|
| 85 |
|
|
|
|
| 106 |
|
| 107 |
conversation_state = gr.State([])
|
| 108 |
|
| 109 |
+
chatbot = gr.Chatbot(label="Chat History", type="messages") # ✅ Fix: Set type to "messages"
|
| 110 |
|
| 111 |
clear_button = gr.Button("Clear Chat History")
|
| 112 |
clear_button.click(lambda: [], outputs=[conversation_state, chatbot])
|
| 113 |
|
| 114 |
question_input = gr.Textbox(label="Ask your question...", placeholder="Describe your insurance question...", interactive=True)
|
| 115 |
+
image_input = gr.File(label="Upload an image (optional)", type="filepath") # ✅ Fix: Change type to "filepath"
|
| 116 |
voice_input = gr.Audio(label="Speak your question (optional)", type="filepath")
|
| 117 |
|
| 118 |
submit_btn = gr.Button("Send")
|