hohieu commited on
Commit
1be63fa
1 Parent(s): a8516ec

improve prompt

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -43,7 +43,10 @@ def generateAnswer(context: str, question: str):
43
  prompt = ChatPromptTemplate.from_messages(
44
  [
45
  (
46
- "user","""Trả lời câu hỏi của người dùng dựa vào thông tin trong thẻ <context> </context> được cho bên dưới. Nếu context không chứa những thông tin liên quan tới câu hỏi, thì đừng trả lời chỉ trả lời "Tôi không biết". <context> {context} </context> Câu hỏi: {question}""",
 
 
 
47
  ),
48
  ]
49
  )
@@ -101,7 +104,7 @@ if prompt := st.chat_input(""):
101
  index = 0
102
  for document in results:
103
  posibleQuestions = posibleQuestions + f"<li>{document['question']}</li>"
104
- context =context + "\n\n" + document['question'] + ": " + document['answer']
105
  if index == 0:
106
  question = document["question"]
107
  index = index + 1
 
43
  prompt = ChatPromptTemplate.from_messages(
44
  [
45
  (
46
+ "user","""Trả lời câu hỏi dựa trên thông tin trong thẻ <context>. Mỗi cặp câu hỏi trả lời được ngăn cách bằng dấu <enter/>. Câu hỏi trả lời được phân tách bằng dấu <space/>.
47
+ Nếu không có thông tin liên quan trong context, chỉ trả lời "Tôi không biết".
48
+ Câu trả lời ngắn và súc tích, nhấn mạnh vào những điểm chính từ thông tin trong context.
49
+ <context>{context}</context> Câu hỏi: {question}""",
50
  ),
51
  ]
52
  )
 
104
  index = 0
105
  for document in results:
106
  posibleQuestions = posibleQuestions + f"<li>{document['question']}</li>"
107
+ context =context + "<enter/>" + document['question'] + "<space/> " + document['answer']
108
  if index == 0:
109
  question = document["question"]
110
  index = index + 1