-
Notifications
You must be signed in to change notification settings - Fork 0
/
preparation
37 lines (31 loc) · 1.17 KB
/
preparation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
file_data = para.text.read()
# 添加下载按钮
st.download_button(
label="Download optimized file",
data=file_data,
file_name="example.txt",
mime="text/plain"
)
'''
# Initialize the language models and chains
llm = OpenAI(temperature=0.7, max_tokens=2500)
chain1 = LLMChain(llm=llm, prompt=prompt1)
chain4 = LLMChain(llm=llm, prompt=prompt4)
sequential_chain = SimpleSequentialChain(chains=[chain1, chain4])
# Add a button for the user to click after uploading a file
process_file_button = st.button("开始处理文件")
new_document = docx.Document()
if process_file_button:
for i in range(len(texts)):
st.write(texts[0])
response2 = sequential_chain.run(texts[0])
st.write(response2)
new_document.add_paragraph(response2)
with io.BytesIO() as output:
new_document.save(output)
output.seek(0)
st.download_button("下载处理后的 Word 文件", output, "processed.docx")
# Add a button for the user to restart the app
restart_button = st.button("重新开始")
if restart_button:
raise st.script_runner.StopException