1) mod system prompt for stability, 2) add warning to page footer

This commit is contained in:
deng
2025-11-05 07:16:49 +08:00
parent 562b917b89
commit 3d67380408
2 changed files with 26 additions and 14 deletions

View File

@ -25,8 +25,8 @@ class EmbraceLifeApp:
return return
system_template = ( system_template = (
'你是臺灣民法專家,請判斷接下來自書遺囑內容在請立囑人親筆書寫簽名後是否有效,' '你是臺灣民法專家,請判斷接下來自書遺囑內容在請立囑人親筆書寫簽名後是否有效遺囑'
'有效的話則回傳有效,無效的話請一百字內告訴我哪些內容需要修改。' '的話則回傳沒問題,否的話請一百字內只要告訴我哪些內容需要修改。'
) )
user_template = '{input_text}' user_template = '{input_text}'
@ -54,9 +54,9 @@ class EmbraceLifeApp:
with st.expander('流程說明'): with st.expander('流程說明'):
st.write(""" st.write("""
1. 請填入以下所有資料 1. 請填入以下所有資料
2. 點擊「製作」產生遺囑內容 2. 點擊「製作」產生遺囑草稿,建議由專業人員(律師)協助審閱
3. 準備紙筆,由立囑人親筆謄寫所有遺囑內容 3. 準備紙筆,由立囑人親筆謄寫所有遺囑內容
4. 妥善保存紙本遺囑,並將保存地點告訴遺囑執行人 4. 妥善保存紙本遺囑,並將保存地點告訴遺囑執行人
""") """)
# 3) Testator Info # 3) Testator Info
@ -160,6 +160,8 @@ class EmbraceLifeApp:
day=datetime.now().day, day=datetime.now().day,
) )
st.code(self._will_content, language=None) st.code(self._will_content, language=None)
col1, col2, _, _, _ = st.columns(5)
with col1:
st.download_button( st.download_button(
label='下載', label='下載',
data=self._will_content, data=self._will_content,
@ -167,15 +169,24 @@ class EmbraceLifeApp:
mime='text/plain', mime='text/plain',
icon=':material/download:', icon=':material/download:',
) )
ai_check_button = ai_check_button = st.button('AI校稿', icon=':material/search:') with col2:
ai_check_button = ai_check_button = st.button('AI審閱', icon=':material/search:')
if ai_check_button: if ai_check_button:
with st.spinner('校稿中...'): with st.spinner('校稿中...'):
result = self._chain.stream({'input_text': self._will_content}) result = self._chain.invoke({'input_text': self._will_content}).content
st.write_stream(result) if result == '沒問題':
st.success(result)
else:
st.info(result)
else: else:
st.warning('請填入所有資料') st.warning('請填入所有資料')
# Footer
st.divider()
footer_text = f'<div style="text-align:center"><p>{self._config["app"]["page_footer_text"]}</p></div>'
st.markdown(footer_text, unsafe_allow_html=True)
if __name__ == '__main__': if __name__ == '__main__':
app = EmbraceLifeApp() app = EmbraceLifeApp()

View File

@ -2,6 +2,7 @@ app:
page_title: 自書遺囑製作 page_title: 自書遺囑製作
page_description: 這是一封重新擁抱生命的書信,也是對所愛之人的一份溫柔承諾。 page_description: 這是一封重新擁抱生命的書信,也是對所愛之人的一份溫柔承諾。
page_favicon_path: ./assets/favicon.jpg page_favicon_path: ./assets/favicon.jpg
page_footer_text: ⚠️ 本AI工具產生之文件為遺囑草稿範本僅供參考使用不具法律效力請交由專業律師審閱並依《民法》規定之方式製作
openai: openai:
model_name: gpt-4.1-mini model_name: gpt-4.1-mini
max_tokens: 1024 max_tokens: 1024