Spaces:
Build error
Build error
TokenopolyHQ commited on
Commit ·
cbb6831
1
Parent(s): 0289774
code update in app.py
Browse files
app.py
CHANGED
|
@@ -59,8 +59,14 @@ def parse_banking_sms(raw_text: str) -> dict:
|
|
| 59 |
except json.JSONDecodeError:
|
| 60 |
pass
|
| 61 |
|
| 62 |
-
return {
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 96 |
# --------------------------------------------------
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
# --------------------------------------------------
|
| 112 |
-
# 5. App launcher
|
| 113 |
# --------------------------------------------------
|
| 114 |
if __name__ == "__main__":
|
| 115 |
-
|
|
|
|
| 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)
|