camparchimedes commited on
Commit
eec23c4
ยท
verified ยท
1 Parent(s): 68ee5fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -143,30 +143,26 @@ 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
- try:
147
- if re.search(booking_pattern, user_message):
148
- booking_id = re.search(booking_pattern, user_message).group(0)
149
- question = f"Retrieve information for booking ID {booking_id}"
150
 
151
- url = f"{base_url}?search={booking_id}"
152
-
153
- response = await api_chain.acall(
154
- {
155
- "booking_id": booking_id,
156
- "question": question,
157
- "url": url
158
- },
159
- callbacks=[cl.AsyncLangchainCallbackHandler()])
160
-
161
- else
162
- await cl.Message("Vi kan desverre ikke finne noen informasjon for det oppgitte bookingnummeret.").send()
163
-
164
- #response = await api_chain.acall({"booking_id": booking_id}, callbacks=[cl.AsyncLangchainCallbackHandler()])
165
- else
166
- response = await llm_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
167
-
168
- except Exception as e:
169
- response = {"output": "Jeg fรฅr desverre ikke fram din informasjon akkurat nรฅ."}
170
 
171
  response_key = "output" if "output" in response else "text"
172
  await cl.Message(response.get(response_key, "")).send()
 
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
+ "booking_id": booking_id,
155
+ "question": question,
156
+ "url": url
157
+ },
158
+ callbacks=[cl.AsyncLangchainCallbackHandler()])
159
+
160
+ else
161
+ ##await cl.Message("Vi kan desverre ikke finne noen informasjon for det oppgitte bookingnummeret.").send()
162
+
163
+ #response = await api_chain.acall({"booking_id": booking_id}, callbacks=[cl.AsyncLangchainCallbackHandler()])
164
+
165
+ response = await llm_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
 
 
 
166
 
167
  response_key = "output" if "output" in response else "text"
168
  await cl.Message(response.get(response_key, "")).send()