camparchimedes commited on
Commit
7fd4898
ยท
verified ยท
1 Parent(s): f0d1094

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -153,24 +153,27 @@ async def handle_message(message: cl.Message):
153
 
154
  },
155
  callbacks=[cl.AsyncLangchainCallbackHandler()])
156
- #if re.search(booking_pattern, user_message):
157
- #booking_id = re.search(booking_pattern, user_message).group(0)
158
- #question = f"Retrieve information for booking ID {booking_id}" # NOTE: field response is updated with "booking_id"
159
-
160
-
161
- #response = await api_chain.acall(
162
- #{
163
- #"booking_id": booking_id,
164
- #"question": question,
165
- #"url": url
166
- #},
167
- #callbacks=[cl.AsyncLangchainCallbackHandler()])
168
-
169
- else:
170
- ##await cl.Message("Vi kan desverre ikke finne noen informasjon for det oppgitte bookingnummeret.").send()
171
-
172
- #response = await api_chain.acall({"booking_id": booking_id}, callbacks=[cl.AsyncLangchainCallbackHandler()])
173
-
 
 
 
174
  response = await llm_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
175
 
176
  response_key = "output" if "output" in response else "text"
 
153
 
154
  },
155
  callbacks=[cl.AsyncLangchainCallbackHandler()])
156
+
157
+ booking_info = response.get("output", {}) # json.loads(response.get("output", "{}"))
158
+
159
+ formatted_response = f"""
160
+ Her er informasjon for bestillingskode: {bestillingskode}
161
+
162
+ | Felt | Detaljer |
163
+ |-------------|----------------------------------------|
164
+ | Navn: | {booking_info.get('Navn', 'N/A')} |
165
+ | Belรธp: | {booking_info.get('Belรธp', 'N/A')} NOK |
166
+ | Check-In: | {booking_info.get('Checkin', 'N/A')} |
167
+ | Check-Out: | {booking_info.get('Checkout', 'N/A')} |
168
+ | Addresse: | {booking_info.get('Addresse', 'N/A')} |
169
+ | Bruker ID: | {booking_info.get('Bruker ID', 'N/A')} |
170
+ | Viktig informasjon: | {booking_info.get('Viktig informasjon', 'N/A')} |
171
+ | Message: | {booking_info.get('Message', 'N/A')} |
172
+ """
173
+
174
+ await cl.Message(content=formatted_response).send()
175
+
176
+ else:
177
  response = await llm_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
178
 
179
  response_key = "output" if "output" in response else "text"