camparchimedes commited on
Commit
0e5fbbd
·
verified ·
1 Parent(s): a9dc765

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -56
app.py CHANGED
@@ -165,62 +165,8 @@ async def handle_message(message: cl.Message):
165
  )
166
 
167
  if response:
168
- await cl.Message(content=str(response)).send()
169
-
170
- ## PS:
171
- #json.dumps(post_data) converts a Python dictionary (post_data) into a JSON string.
172
- #json.loads(post_data) takes a JSON string and converts it back into a Python dictionary.
173
-
174
-
175
- """
176
- ## OPTION I
177
- if response:
178
- try:
179
- booking_info = json.loads(response)
180
-
181
-
182
- table = (
183
- "|:------|:------|\n"
184
- f"| Booking ID | `{booking_info.get('booking_id')}` |\n"
185
- f"| Full Name | `{booking_info.get('full_name')}` |\n"
186
- f"| Amount | `{booking_info.get('amount')} kr` |\n"
187
- f"| Check-in | `{booking_info.get('checkin')}` |\n"
188
- f"| Check-out | `{booking_info.get('checkout')}` |\n"
189
- f"| Address | `{booking_info.get('address')}` |\n"
190
- f"| User ID | `{booking_info.get('user_id')}` |\n"
191
- f"| Info Text | `{booking_info.get('infotext')}` |\n"
192
- f"| Included | `{booking_info.get('included')}` |"
193
- )
194
-
195
- await cl.Message(content=table).send()
196
-
197
- except Exception as e:
198
- error_msg = f"Error: Could not parse the booking information. Details: {str(e)}"
199
- await cl.Message(error_msg).send()
200
-
201
- # info: ↑™ returns a ’None’ response for values
202
-
203
-
204
- ## OPTION II
205
- table = "| Field | Information |\n|---|---|\n"
206
-
207
- fields_mapping = [
208
- ('booking_id', 'booking_id'),
209
- ('full_name', 'full_name'),
210
- ('amount', 'amount'),
211
- ('checkin', 'checkin'),
212
- ('checkout', 'checkout'),
213
- ('address', 'address'),
214
- ('user_id', 'user_id'),
215
- ('infotext', 'infotext'),
216
- ('included', 'included')
217
- ]
218
-
219
- for field, display_name in fields_mapping:
220
- value = booking_data.get(field)
221
- table += f"| {display_name} | {value} |\n"
222
- """
223
-
224
  else:
225
  response = await llm_chain.ainvoke(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
226
 
 
165
  )
166
 
167
  if response:
168
+ await cl.Message(content=str(response)).send()
169
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  else:
171
  response = await llm_chain.ainvoke(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
172