Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,13 +62,13 @@ PERSONVERNSPOLICY_QUESTIONS = [
|
|
62 |
"Endringer i denne policyen"
|
63 |
]
|
64 |
|
|
|
|
|
65 |
daysoff_assistant_template = """
|
66 |
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.no
|
67 |
By default, you respond in Norwegian language, using a warm, direct and professional tone.
|
68 |
You can look up booking information for a booking ID (bestillingskode)
|
69 |
-
and answer FAQ
|
70 |
-
If you do not know the answer, just reply truthfully that you do not have the answer rather than
|
71 |
-
giving inaccurate or speculative information.
|
72 |
Chat History: {chat_history}
|
73 |
Question: {question}
|
74 |
Answer:
|
@@ -90,19 +90,17 @@ API URL:
|
|
90 |
api_url_prompt = PromptTemplate(input_variables=['api_docs', 'question'],
|
91 |
template=api_url_template)
|
92 |
|
|
|
|
|
93 |
api_response_template = """
|
94 |
With the API Documentation for Daysoff's official API: {api_docs} in mind,
|
95 |
and the specific user question: {question},
|
96 |
and given this API URL: {api_url} for querying,
|
97 |
here is the response from Daysoff's API: {api_response}.
|
98 |
-
|
99 |
-
directly to the user without summarizing it.
|
100 |
-
For all other responses, please provide a clear and concise summary (in Norwegian) that directly addresses the user's question,
|
101 |
delivered in a manner that reflects the professionalism and warmth of a human customer service agent.
|
102 |
-
|
103 |
Summary:
|
104 |
"""
|
105 |
-
|
106 |
api_response_prompt = PromptTemplate(
|
107 |
input_variables=['api_docs', 'question', 'api_url', 'api_response'],
|
108 |
template=api_response_template
|
@@ -113,12 +111,12 @@ def setup_multiple_chains():
|
|
113 |
|
114 |
llm = OpenAI(
|
115 |
model='gpt-3.5-turbo-instruct',
|
116 |
-
temperature=0.
|
117 |
openai_api_key=OPENAI_API_KEY,
|
118 |
#max_tokens=512,
|
119 |
top_p=0.9,
|
120 |
-
frequency_penalty=0.
|
121 |
-
presence_penalty=0.
|
122 |
)
|
123 |
|
124 |
conversation_memory = ConversationBufferMemory(memory_key="chat_history",
|
@@ -171,8 +169,7 @@ async def handle_message(message: cl.Message):
|
|
171 |
callbacks=[cl.AsyncLangchainCallbackHandler()])
|
172 |
|
173 |
elif any(keyword in user_message for keyword in (FAQ_ANSATTE + FAQ_UTLEIERE + PERSONVERNSPOLICY_QUESTIONS)):
|
174 |
-
|
175 |
-
#elif any(keyword in user_message for keyword in faq_keywords):
|
176 |
response = await api_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
177 |
|
178 |
else:
|
|
|
62 |
"Endringer i denne policyen"
|
63 |
]
|
64 |
|
65 |
+
# If you do not know the answer, just reply truthfully that you do not have the answer rather than
|
66 |
+
# giving inaccurate or speculative information.
|
67 |
daysoff_assistant_template = """
|
68 |
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.no
|
69 |
By default, you respond in Norwegian language, using a warm, direct and professional tone.
|
70 |
You can look up booking information for a booking ID (bestillingskode)
|
71 |
+
and answer FAQ related to DaysOff firmahytteordning.
|
|
|
|
|
72 |
Chat History: {chat_history}
|
73 |
Question: {question}
|
74 |
Answer:
|
|
|
90 |
api_url_prompt = PromptTemplate(input_variables=['api_docs', 'question'],
|
91 |
template=api_url_template)
|
92 |
|
93 |
+
# If the response includes a booking ID (bestillingskode), consistently present this information
|
94 |
+
# directly to the user without summarizing it.
|
95 |
api_response_template = """
|
96 |
With the API Documentation for Daysoff's official API: {api_docs} in mind,
|
97 |
and the specific user question: {question},
|
98 |
and given this API URL: {api_url} for querying,
|
99 |
here is the response from Daysoff's API: {api_response}.
|
100 |
+
Please provide a clear and concise summary (in Norwegian) that directly addresses the user's question,
|
|
|
|
|
101 |
delivered in a manner that reflects the professionalism and warmth of a human customer service agent.
|
|
|
102 |
Summary:
|
103 |
"""
|
|
|
104 |
api_response_prompt = PromptTemplate(
|
105 |
input_variables=['api_docs', 'question', 'api_url', 'api_response'],
|
106 |
template=api_response_template
|
|
|
111 |
|
112 |
llm = OpenAI(
|
113 |
model='gpt-3.5-turbo-instruct',
|
114 |
+
temperature=0.3,
|
115 |
openai_api_key=OPENAI_API_KEY,
|
116 |
#max_tokens=512,
|
117 |
top_p=0.9,
|
118 |
+
frequency_penalty=0.1,
|
119 |
+
presence_penalty=0.1
|
120 |
)
|
121 |
|
122 |
conversation_memory = ConversationBufferMemory(memory_key="chat_history",
|
|
|
169 |
callbacks=[cl.AsyncLangchainCallbackHandler()])
|
170 |
|
171 |
elif any(keyword in user_message for keyword in (FAQ_ANSATTE + FAQ_UTLEIERE + PERSONVERNSPOLICY_QUESTIONS)):
|
172 |
+
#elif any(keyword in user_message for keyword in faq_keywords):
|
|
|
173 |
response = await api_chain.acall(user_message, callbacks=[cl.AsyncLangchainCallbackHandler()])
|
174 |
|
175 |
else:
|