Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
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 |
-
|
127 |
-
|
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()
|
|