TokenopolyHQ commited on
Commit
cbb6831
·
1 Parent(s): 0289774

code update in app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -18
app.py CHANGED
@@ -59,8 +59,14 @@ def parse_banking_sms(raw_text: str) -> dict:
59
  except json.JSONDecodeError:
60
  pass
61
 
62
- return {"date": None, "type": None, "amount": None,
63
- "category": None, "last4": None, "is_transaction": False}
 
 
 
 
 
 
64
 
65
  # --------------------------------------------------
66
  # 3. Chatbot response handler
@@ -92,24 +98,43 @@ This appears to be a promotional or informational message.
92
  return [(raw_text, response)]
93
 
94
  # --------------------------------------------------
95
- # 4. Gradio Interface
96
  # --------------------------------------------------
97
- iface = gr.Interface(
98
- fn=chatbot_response,
99
- inputs=gr.Textbox(lines=3, placeholder="Paste your banking SMS/email here…"),
100
- outputs=gr.Chatbot(label="Banking SMS Parser", height=400),
101
- title="🏦 Banking SMS JSON Parser Chatbot",
102
- description="Paste any banking SMS or email to extract structured JSON.",
103
- examples=[
104
- ["Your A/c XX1234 debited for 5000 on 15-Jan-2024 at AMAZON"],
105
- ["2500 credited to A/c 9876 on 20-Dec-2023 from PAYROLL"],
106
- ["Card 4321 used for 120 at STARBUCKS on 10-Nov-2023"],
107
- ],
108
- show_api=False
109
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  # --------------------------------------------------
112
- # 5. App launcher (Spaces-compatible)
113
  # --------------------------------------------------
114
  if __name__ == "__main__":
115
- iface.launch(share=True)
 
59
  except json.JSONDecodeError:
60
  pass
61
 
62
+ return {
63
+ "date": None,
64
+ "type": None,
65
+ "amount": None,
66
+ "category": None,
67
+ "last4": None,
68
+ "is_transaction": False
69
+ }
70
 
71
  # --------------------------------------------------
72
  # 3. Chatbot response handler
 
98
  return [(raw_text, response)]
99
 
100
  # --------------------------------------------------
101
+ # 4. Gradio Blocks UI
102
  # --------------------------------------------------
103
+ with gr.Blocks() as demo:
104
+ gr.Markdown("""
105
+ # 🏦 Banking SMS JSON Parser Chatbot
106
+
107
+ Paste any banking SMS or email below – no special formatting needed!
108
+
109
+ **Features:**
110
+ - Detects real transactions vs promotional messages
111
+ - Extracts date, amount, merchant, category, account info
112
+ - Works with all Indian & global banking formats
113
+ """)
114
+
115
+ chatbot = gr.Chatbot(label="Banking SMS Parser", height=400)
116
+ msg = gr.Textbox(
117
+ lines=3,
118
+ placeholder="Paste your banking SMS/email here…",
119
+ label="Input Message"
120
+ )
121
+
122
+ gr.Examples(
123
+ examples=[
124
+ ["Your A/c XX1234 debited for 5000 on 15-Jan-2024 at AMAZON"],
125
+ ["2500 credited to A/c 9876 on 20-Dec-2023 from PAYROLL"],
126
+ ["Card 4321 used for 120 at STARBUCKS on 10-Nov-2023"],
127
+ ],
128
+ inputs=msg
129
+ )
130
+
131
+ msg.submit(chatbot_response, inputs=msg, outputs=chatbot)
132
+ msg.submit(lambda: "", None, msg)
133
+
134
+ gr.Markdown("---\n**Model:** `rawsun00001/banking-sms-json-parser-v6-merged`")
135
 
136
  # --------------------------------------------------
137
+ # 5. App launcher
138
  # --------------------------------------------------
139
  if __name__ == "__main__":
140
+ demo.launch(share=True)