nijoow commited on
Commit
e544064
Β·
1 Parent(s): d6c66ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -13,6 +13,7 @@ from langchain.llms import HuggingFaceHub, LlamaCpp, CTransformers # For loadin
13
  from langchain.document_loaders import PyPDFLoader, TextLoader, JSONLoader, CSVLoader
14
  import tempfile # μž„μ‹œ νŒŒμΌμ„ μƒμ„±ν•˜κΈ° μœ„ν•œ λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
15
  import os
 
16
 
17
  for file in docs:
18
  print('file -type : ',file.type)
@@ -95,7 +96,7 @@ def get_conversation_chain(vectorstore):
95
  return conversation_chain
96
 
97
  # μ‚¬μš©μž μž…λ ₯을 μ²˜λ¦¬ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
98
- def handle_userinput(user_question, docs):
99
  # λŒ€ν™” 체인을 μ‚¬μš©ν•˜μ—¬ μ‚¬μš©μž μ§ˆλ¬Έμ— λŒ€ν•œ 응닡을 μƒμ„±ν•©λ‹ˆλ‹€.
100
  response = st.session_state.conversation({'question': user_question})
101
  # λŒ€ν™” 기둝을 μ €μž₯ν•©λ‹ˆλ‹€.
@@ -123,10 +124,8 @@ def main():
123
 
124
  st.header("Chat with multiple Files :")
125
  user_question = st.text_input("Ask a question about your documents:")
126
- docs = st.file_uploader(
127
- "Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
128
- if user_question and docs:
129
- handle_userinput(user_question, docs)
130
 
131
  with st.sidebar:
132
  openai_key = st.text_input("Paste your OpenAI API key (sk-...)")
@@ -134,6 +133,8 @@ def main():
134
  os.environ["OPENAI_API_KEY"] = openai_key
135
 
136
  st.subheader("Your documents")
 
 
137
  if st.button("Process"):
138
  with st.spinner("Processing"):
139
  # get pdf text
@@ -167,4 +168,3 @@ def main():
167
 
168
  if __name__ == '__main__':
169
  main()
170
-
 
13
  from langchain.document_loaders import PyPDFLoader, TextLoader, JSONLoader, CSVLoader
14
  import tempfile # μž„μ‹œ νŒŒμΌμ„ μƒμ„±ν•˜κΈ° μœ„ν•œ λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
15
  import os
16
+ import docs
17
 
18
  for file in docs:
19
  print('file -type : ',file.type)
 
96
  return conversation_chain
97
 
98
  # μ‚¬μš©μž μž…λ ₯을 μ²˜λ¦¬ν•˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
99
+ def handle_userinput(user_question):
100
  # λŒ€ν™” 체인을 μ‚¬μš©ν•˜μ—¬ μ‚¬μš©μž μ§ˆλ¬Έμ— λŒ€ν•œ 응닡을 μƒμ„±ν•©λ‹ˆλ‹€.
101
  response = st.session_state.conversation({'question': user_question})
102
  # λŒ€ν™” 기둝을 μ €μž₯ν•©λ‹ˆλ‹€.
 
124
 
125
  st.header("Chat with multiple Files :")
126
  user_question = st.text_input("Ask a question about your documents:")
127
+ if user_question:
128
+ handle_userinput(user_question)
 
 
129
 
130
  with st.sidebar:
131
  openai_key = st.text_input("Paste your OpenAI API key (sk-...)")
 
133
  os.environ["OPENAI_API_KEY"] = openai_key
134
 
135
  st.subheader("Your documents")
136
+ docs = st.file_uploader(
137
+ "Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
138
  if st.button("Process"):
139
  with st.spinner("Processing"):
140
  # get pdf text
 
168
 
169
  if __name__ == '__main__':
170
  main()