File size: 1,463 Bytes
306ec16
 
 
a6bd74b
306ec16
a6bd74b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8f9be0
a6bd74b
 
 
 
 
 
306ec16
 
a6bd74b
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
import gradio as gr
from chatbot import generate_answer

# Function to display chatbot answer
def main():
    # Define custom CSS for styling the interface
    css = """
    .chatbox-container {
        background-color: #f0f0f0;
        padding: 20px;
        border-radius: 10px;
        box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
        width: 100%;
        max-width: 600px;
        margin: auto;
    }
    .chatbox-container h1 {
        color: #4CAF50;
        font-size: 2rem;
        text-align: center;
        font-family: 'Arial', sans-serif;
    }
    .chatbox-container .output-box {
        padding: 10px;
        background-color: #fff;
        border-radius: 5px;
        font-size: 1.1rem;
        box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
    }
    .gradio-container {
        background-color: #fafafa;
    }
    .gradio-row {
        margin-bottom: 20px;
    }
    """
    
    # Define Gradio interface with a more structured layout
    with gr.Blocks(css=css) as demo:
        with gr.Column(elem_id="chatbox-container"):
            gr.Markdown("<h1>General Knowledge & Current Affairs Chatbot</h1>")
            chatbot = gr.Chatbot(label="Ask Me Anything", type="messages")
            textbox = gr.Textbox(label="Type your question")
            submit_button = gr.Button("Ask")
            
            submit_button.click(generate_answer, inputs=textbox, outputs=chatbot)

    demo.launch()

if __name__ == "__main__":
    main()