Railway / app.py
NeerajRavi's picture
Update app.py
2dbe990 verified
import gradio as gr
import traceback
from Chatbot.bot import answer_query
def chat_fn(message, history):
history = history or []
try:
answer = answer_query(message)
if not answer:
answer = "I couldn’t process that. Please try rephrasing your question."
except Exception:
traceback.print_exc()
answer = "Something went wrong while processing your request."
history.append({"role": "user", "content": message})
history.append({"role": "assistant", "content": answer})
return "", history
with gr.Blocks(
theme=gr.themes.Soft(),
title="RailMind AI"
) as demo:
gr.Markdown("""
# 🚆 RailMind AI
Smart railway assistance for live data and verified rules
""")
chatbot = gr.Chatbot(height=420)
msg = gr.Textbox(
placeholder="Ask about train schedules, PNR status, seat availability, or railway rules…",
show_label=False
)
msg.submit(chat_fn, [msg, chatbot], [msg, chatbot])
demo.launch(server_name="0.0.0.0", server_port=7860)