camparchimedes commited on
Commit
2f87804
ยท
verified ยท
1 Parent(s): 32f75ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -142,7 +142,7 @@ def setup_multiple_chains():
142
 
143
  requests_wrapper = TextRequestsWrapper(
144
  headers={
145
- "Authorization": auth_token,
146
  "Content-Type": "application/json"
147
  }
148
  )
@@ -170,19 +170,38 @@ async def handle_message(message: cl.Message):
170
 
171
  match = re.search(booking_pattern, user_message)
172
  if match:
 
173
  bestillingskode = match.group()
174
  post_data = {
175
  "url": endpoint_url,
176
- "body": {
177
- "booking_id": bestillingskode
178
- }
179
  }
 
180
 
181
  response = await post_tool.arun(
182
  json.dumps(post_data),
183
  callbacks=[cl.AsyncLangchainCallbackHandler()]
184
  )
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  else:
187
  response = await llm_chain.ainvoke(
188
  user_message, # {"chat_history": "", "question": user_message}
 
142
 
143
  requests_wrapper = TextRequestsWrapper(
144
  headers={
145
+ "Authorization": f"Bearer <auth_token>",
146
  "Content-Type": "application/json"
147
  }
148
  )
 
170
 
171
  match = re.search(booking_pattern, user_message)
172
  if match:
173
+
174
  bestillingskode = match.group()
175
  post_data = {
176
  "url": endpoint_url,
177
+ "data": {
178
+ "booking_id": bestillingskode
 
179
  }
180
+ }
181
 
182
  response = await post_tool.arun(
183
  json.dumps(post_data),
184
  callbacks=[cl.AsyncLangchainCallbackHandler()]
185
  )
186
 
187
+ if response:
188
+
189
+ booking_data = json.loads(response)
190
+ postman_response = f"""
191
+ | Field | Value |
192
+ |-------|--------|
193
+ | Booking ID | {booking_data['booking_id']} |
194
+ | Name | {booking_data['full_name']} |
195
+ | Amount | {booking_data['amount']} kr |
196
+ | Check-in | {booking_data['checkin']} |
197
+ | Check-out | {booking_data['checkout']} |
198
+ | Address | {booking_data['address']} |
199
+ | User ID | {booking_data['user_id']} |
200
+ | Info | {booking_data['infotext']} |
201
+ | Included | {booking_data['included']} |
202
+ """
203
+ await cl.Message(postman_response).send()
204
+
205
  else:
206
  response = await llm_chain.ainvoke(
207
  user_message, # {"chat_history": "", "question": user_message}