Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,14 @@ vector_db = FAISS.load_local("faiss_index_8k", embeddings, allow_dangerous_deser
|
|
27 |
|
28 |
df = pd.read_csv("faiss_index/bger_cedh_db 1954-2024.csv")
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
def respond(
|
31 |
message,
|
32 |
history: list[tuple[str, str]],
|
@@ -59,17 +67,10 @@ def respond(
|
|
59 |
|
60 |
|
61 |
message = f"""
|
62 |
-
|
63 |
-
|
64 |
-
Context:
|
65 |
-
The following case extracts are either Swiss Federal Court or European Court of Human Rights cases and have been found to fit the question :
|
66 |
{context}
|
67 |
-
Task:
|
68 |
-
If no relevant cases were retrieved or the issue has not been addressed within the context, just say "I can't find enough relevant information".
|
69 |
-
Don't make up an answer or give irrelevant information not requested by the user.
|
70 |
-
Otherwise, if relevant cases were found, start by summarizing these cases in the user's question's language and reference the sources, including the urls and dates.
|
71 |
-
Instructions:
|
72 |
-
Always answer the user using the language used in his question: {message}
|
73 |
"""
|
74 |
|
75 |
print(message)
|
@@ -103,7 +104,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
103 |
demo = gr.ChatInterface(
|
104 |
respond,
|
105 |
additional_inputs=[
|
106 |
-
gr.Textbox(value="
|
107 |
gr.Slider(minimum=1, maximum=24000, value=5000, step=1, label="Max new tokens"),
|
108 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
109 |
gr.Slider(
|
|
|
27 |
|
28 |
df = pd.read_csv("faiss_index/bger_cedh_db 1954-2024.csv")
|
29 |
|
30 |
+
"""
|
31 |
+
You are an assistant in Swiss Jurisprudence law.
|
32 |
+
Please answer the user in the same language that he used in his question using the following given context, not prior or other knowledge.
|
33 |
+
If no relevant cases were retrieved or the issue has not been addressed within the context, just say "I can't find enough relevant information".
|
34 |
+
Don't make up an answer or give irrelevant information not requested by the user and do not give any links that are not provided in the context.
|
35 |
+
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.
|
36 |
+
"""
|
37 |
+
|
38 |
def respond(
|
39 |
message,
|
40 |
history: list[tuple[str, str]],
|
|
|
67 |
|
68 |
|
69 |
message = f"""
|
70 |
+
The user is asking you the following question: {message}
|
71 |
+
The following case extracts have been found in either Swiss Federal Court or European Court of Human Rights cases and could fit the question:
|
|
|
|
|
72 |
{context}
|
73 |
+
Task: Always answer the user using the language used in his question: {message}
|
|
|
|
|
|
|
|
|
|
|
74 |
"""
|
75 |
|
76 |
print(message)
|
|
|
104 |
demo = gr.ChatInterface(
|
105 |
respond,
|
106 |
additional_inputs=[
|
107 |
+
gr.Textbox(value="", label="System message"),
|
108 |
gr.Slider(minimum=1, maximum=24000, value=5000, step=1, label="Max new tokens"),
|
109 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
110 |
gr.Slider(
|