Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,7 @@
|
|
5 |
|
6 |
|
7 |
|
8 |
-
|
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
|
@@ -35,31 +29,27 @@ from langchain.memory import ConversationTokenBufferMemory
|
|
35 |
from langchain.memory import ConversationSummaryMemory
|
36 |
|
37 |
from api_docs_mck import api_docs_str
|
38 |
-
from personvernspolicy import instruction_text_priv, personvernspolicy_data
|
39 |
-
from frequently_asked_questions import instruction_text_faq, faq
|
40 |
|
41 |
|
42 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
43 |
|
44 |
# If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
45 |
daysoff_assistant_template = """
|
46 |
-
You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.
|
47 |
-
By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
48 |
-
Your expertise is exclusively in retrieving booking information for a given booking
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
upon user confirmation, do your best to provide a precise privacy-related response by referring to: {instruction_text_priv} and {personvernspolicy_data}.
|
54 |
-
If the query does not involve booking information for a given booking id, firmahytteordning or personvernspolicy,
|
55 |
-
respond with: "Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon og ofte-stilte-spørsmål i forbindelse
|
56 |
-
med DaysOff firmahytteordning (inkludert personvernspolicyn). Gjelder det andre henvendelser, må du nok kontakte kundeservice på [email protected]😊"
|
57 |
Chat History: {chat_history}
|
58 |
Question: {question}
|
59 |
Answer:
|
60 |
"""
|
61 |
daysoff_assistant_prompt = PromptTemplate(
|
62 |
-
input_variables=['chat_history', 'question'
|
63 |
template=daysoff_assistant_template
|
64 |
)
|
65 |
|
@@ -137,23 +127,10 @@ def setup_multiple_chains():
|
|
137 |
#)
|
138 |
|
139 |
|
140 |
-
class LLMChainConfig(BaseModel):
|
141 |
-
model_config = ConfigDict(extra='allow')
|
142 |
-
instruction_text_faq: str
|
143 |
-
faq: dict
|
144 |
-
instruction_text_priv: str
|
145 |
-
personvernspolicy_data: dict
|
146 |
-
|
147 |
llm_chain = LLMChain(
|
148 |
llm=llm,
|
149 |
prompt=daysoff_assistant_prompt,
|
150 |
memory=conversation_memory,
|
151 |
-
**LLMChainConfig(
|
152 |
-
instruction_text_faq=instruction_text_faq,
|
153 |
-
faq=faq,
|
154 |
-
instruction_text_priv=instruction_text_priv,
|
155 |
-
personvernspolicy_data=personvernspolicy_data
|
156 |
-
).model_dump()
|
157 |
)
|
158 |
|
159 |
cl.user_session.set("llm_chain", llm_chain)
|
|
|
5 |
|
6 |
|
7 |
|
8 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
import asyncio
|
|
|
29 |
from langchain.memory import ConversationSummaryMemory
|
30 |
|
31 |
from api_docs_mck import api_docs_str
|
32 |
+
#from personvernspolicy import instruction_text_priv, personvernspolicy_data
|
33 |
+
#from frequently_asked_questions import instruction_text_faq, faq
|
34 |
|
35 |
|
36 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
37 |
|
38 |
# If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
39 |
daysoff_assistant_template = """
|
40 |
+
#You are a customer support assistant (’kundeservice AI assistent’) for Daysoff.
|
41 |
+
#By default, you respond in Norwegian language, using a warm, direct, and professional tone.
|
42 |
+
Your expertise is exclusively in retrieving booking information for a given booking ID assistance related to
|
43 |
+
#to this.
|
44 |
+
You do not provide information outside of this scope. If a question is not about this topic, respond with
|
45 |
+
"Jeg driver faktisk kun med henvendelser omkring bestillingsinformasjon. Gjelder det andre henvendelser,
|
46 |
+
må du nok kontakte kundeservice på [email protected]😊"
|
|
|
|
|
|
|
|
|
47 |
Chat History: {chat_history}
|
48 |
Question: {question}
|
49 |
Answer:
|
50 |
"""
|
51 |
daysoff_assistant_prompt = PromptTemplate(
|
52 |
+
input_variables=['chat_history', 'question'],
|
53 |
template=daysoff_assistant_template
|
54 |
)
|
55 |
|
|
|
127 |
#)
|
128 |
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
llm_chain = LLMChain(
|
131 |
llm=llm,
|
132 |
prompt=daysoff_assistant_prompt,
|
133 |
memory=conversation_memory,
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
)
|
135 |
|
136 |
cl.user_session.set("llm_chain", llm_chain)
|