Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -49,42 +49,12 @@ BOOKING_KEYWORDS = [
|
|
49 |
]
|
50 |
|
51 |
daysoff_assistant_template = """
|
52 |
-
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff named "Agrippa".
|
53 |
-
|
54 |
-
|
55 |
-
questions about Daysoff's personvernspolicy and firmahytteordning.
|
56 |
-
|
57 |
-
|
58 |
-
- By default, you respond in Norwegian language
|
59 |
-
- Prioritize customer satisfaction and question-answering
|
60 |
-
- Provide clear, concise, and helpful responses
|
61 |
-
- Use a friendly, professional, and approachable tone
|
62 |
-
|
63 |
-
Interaction Protocol:
|
64 |
-
4. Never fabricate information
|
65 |
-
5. Ask clarifying questions if the query is ambiguous
|
66 |
-
6. Always transparent about information limitations
|
67 |
-
7. Prioritize precision over verbosity
|
68 |
-
|
69 |
-
Persona Characteristics:
|
70 |
-
- Gender: female
|
71 |
-
- Role: customer support assistant for Dayoff.no
|
72 |
-
- Communication Style: Warm, direct, solution-oriented
|
73 |
-
- Brand Personality: Helpful, efficient, trustworthy
|
74 |
-
|
75 |
-
Response Structure:
|
76 |
-
- Directly address the user's question
|
77 |
-
- Provide step-by-step guidance if applicable
|
78 |
-
|
79 |
-
Ethical Constraints:
|
80 |
-
- Stay within the scope of Dayoff.no's services
|
81 |
-
- Maintain customer privacy
|
82 |
-
- Avoid sharing sensitive personal information
|
83 |
-
- Refer complex issues to human support at [email protected] when necessary
|
84 |
-
|
85 |
-
Special Instructions:
|
86 |
-
- Adapt communication complexity to the customer's apparent technical understanding
|
87 |
-
- Proactively suggest solutions based on contextual information
|
88 |
Chat History: {chat_history}
|
89 |
Question: {question}
|
90 |
Answer:
|
@@ -116,6 +86,7 @@ Please provide an summary that directly addresses the user's question,
|
|
116 |
omitting technical details like response format, and
|
117 |
focusing on delivering the answer with clarity and conciseness,
|
118 |
as if a human customer service agent is providing this information.
|
|
|
119 |
Summary:
|
120 |
"""
|
121 |
|
@@ -181,7 +152,7 @@ async def handle_message(message: cl.Message):
|
|
181 |
llm_chain = cl.user_session.get("llm_chain")
|
182 |
api_chain = cl.user_session.get("api_chain")
|
183 |
|
184 |
-
api_keywords = ["firmahytteordning", "personvernspolicy"]
|
185 |
|
186 |
try:
|
187 |
# --check message for booking ID
|
@@ -190,7 +161,7 @@ async def handle_message(message: cl.Message):
|
|
190 |
response = await api_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
191 |
|
192 |
# --check message for API keywords
|
193 |
-
elif any(keyword in user_message
|
194 |
logging.debug(f"API keyword detected in message: {user_message}")
|
195 |
response = await api_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
196 |
|
@@ -200,7 +171,7 @@ async def handle_message(message: cl.Message):
|
|
200 |
|
201 |
except Exception as e:
|
202 |
logging.error(f"Error in processing message: {str(e)}")
|
203 |
-
response = {"output": "
|
204 |
|
205 |
response_key = "output" if "output" in response else "text"
|
206 |
await cl.Message(response.get(response_key, "")).send()
|
|
|
49 |
]
|
50 |
|
51 |
daysoff_assistant_template = """
|
52 |
+
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff named "Agrippa".
|
53 |
+
By default, you respond in Norwegian language, using a warm, direct and professional tone. Your expertise
|
54 |
+
is in retrieving booking information associated with a specific booking ID and answering
|
55 |
+
questions about Daysoff's personvernspolicy and firmahytteordning.
|
56 |
+
Directly address the user's question but stay within the scope of Dayoff.no's services.
|
57 |
+
If needed, inform user that they can find human support at [email protected].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
Chat History: {chat_history}
|
59 |
Question: {question}
|
60 |
Answer:
|
|
|
86 |
omitting technical details like response format, and
|
87 |
focusing on delivering the answer with clarity and conciseness,
|
88 |
as if a human customer service agent is providing this information.
|
89 |
+
By default, you respond in Norwegian language.
|
90 |
Summary:
|
91 |
"""
|
92 |
|
|
|
152 |
llm_chain = cl.user_session.get("llm_chain")
|
153 |
api_chain = cl.user_session.get("api_chain")
|
154 |
|
155 |
+
# api_keywords = ["firmahytteordning", "personvernspolicy"]
|
156 |
|
157 |
try:
|
158 |
# --check message for booking ID
|
|
|
161 |
response = await api_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
162 |
|
163 |
# --check message for API keywords
|
164 |
+
elif any(keyword in user_message for keyword in ["firmahytteordning", "personvernspolicy"]): # any(keyword in user_message for keyword in api_keywords):
|
165 |
logging.debug(f"API keyword detected in message: {user_message}")
|
166 |
response = await api_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
167 |
|
|
|
171 |
|
172 |
except Exception as e:
|
173 |
logging.error(f"Error in processing message: {str(e)}")
|
174 |
+
response = {"output": "Jeg får desverre ikke hentet fram din informasjon akkurat nå."}
|
175 |
|
176 |
response_key = "output" if "output" in response else "text"
|
177 |
await cl.Message(response.get(response_key, "")).send()
|