Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
|
2 |
# ===========================================
|
3 |
-
# ver2-----app.py
|
4 |
# ===========================================
|
5 |
|
6 |
-
|
7 |
-
|
8 |
import asyncio
|
9 |
import os
|
10 |
import re
|
@@ -143,19 +141,30 @@ async def handle_message(message: cl.Message):
|
|
143 |
booking_pattern = r'\b[A-Z]{6}\d{6}\b'
|
144 |
base_url = "https://670dccd0073307b4ee447f2f.mockapi.io/daysoff/api/V1/booking"
|
145 |
|
146 |
-
if re.search(booking_pattern, user_message):
|
147 |
-
booking_id = re.search(booking_pattern, user_message).group(0)
|
148 |
-
question = f"Retrieve information for booking ID {booking_id}"
|
149 |
-
|
150 |
-
url = f"{base_url}?search={booking_id}"
|
151 |
|
|
|
|
|
|
|
|
|
152 |
response = await api_chain.acall(
|
153 |
{
|
154 |
-
"
|
155 |
-
"question": question
|
156 |
-
|
157 |
},
|
158 |
callbacks=[cl.AsyncLangchainCallbackHandler()])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
else:
|
161 |
##await cl.Message("Vi kan desverre ikke finne noen informasjon for det oppgitte bookingnummeret.").send()
|
|
|
1 |
|
2 |
# ===========================================
|
3 |
+
# ver2.01-----app.py
|
4 |
# ===========================================
|
5 |
|
|
|
|
|
6 |
import asyncio
|
7 |
import os
|
8 |
import re
|
|
|
141 |
booking_pattern = r'\b[A-Z]{6}\d{6}\b'
|
142 |
base_url = "https://670dccd0073307b4ee447f2f.mockapi.io/daysoff/api/V1/booking"
|
143 |
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
+
if re.search(booking_pattern, user_message):
|
146 |
+
bestillingskode = re.search(booking_pattern, user_message).group(0)
|
147 |
+
question = f"Retrieve information for booking ID {base_url}?search={bestillingskode}"
|
148 |
+
|
149 |
response = await api_chain.acall(
|
150 |
{
|
151 |
+
"bestillingskode": bestillingskode,
|
152 |
+
"question": question
|
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()
|