julkarnaeen commited on
Commit
b32d514
Β·
verified Β·
1 Parent(s): 27514ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -55
app.py CHANGED
@@ -1,68 +1,30 @@
1
- import gradio as gr
2
- from databot import DataBot
3
 
4
- # ── Initialize DataBot once at startup ──────────────────────────────
5
- print("Initializing DataBot...")
6
  bot = DataBot()
7
- print("DataBot ready.\n")
8
 
9
 
10
- # ── Gradio chat handler ──────────────────────────────────────────────
11
- def chat(message: str, history: list):
12
  """Handle a user message and return the bot's response."""
13
  if not message.strip():
14
  return ""
15
  return bot.ask(message)
16
 
17
 
18
- # ── Build Gradio UI ──────────────────────────────────────────────────
19
- with gr.Blocks(
20
- title="DataBot – ERP Assistant",
 
 
 
 
 
 
 
21
  theme=gr.themes.Soft(),
22
- css="""
23
- #header { text-align: center; padding: 20px 0 10px 0; }
24
- #header h1 { font-size: 2rem; font-weight: 700; }
25
- #header p { color: #555; margin-top: 4px; }
26
- footer { display: none !important; }
27
- """,
28
- ) as demo:
29
-
30
- with gr.Row(elem_id="header"):
31
- with gr.Column():
32
- gr.HTML("""
33
- <h1>πŸ€– DataBot</h1>
34
- <p>Ask natural-language questions about your ERP database.</p>
35
- """)
36
-
37
- chatbot = gr.ChatInterface(
38
- fn=chat,
39
- chatbot=gr.Chatbot(
40
- label="DataBot",
41
- height=520,
42
- bubble_full_width=False,
43
- show_copy_button=True,
44
- type="messages",
45
- ),
46
- textbox=gr.Textbox(
47
- placeholder="e.g. How many products are in stock? Which partners are active?",
48
- container=False,
49
- scale=7,
50
- ),
51
- examples=[
52
- "How many products are currently in the database?",
53
- "List all active commercial partners.",
54
- "What are the top 5 product categories by number of products?",
55
- "Show me all fiscal years.",
56
- "How many sales orders were created this year?",
57
- ],
58
- cache_examples=False,
59
- )
60
-
61
- gr.Markdown(
62
- "_DataBot only reads data. Write operations (INSERT / UPDATE / DELETE) "
63
- "and access to sensitive personal data are blocked by design._",
64
- elem_id="footer-note",
65
- )
66
 
67
  if __name__ == "__main__":
68
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
1
+ import gradio as gr # pyre-ignore[21]
2
+ from databot import DataBot # pyre-ignore[21]
3
 
4
+ print("Starting DataBot...")
 
5
  bot = DataBot()
6
+ print("DataBot ready!\n")
7
 
8
 
9
+ def respond(message, history):
 
10
  """Handle a user message and return the bot's response."""
11
  if not message.strip():
12
  return ""
13
  return bot.ask(message)
14
 
15
 
16
+ demo = gr.ChatInterface(
17
+ fn=respond,
18
+ title="πŸ€– DataBot",
19
+ description="Your intelligent ERP database assistant. Ask questions about your business data in English or French.",
20
+ examples=[
21
+ "How many products are there?",
22
+ "Combien y a-t-il d'articles ?",
23
+ "Show me the top 10 partners",
24
+ "What are the recent sales?",
25
+ ],
26
  theme=gr.themes.Soft(),
27
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if __name__ == "__main__":
30
+ demo.launch()