Update app.py
Browse files
app.py
CHANGED
|
@@ -82,16 +82,16 @@ def postprocess_answer(answer):
|
|
| 82 |
answer = answer.replace(phrase, "").strip()
|
| 83 |
|
| 84 |
# Viết hoa chữ cái đầu tiên (nếu cần thiết trong tiếng Nhật)
|
| 85 |
-
if answer and len(answer) > 0:
|
| 86 |
-
|
| 87 |
|
| 88 |
-
# Thêm dấu chấm cuối câu nếu thiếu
|
| 89 |
-
if answer and answer[-1] not in "。.?!":
|
| 90 |
-
|
| 91 |
|
| 92 |
-
# Nếu câu quá ngắn hoặc vô nghĩa, phản hồi mềm mại
|
| 93 |
-
if len(answer.split()) < 4:
|
| 94 |
-
|
| 95 |
|
| 96 |
return answer
|
| 97 |
|
|
@@ -130,8 +130,8 @@ def main():
|
|
| 130 |
with st.spinner("回答を生成中..."):
|
| 131 |
try:
|
| 132 |
result = qa_chain({"question": query})
|
| 133 |
-
|
| 134 |
-
|
| 135 |
|
| 136 |
|
| 137 |
st.markdown("### 回答")
|
|
|
|
| 82 |
answer = answer.replace(phrase, "").strip()
|
| 83 |
|
| 84 |
# Viết hoa chữ cái đầu tiên (nếu cần thiết trong tiếng Nhật)
|
| 85 |
+
# if answer and len(answer) > 0:
|
| 86 |
+
# answer = answer[0].upper() + answer[1:]
|
| 87 |
|
| 88 |
+
# # Thêm dấu chấm cuối câu nếu thiếu
|
| 89 |
+
# if answer and answer[-1] not in "。.?!":
|
| 90 |
+
# answer += "。"
|
| 91 |
|
| 92 |
+
# # Nếu câu quá ngắn hoặc vô nghĩa, phản hồi mềm mại
|
| 93 |
+
# if len(answer.split()) < 4:
|
| 94 |
+
# answer = "資料にはその件についての詳細な記載が見受けられませんが、以下のように推測されます:" + answer
|
| 95 |
|
| 96 |
return answer
|
| 97 |
|
|
|
|
| 130 |
with st.spinner("回答を生成中..."):
|
| 131 |
try:
|
| 132 |
result = qa_chain({"question": query})
|
| 133 |
+
raw_answer = result["result"]
|
| 134 |
+
answer = postprocess_answer(raw_answer)
|
| 135 |
|
| 136 |
|
| 137 |
st.markdown("### 回答")
|