dschandra commited on
Commit
a6bd74b
·
verified ·
1 Parent(s): 4135464

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -10
app.py CHANGED
@@ -1,16 +1,51 @@
1
  import gradio as gr
2
  from chatbot import generate_answer
3
 
 
4
  def main():
5
- # Create Gradio Interface
6
- iface = gr.Interface(
7
- fn=generate_answer,
8
- inputs=gr.Textbox(label="Ask a question"),
9
- outputs=gr.Textbox(label="Answer"),
10
- title="General Knowledge & Current Affairs Chatbot",
11
- description="Ask any question, and the bot will provide answers based on general knowledge and current affairs."
12
- )
13
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()