Update app.py
Browse files
app.py
CHANGED
@@ -29,18 +29,25 @@ load_dotenv()
|
|
29 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
30 |
auth_token = os.environ.get("DAYSOFF_API_TOKEN")
|
31 |
|
32 |
-
# API endpoint
|
33 |
API_URL = "https://aivisions.no/data/daysoff/api/v1/booking/"
|
34 |
|
35 |
-
|
36 |
daysoff_assistant_template = """
|
37 |
#You are a customer support assistant (โkundeservice AI assistentโ) for Daysoff.
|
38 |
#By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
39 |
-
Your expertise is exclusively in retrieving booking information for a given booking ID assistance related to
|
40 |
to this.
|
41 |
-
You
|
|
|
|
|
|
|
|
|
|
|
42 |
"Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon. Gjelder det andre henvendelser
|
43 |
mรฅ du nok kontakte kundeservice pรฅ [email protected]๐"
|
|
|
|
|
|
|
44 |
"""
|
45 |
daysoff_assistant_prompt = PromptTemplate(
|
46 |
input_variables=["chat_history", "question"],
|
@@ -104,20 +111,23 @@ async def handle_message(message: cl.Message):
|
|
104 |
booking_data = response.json()
|
105 |
|
106 |
if "booking_id" in booking_data:
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
121 |
else:
|
122 |
await cl.Message(content="Booking not found or invalid response.").send()
|
123 |
except requests.exceptions.RequestException as e:
|
@@ -135,7 +145,3 @@ async def handle_message(message: cl.Message):
|
|
135 |
await cl.Message(content=f"Error: {str(e)}").send()
|
136 |
|
137 |
|
138 |
-
|
139 |
-
#response_key = "output" if "output" in response else "text"
|
140 |
-
#await cl.Message(response.get(response_key, "")).send()
|
141 |
-
#return message.content
|
|
|
29 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
30 |
auth_token = os.environ.get("DAYSOFF_API_TOKEN")
|
31 |
|
|
|
32 |
API_URL = "https://aivisions.no/data/daysoff/api/v1/booking/"
|
33 |
|
34 |
+
|
35 |
daysoff_assistant_template = """
|
36 |
#You are a customer support assistant (โkundeservice AI assistentโ) for Daysoff.
|
37 |
#By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
38 |
+
Your expertise is exclusively in retrieving booking information for a given booking ID and assistance related to
|
39 |
to this.
|
40 |
+
#You should always provide a clear and concise answer (in Norwegian) of the booking information retrieved.
|
41 |
+
#The best way to ensure professionalism and relevance is to ppresent the answer in a markdown table.
|
42 |
+
#This way you directly address the user's question in a manner that reflects the professionalism and warmth
|
43 |
+
#of a human customer service agent.
|
44 |
+
You do not provide information outside of this scope. If a question is not about this topic, adapt to user's query
|
45 |
+
and respond with something like
|
46 |
"Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon. Gjelder det andre henvendelser
|
47 |
mรฅ du nok kontakte kundeservice pรฅ [email protected]๐"
|
48 |
+
Chat History: {chat_history}
|
49 |
+
Question: {question}
|
50 |
+
Answer:
|
51 |
"""
|
52 |
daysoff_assistant_prompt = PromptTemplate(
|
53 |
input_variables=["chat_history", "question"],
|
|
|
111 |
booking_data = response.json()
|
112 |
|
113 |
if "booking_id" in booking_data:
|
114 |
+
|
115 |
+
table = (
|
116 |
+
"| Field | Info |\n"
|
117 |
+
"|:-----------|:---------------------|\n"
|
118 |
+
f"| Booking ID | {booking_data.get('booking_id', 'N/A')} |\n"
|
119 |
+
f"| Full Name | {booking_data.get('full_name', 'N/A')} |\n"
|
120 |
+
f"| Amount | {booking_data.get('amount', 0)} |\n"
|
121 |
+
f"| Check-in | {booking_data.get('checkin', 'N/A')} |\n"
|
122 |
+
f"| Check-out | {booking_data.get('checkout', 'N/A')} |\n"
|
123 |
+
f"| Address | {booking_data.get('address', 'N/A')} |\n"
|
124 |
+
f"| User ID | {booking_data.get('user_id', 0)} |\n"
|
125 |
+
f"| Info Text | {booking_data.get('infotext', 'N/A')} |\n"
|
126 |
+
f"| Included | {booking_data.get('included', 'N/A')} |"
|
127 |
+
)
|
128 |
+
|
129 |
+
await cl.Message(content=table).send()
|
130 |
+
|
131 |
else:
|
132 |
await cl.Message(content="Booking not found or invalid response.").send()
|
133 |
except requests.exceptions.RequestException as e:
|
|
|
145 |
await cl.Message(content=f"Error: {str(e)}").send()
|
146 |
|
147 |
|
|
|
|
|
|
|
|