Spaces:
Runtime error
Runtime error
improve prompt
Browse files
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
|
|
|
|
|
|
|
|
|
|
| 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 + "
|
| 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 và trả lời được ngăn cách bằng dấu <enter/>. Câu hỏi và 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
|