stack86 commited on
Commit
545e1d8
·
verified ·
1 Parent(s): 3960f65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
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 "Sorry, I couldn't find an answer."
70
 
71
 
72
  # Streamlit app initialization
73
- st.title("Chat with your PDF 🦜📄")
74
- st.markdown("Built by [Suriya❤️](https://github.com/theSuriya)")
75
- st.markdown("chat here👇")
76
 
77
  if 'messages' not in st.session_state:
78
- st.session_state.messages = [{'role': 'assistant', "content": 'Hello! Upload a PDF and ask me anything about its content.'}]
79
 
80
  with st.sidebar:
81
- st.title("Menu:")
82
- uploaded_file = st.file_uploader("Upload your PDF Files and Click on the Submit & Process Button")
83
- if st.button("Submit & Process"):
84
- with st.spinner("Processing..."):
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("Ask me anything about the content of the PDF:")
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)