Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,17 @@
|
|
3 |
# ver01.01-5.workload-----app.py
|
4 |
# ===========================================
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
import asyncio
|
7 |
import os
|
8 |
import re
|
@@ -21,27 +32,35 @@ from langchain.memory.buffer import ConversationBufferMemory
|
|
21 |
from langchain.memory import ConversationTokenBufferMemory
|
22 |
from langchain.memory import ConversationSummaryMemory
|
23 |
|
24 |
-
|
25 |
from api_docs_mck import api_docs_str
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
30 |
|
|
|
|
|
|
|
31 |
daysoff_assistant_template = """
|
32 |
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.
|
33 |
By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
34 |
-
Your expertise is exclusively in retrieving booking information for a given booking
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
Chat History: {chat_history}
|
40 |
Question: {question}
|
41 |
Answer:
|
42 |
"""
|
43 |
daysoff_assistant_prompt = PromptTemplate(
|
44 |
-
input_variables=['chat_history', 'question'],
|
45 |
template=daysoff_assistant_template
|
46 |
)
|
47 |
|
@@ -128,6 +147,10 @@ def setup_multiple_chains():
|
|
128 |
api_chain = APIChain.from_llm_and_api_docs(
|
129 |
llm=llm,
|
130 |
api_docs=api_docs_str,
|
|
|
|
|
|
|
|
|
131 |
api_url_prompt=api_url_prompt,
|
132 |
api_response_prompt=api_response_prompt,
|
133 |
verbose=True,
|
|
|
3 |
# ver01.01-5.workload-----app.py
|
4 |
# ===========================================
|
5 |
|
6 |
+
|
7 |
+
|
8 |
+
#You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.
|
9 |
+
#By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
10 |
+
#Your expertise is exclusively in retrieving booking information for a given booking ID assistance related to
|
11 |
+
#to this.
|
12 |
+
#You do not provide information outside of this scope. If a question is not about this topic, respond with
|
13 |
+
#"Ooops da, jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon. Gjelder det andre henvendelser,
|
14 |
+
#må du nok kontakte kundeservice på [email protected]😊"
|
15 |
+
|
16 |
+
|
17 |
import asyncio
|
18 |
import os
|
19 |
import re
|
|
|
32 |
from langchain.memory import ConversationTokenBufferMemory
|
33 |
from langchain.memory import ConversationSummaryMemory
|
34 |
|
|
|
35 |
from api_docs_mck import api_docs_str
|
36 |
+
from frequently_asked_questions import instruction_text, frequently_asked_questions
|
37 |
+
from personvernspolicy import instruction_text_priv, personvernspolicy_data
|
38 |
+
from frequently_asked_questions import instruction_text_faq, faq
|
39 |
+
|
40 |
|
41 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
42 |
|
43 |
+
|
44 |
+
|
45 |
+
# If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
46 |
daysoff_assistant_template = """
|
47 |
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.
|
48 |
By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
49 |
+
Your expertise is exclusively in retrieving booking information for a given booking id and answering
|
50 |
+
questions about firmahytteorning and personvernspolicy.
|
51 |
+
If a question does not involve booking information for a given booking id, ask: "Gjelder spørsmålet firmahytteordning?",
|
52 |
+
upon user confirmation, do your best to try to answer accordingly by referring to {instruction_text_faq} and {frequently_asked_questions}.
|
53 |
+
If a query does not involve booking information for a given booking id or firmahytteordning, ask: "Gjelder spørsmålet personvernspolicy?"
|
54 |
+
upon user confirmation, do your best to provide a precise privacy-related response by referring to: {instruction_text_priv} and {personvernspolicy_data}.
|
55 |
+
If the query does not involve booking information for a given booking id, firmahytteordning or personvernspolicy,
|
56 |
+
respond with: "Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon og ofte-stilte-spørsmål i forbindelse
|
57 |
+
med DaysOff firmahytteordning (inkludert personvernspolicyn). Gjelder det andre henvendelser, må du nok kontakte kundeservice på [email protected]😊"
|
58 |
Chat History: {chat_history}
|
59 |
Question: {question}
|
60 |
Answer:
|
61 |
"""
|
62 |
daysoff_assistant_prompt = PromptTemplate(
|
63 |
+
input_variables=['chat_history', 'question', "instruction_text_faq", "frequently_asked_questions", "instruction_text_priv", "personvernspolicy_data"],
|
64 |
template=daysoff_assistant_template
|
65 |
)
|
66 |
|
|
|
147 |
api_chain = APIChain.from_llm_and_api_docs(
|
148 |
llm=llm,
|
149 |
api_docs=api_docs_str,
|
150 |
+
instruction_text_faq=instruction_text_faq,
|
151 |
+
frequently_asked_questions=frequently_asked_questions,
|
152 |
+
instruction_text_priv=instruction_text_priv,
|
153 |
+
personvernspolicy_data=personvernspolicy_data,
|
154 |
api_url_prompt=api_url_prompt,
|
155 |
api_response_prompt=api_response_prompt,
|
156 |
verbose=True,
|