rawsun007 commited on
Commit
cc215f9
·
1 Parent(s): f829116

code update in app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -73,7 +73,28 @@ def parse_banking_sms(raw_text: str) -> dict:
73
  # --------------------------------------------------
74
  # 3. Chatbot response handler
75
  # --------------------------------------------------
76
- def chatbot_response(raw_text):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  result = parse_banking_sms(raw_text)
78
  if result["is_transaction"]:
79
  response = f"""✅ **Transaction Detected!**
@@ -128,7 +149,7 @@ with gr.Blocks() as demo:
128
  )
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`")
 
73
  # --------------------------------------------------
74
  # 3. Chatbot response handler
75
  # --------------------------------------------------
76
+ def chatbot_response(raw_text, chat_history):
77
+ result = parse_banking_sms(raw_text)
78
+ if result["is_transaction"]:
79
+ response = f"""✅ Transaction Detected!
80
+
81
+ 📅 Date: {result['date']}
82
+ 💳 Type: {result['type'].title() if result['type'] else 'N/A'}
83
+ 💰 Amount: {result['amount']}
84
+ 🏪 Category: {result['category']}
85
+ 🔢 Last 4 Digits: {result['last4']}
86
+ """
87
+ else:
88
+ response = """ℹ️ Non-Transaction Message
89
+
90
+ This appears to be a promotional or informational message.
91
+ """
92
+ chat_history = chat_history or []
93
+ chat_history.append({"role": "user", "content": raw_text})
94
+ chat_history.append({"role": "assistant", "content": response})
95
+
96
+ return chat_history, ""
97
+
98
  result = parse_banking_sms(raw_text)
99
  if result["is_transaction"]:
100
  response = f"""✅ **Transaction Detected!**
 
149
  )
150
 
151
 
152
+ msg.submit(chatbot_response, inputs=[msg, chatbot], outputs=[chatbot, msg])
153
  msg.submit(lambda: "", None, msg)
154
 
155
  gr.Markdown("---\n**Model:** `rawsun00001/banking-sms-json-parser-v6-merged`")