Update pages/Translate.py
Browse files- pages/Translate.py +10 -3
pages/Translate.py
CHANGED
@@ -29,6 +29,8 @@ with st.sidebar:
|
|
29 |
st.caption('markdown')
|
30 |
else:
|
31 |
st.caption('latex')
|
|
|
|
|
32 |
|
33 |
|
34 |
def get_translate_and_conclude(question: str, step: int):
|
@@ -114,6 +116,11 @@ if prompt := st.chat_input():
|
|
114 |
translate_result = chat_container.chat_message("ai").write_stream(response)
|
115 |
st.session_state.translate_messages.append({'role': 'assistant', 'content': translate_result})
|
116 |
|
|
|
|
|
|
|
|
|
|
|
117 |
if st.session_state.get('trans_conclusion'):
|
118 |
query = "接下来,请用两到四句话总结一下这段文本的内容"
|
119 |
chat_container.chat_message("human").write(query)
|
@@ -125,13 +132,13 @@ if prompt := st.chat_input():
|
|
125 |
st.session_state.translate_messages.append({'role': 'assistant', 'content': conclusion_result})
|
126 |
|
127 |
if st.session_state.get('trans_text_mode'):
|
128 |
-
markdown_text
|
129 |
else:
|
130 |
-
markdown_text
|
131 |
markdown_text = markdown_text.replace('%', r'\%')
|
132 |
st.session_state.markdown_text = markdown_text
|
133 |
else:
|
134 |
-
markdown_text
|
135 |
st.session_state.markdown_text = markdown_text
|
136 |
|
137 |
st.rerun()
|
|
|
29 |
st.caption('markdown')
|
30 |
else:
|
31 |
st.caption('latex')
|
32 |
+
|
33 |
+
st.toggle('双语输出', key='trans_en_output')
|
34 |
|
35 |
|
36 |
def get_translate_and_conclude(question: str, step: int):
|
|
|
116 |
translate_result = chat_container.chat_message("ai").write_stream(response)
|
117 |
st.session_state.translate_messages.append({'role': 'assistant', 'content': translate_result})
|
118 |
|
119 |
+
if st.session_state.get('trans_en_output'):
|
120 |
+
markdown_text = f"""{prompt}\t\n\n"""
|
121 |
+
else:
|
122 |
+
markdown_text = ""
|
123 |
+
|
124 |
if st.session_state.get('trans_conclusion'):
|
125 |
query = "接下来,请用两到四句话总结一下这段文本的内容"
|
126 |
chat_container.chat_message("human").write(query)
|
|
|
132 |
st.session_state.translate_messages.append({'role': 'assistant', 'content': conclusion_result})
|
133 |
|
134 |
if st.session_state.get('trans_text_mode'):
|
135 |
+
markdown_text += f"""{translate_result}\t\r\n> {conclusion_result}"""
|
136 |
else:
|
137 |
+
markdown_text += f"""{translate_result}\n\n\\tbox{{ {conclusion_result} }}"""
|
138 |
markdown_text = markdown_text.replace('%', r'\%')
|
139 |
st.session_state.markdown_text = markdown_text
|
140 |
else:
|
141 |
+
markdown_text += f"""{translate_result}"""
|
142 |
st.session_state.markdown_text = markdown_text
|
143 |
|
144 |
st.rerun()
|