Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,51 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from chatbot import generate_answer
|
| 3 |
|
|
|
|
| 4 |
def main():
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
if __name__ == "__main__":
|
| 16 |
-
main()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from chatbot import generate_answer
|
| 3 |
|
| 4 |
+
# Function to display chatbot answer
|
| 5 |
def main():
|
| 6 |
+
# Define custom CSS for styling the interface
|
| 7 |
+
css = """
|
| 8 |
+
.chatbox-container {
|
| 9 |
+
background-color: #f0f0f0;
|
| 10 |
+
padding: 20px;
|
| 11 |
+
border-radius: 10px;
|
| 12 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
|
| 13 |
+
width: 100%;
|
| 14 |
+
max-width: 600px;
|
| 15 |
+
margin: auto;
|
| 16 |
+
}
|
| 17 |
+
.chatbox-container h1 {
|
| 18 |
+
color: #4CAF50;
|
| 19 |
+
font-size: 2rem;
|
| 20 |
+
text-align: center;
|
| 21 |
+
font-family: 'Arial', sans-serif;
|
| 22 |
+
}
|
| 23 |
+
.chatbox-container .output-box {
|
| 24 |
+
padding: 10px;
|
| 25 |
+
background-color: #fff;
|
| 26 |
+
border-radius: 5px;
|
| 27 |
+
font-size: 1.1rem;
|
| 28 |
+
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
|
| 29 |
+
}
|
| 30 |
+
.gradio-container {
|
| 31 |
+
background-color: #fafafa;
|
| 32 |
+
}
|
| 33 |
+
.gradio-row {
|
| 34 |
+
margin-bottom: 20px;
|
| 35 |
+
}
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
# Define Gradio interface with a more structured layout
|
| 39 |
+
with gr.Blocks(css=css) as demo:
|
| 40 |
+
with gr.Column(elem_id="chatbox-container"):
|
| 41 |
+
gr.Markdown("<h1>General Knowledge & Current Affairs Chatbot</h1>")
|
| 42 |
+
chatbot = gr.Chatbot(label="Ask Me Anything")
|
| 43 |
+
textbox = gr.Textbox(label="Type your question")
|
| 44 |
+
submit_button = gr.Button("Ask")
|
| 45 |
+
|
| 46 |
+
submit_button.click(generate_answer, inputs=textbox, outputs=chatbot)
|
| 47 |
+
|
| 48 |
+
demo.launch()
|
| 49 |
|
| 50 |
if __name__ == "__main__":
|
| 51 |
+
main()
|