Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,7 @@
|
|
1 |
# ===================================================
|
2 |
-
# "the-very-latest-latest-POST-it"-----app.py
|
3 |
# ===================================================
|
4 |
-
|
5 |
-
Change from APIChain to EnhancedRequestsPostTool was heisted by the need to handle POST requests.
|
6 |
-
APIChain internally was responsible for URL construction, API interaction, and response formatting:
|
7 |
-
EnhancedRequestsPostTool is an enabler for POST handling@RequestsPostTool.
|
8 |
-
Routing mechanisms for prompts (api_url_prompt+api_response_prompt) remain are being used across distinct components.
|
9 |
-
"""
|
10 |
import asyncio
|
11 |
import os
|
12 |
import re
|
@@ -189,25 +184,32 @@ async def handle_message(message: cl.Message):
|
|
189 |
|
190 |
if response:
|
191 |
try:
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
except
|
210 |
-
|
|
|
211 |
|
212 |
else:
|
213 |
response = await llm_chain.ainvoke(
|
|
|
1 |
# ===================================================
|
2 |
+
# "the-very-latest-latest-POST-it"-----app.py
|
3 |
# ===================================================
|
4 |
+
|
|
|
|
|
|
|
|
|
|
|
5 |
import asyncio
|
6 |
import os
|
7 |
import re
|
|
|
184 |
|
185 |
if response:
|
186 |
try:
|
187 |
+
booking_data = json.loads(response)
|
188 |
+
table = "| Field | Information |\n|---|---|\n"
|
189 |
+
|
190 |
+
# Add each field with proper formatting
|
191 |
+
fields_mapping = [
|
192 |
+
('booking_id', 'Booking ID'),
|
193 |
+
('full_name', 'Full Name'),
|
194 |
+
('amount', 'Amount'),
|
195 |
+
('checkin', 'Check-in'),
|
196 |
+
('checkout', 'Check-out'),
|
197 |
+
('address', 'Address'),
|
198 |
+
('user_id', 'User ID'),
|
199 |
+
('infotext', 'Info Text'),
|
200 |
+
('included', 'Included')
|
201 |
+
]
|
202 |
+
|
203 |
+
for field, display_name in fields_mapping:
|
204 |
+
value = booking_data.get(field, 'N/A')
|
205 |
+
table += f"| {display_name} | {value} |\n"
|
206 |
+
|
207 |
+
|
208 |
+
await cl.Message(content=table).send()
|
209 |
|
210 |
+
except Exception as e:
|
211 |
+
error_msg = f"Error: Could not parse the booking information. Details: {str(e)}"
|
212 |
+
await cl.Message(error_msg).send()
|
213 |
|
214 |
else:
|
215 |
response = await llm_chain.ainvoke(
|