NeerajRavi commited on
Commit
2dbe990
·
verified ·
1 Parent(s): f2030f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -60
app.py CHANGED
@@ -4,6 +4,8 @@ from Chatbot.bot import answer_query
4
 
5
 
6
  def chat_fn(message, history):
 
 
7
  try:
8
  answer = answer_query(message)
9
  if not answer:
@@ -12,78 +14,30 @@ def chat_fn(message, history):
12
  traceback.print_exc()
13
  answer = "Something went wrong while processing your request."
14
 
15
- history = history or []
16
  history.append({"role": "user", "content": message})
17
  history.append({"role": "assistant", "content": answer})
18
 
19
  return "", history
20
 
21
 
22
- custom_css = """
23
- body {
24
- margin: 0;
25
- background: linear-gradient(135deg, #0f172a, #111827);
26
- }
27
-
28
- .gradio-container {
29
- height: 100vh !important;
30
- display: flex;
31
- flex-direction: column;
32
- padding: 0 20px;
33
- }
34
-
35
- .header {
36
- padding: 12px 0;
37
- font-size: 20px;
38
- font-weight: 600;
39
- }
40
-
41
- .subheader {
42
- font-size: 13px;
43
- color: #9ca3af;
44
- }
45
-
46
- .chat-container {
47
- flex: 1;
48
- display: flex;
49
- flex-direction: column;
50
- gap: 10px;
51
- }
52
-
53
- footer {visibility: hidden}
54
- """
55
-
56
-
57
- with gr.Blocks(title="RailMind AI") as demo:
58
 
59
  gr.Markdown("""
60
- <div class="header">🚆 RailMind AI</div>
61
- <div class="subheader">Real-time railway data & verified rules</div>
62
  """)
63
 
64
- with gr.Column(elem_classes="chat-container"):
65
- chatbot = gr.Chatbot(
66
- height=480,
67
- show_label=False
68
- )
69
 
70
- with gr.Row():
71
- msg = gr.Textbox(
72
- placeholder="Ask about live train status, PNR, fares, seat availability, or railway rules...",
73
- show_label=False,
74
- scale=8
75
- )
76
- send = gr.Button("Send", scale=1)
77
- clear = gr.Button("Clear", scale=1)
78
 
79
  msg.submit(chat_fn, [msg, chatbot], [msg, chatbot])
80
- send.click(chat_fn, [msg, chatbot], [msg, chatbot])
81
- clear.click(lambda: [], None, chatbot)
82
 
83
 
84
- demo.launch(
85
- server_name="0.0.0.0",
86
- server_port=7860,
87
- theme=gr.themes.Soft(primary_hue="blue", secondary_hue="slate"),
88
- css=custom_css
89
- )
 
4
 
5
 
6
  def chat_fn(message, history):
7
+ history = history or []
8
+
9
  try:
10
  answer = answer_query(message)
11
  if not answer:
 
14
  traceback.print_exc()
15
  answer = "Something went wrong while processing your request."
16
 
 
17
  history.append({"role": "user", "content": message})
18
  history.append({"role": "assistant", "content": answer})
19
 
20
  return "", history
21
 
22
 
23
+ with gr.Blocks(
24
+ theme=gr.themes.Soft(),
25
+ title="RailMind AI"
26
+ ) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  gr.Markdown("""
29
+ # 🚆 RailMind AI
30
+ Smart railway assistance for live data and verified rules
31
  """)
32
 
33
+ chatbot = gr.Chatbot(height=420)
 
 
 
 
34
 
35
+ msg = gr.Textbox(
36
+ placeholder="Ask about train schedules, PNR status, seat availability, or railway rules…",
37
+ show_label=False
38
+ )
 
 
 
 
39
 
40
  msg.submit(chat_fn, [msg, chatbot], [msg, chatbot])
 
 
41
 
42
 
43
+ demo.launch(server_name="0.0.0.0", server_port=7860)