umaiku commited on
Commit
a0ff377
·
verified ·
1 Parent(s): 21b494b

Update app.py

Browse files

Improve prompt

Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -50,25 +50,26 @@ def respond(
50
  for doc in documents:
51
  case_text = df[df["case_url"] == doc.metadata["case_url"]].case_text.values[0]
52
 
53
- context += "Case number: " + doc.metadata["case_nb"] + spacer
54
- context += "Case source: " + ("Swiss Federal Court" if doc.metadata["case_ref"] == "ATF" else "European Court of Human Rights") + spacer
55
- context += "Case date: " + doc.metadata["case_date"] + spacer
56
- context += "Case url: " + doc.metadata["case_url"] + spacer
57
- context += "Case text: " + doc.page_content + spacer
 
58
  #context += "Case text: " + case_text[:8000] + spacer
59
 
60
 
61
  message = f"""
62
  A user is asking you the following question: {message}
63
  Please answer the user in the same language that he used in his question using ONLY the following given context not any prior knowledge or information found on the internet.
64
- Context:
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:
68
  If the retrieved context is not relevant cases 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
 
 
50
  for doc in documents:
51
  case_text = df[df["case_url"] == doc.metadata["case_url"]].case_text.values[0]
52
 
53
+ context += "#######"
54
+ context += "# Case number: " + doc.metadata["case_nb"] + spacer
55
+ context += "# Case source: " + ("Swiss Federal Court" if doc.metadata["case_ref"] == "ATF" else "European Court of Human Rights") + spacer
56
+ context += "# Case date: " + doc.metadata["case_date"] + spacer
57
+ context += "# Case url: " + doc.metadata["case_url"] + spacer
58
+ context += "# Case text: " + doc.page_content + spacer
59
  #context += "Case text: " + case_text[:8000] + spacer
60
 
61
 
62
  message = f"""
63
  A user is asking you the following question: {message}
64
  Please answer the user in the same language that he used in his question using ONLY the following given context not any prior knowledge or information found on the internet.
65
+ # Context:
66
  The following case extracts have been found in either Swiss Federal Court or European Court of Human Rights cases and could fit the question:
67
  {context}
68
+ # Task:
69
  If the retrieved context is not relevant cases or the issue has not been addressed within the context, just say "I can't find enough relevant information".
70
  Don't make up an answer or give irrelevant information not requested by the user.
71
  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.
72
+ # Instructions:
73
  Always answer the user using the language used in his question: {message}
74
  """
75