Update app.py
Browse filesAdapt system message
app.py
CHANGED
@@ -34,6 +34,8 @@ Don't make up an answer or give irrelevant information not requested by the user
|
|
34 |
Otherwise, if relevant cases were found, start by summarizing these cases in the user's question's language and reference the sources, including the source, urls and dates.
|
35 |
"""
|
36 |
|
|
|
|
|
37 |
def respond(
|
38 |
message,
|
39 |
history: list[tuple[str, str]],
|
@@ -43,11 +45,6 @@ def respond(
|
|
43 |
top_p,
|
44 |
score,
|
45 |
):
|
46 |
-
messages = [{"role": "system", "content": system_message}]
|
47 |
-
|
48 |
-
print(system_message)
|
49 |
-
|
50 |
-
retriever = vector_db.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": score})
|
51 |
documents = retriever.invoke(message)
|
52 |
|
53 |
spacer = " \n"
|
@@ -63,17 +60,26 @@ def respond(
|
|
63 |
context += "Case url: " + doc.metadata["case_url"] + spacer
|
64 |
context += "Case text: " + doc.page_content + spacer
|
65 |
#context += "Case text: " + case_text[:8000] + spacer
|
66 |
-
|
67 |
-
|
68 |
-
message = f"""
|
69 |
-
The user is asking you the following question: {message}
|
70 |
The following case extracts have been found in either Swiss Federal Court or European Court of Human Rights cases and could fit the question:
|
71 |
{context}
|
72 |
-
Task: Always answer the user using the language used in his question
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
# for val in history:
|
78 |
# if val[0]:
|
79 |
# messages.append({"role": "user", "content": val[0]})
|
|
|
34 |
Otherwise, if relevant cases were found, start by summarizing these cases in the user's question's language and reference the sources, including the source, urls and dates.
|
35 |
"""
|
36 |
|
37 |
+
retriever = vector_db.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": score})
|
38 |
+
|
39 |
def respond(
|
40 |
message,
|
41 |
history: list[tuple[str, str]],
|
|
|
45 |
top_p,
|
46 |
score,
|
47 |
):
|
|
|
|
|
|
|
|
|
|
|
48 |
documents = retriever.invoke(message)
|
49 |
|
50 |
spacer = " \n"
|
|
|
60 |
context += "Case url: " + doc.metadata["case_url"] + spacer
|
61 |
context += "Case text: " + doc.page_content + spacer
|
62 |
#context += "Case text: " + case_text[:8000] + spacer
|
63 |
+
|
64 |
+
system_message += f"""
|
|
|
|
|
65 |
The following case extracts have been found in either Swiss Federal Court or European Court of Human Rights cases and could fit the question:
|
66 |
{context}
|
67 |
+
Task: Always answer the user using the language used in his question
|
68 |
+
"""
|
69 |
+
|
70 |
+
messages = [{"role": "system", "content": system_message}]
|
71 |
|
72 |
+
print(system_message)
|
73 |
+
|
74 |
+
# message = f"""
|
75 |
+
#The user is asking you the following question: {message}
|
76 |
+
#The following case extracts have been found in either Swiss Federal Court or European Court of Human Rights cases and could fit the question:
|
77 |
+
#{context}
|
78 |
+
#Task: Always answer the user using the language used in his question: {message}
|
79 |
+
# """
|
80 |
+
|
81 |
+
# print(message)
|
82 |
+
|
83 |
# for val in history:
|
84 |
# if val[0]:
|
85 |
# messages.append({"role": "user", "content": val[0]})
|