Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -66,22 +66,21 @@ def handle_query(query):
|
|
66 |
elif isinstance(answer, dict) and 'response' in answer:
|
67 |
return answer['response']
|
68 |
else:
|
69 |
-
return "
|
70 |
|
71 |
|
72 |
# Streamlit app initialization
|
73 |
-
st.title("
|
74 |
-
st.markdown("
|
75 |
-
st.markdown("chat here👇")
|
76 |
|
77 |
if 'messages' not in st.session_state:
|
78 |
-
st.session_state.messages = [{'role': 'assistant', "content": '
|
79 |
|
80 |
with st.sidebar:
|
81 |
-
st.title("
|
82 |
-
uploaded_file = st.file_uploader("
|
83 |
-
if st.button("
|
84 |
-
with st.spinner("
|
85 |
filepath = "data/saved_pdf.pdf"
|
86 |
with open(filepath, "wb") as f:
|
87 |
f.write(uploaded_file.getbuffer())
|
@@ -89,7 +88,7 @@ with st.sidebar:
|
|
89 |
data_ingestion() # Process PDF every time new file is uploaded
|
90 |
st.success("Done")
|
91 |
|
92 |
-
user_prompt = st.chat_input("
|
93 |
if user_prompt:
|
94 |
st.session_state.messages.append({'role': 'user', "content": user_prompt})
|
95 |
response = handle_query(user_prompt)
|
|
|
66 |
elif isinstance(answer, dict) and 'response' in answer:
|
67 |
return answer['response']
|
68 |
else:
|
69 |
+
return "抱歉,我找不到答案。"
|
70 |
|
71 |
|
72 |
# Streamlit app initialization
|
73 |
+
st.title("与您的PDF聊天 🦜📄")
|
74 |
+
st.markdown("在这里聊天👇")
|
|
|
75 |
|
76 |
if 'messages' not in st.session_state:
|
77 |
+
st.session_state.messages = [{'role': 'assistant', "content": '你好啊!上传一个PDF,并询问我有关其内容的任何信息。'}]
|
78 |
|
79 |
with st.sidebar:
|
80 |
+
st.title("上传PDF:")
|
81 |
+
uploaded_file = st.file_uploader("上传您的PDF文件并点击提交&处理按钮")
|
82 |
+
if st.button("提交"):
|
83 |
+
with st.spinner("处理中..."):
|
84 |
filepath = "data/saved_pdf.pdf"
|
85 |
with open(filepath, "wb") as f:
|
86 |
f.write(uploaded_file.getbuffer())
|
|
|
88 |
data_ingestion() # Process PDF every time new file is uploaded
|
89 |
st.success("Done")
|
90 |
|
91 |
+
user_prompt = st.chat_input("问我关于PDF的内容:")
|
92 |
if user_prompt:
|
93 |
st.session_state.messages.append({'role': 'user', "content": user_prompt})
|
94 |
response = handle_query(user_prompt)
|