umaiku commited on
Commit
6399f7b
·
verified ·
1 Parent(s): 167d891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -83,17 +83,28 @@ def respond(message, history: list[tuple[str, str]], system_message, max_tokens,
83
  print(datetime.now())
84
  context = retriever_tool(message)
85
 
86
- prompt = f"""Given the question and supporting documents below, give a comprehensive answer to the question.
87
- Respond only to the question asked, response should be relevant to the question and in the same language as the question.
88
- Provide the number of the source document when relevant, as well as the link to the document.
89
- If you cannot find information, do not give up and try calling your retriever again with different arguments!
90
- Always give url of the sources at the end and only answer in the language the question is asked.
 
 
 
 
 
 
 
 
91
 
92
- Question:
93
- {message}
94
 
95
- {context}
96
- """
 
 
 
97
 
98
  messages = [{"role": "system", "content": system_message}]
99
 
 
83
  print(datetime.now())
84
  context = retriever_tool(message)
85
 
86
+ is_law = client.text_generation(f"""Given the user question below, classify it as either being about "Law" or "Other".
87
+ Do NOT respond with more than one word.
88
+ Question:
89
+ {message}""")
90
+
91
+ print(is_law)
92
+
93
+ if is_law.lower() != "other":
94
+ prompt = f"""Given the question and supporting documents below, give a comprehensive answer to the question.
95
+ Respond only to the question asked, response should be relevant to the question and in the same language as the question.
96
+ Provide the number of the source document when relevant, as well as the link to the document.
97
+ If you cannot find information, do not give up and try calling your retriever again with different arguments!
98
+ Always give url of the sources at the end and only answer in the language the question is asked.
99
 
100
+ Question:
101
+ {message}
102
 
103
+ {context}
104
+ """
105
+ else:
106
+ prompt = f"""A user wrote the following message, please answer him to best of your knowledge in the language of his message:
107
+ {message}"""
108
 
109
  messages = [{"role": "system", "content": system_message}]
110