Spaces:
Runtime error
Runtime error
abhi001vj
commited on
Commit
·
44a4b54
1
Parent(s):
fe3f712
added the fileuplaod fix
Browse files
app.py
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
|
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import sys
|
| 3 |
-
import
|
| 4 |
-
from pathlib import Path
|
| 5 |
from json import JSONDecodeError
|
|
|
|
|
|
|
| 6 |
import pandas as pd
|
|
|
|
| 7 |
import streamlit as st
|
| 8 |
from annotated_text import annotation
|
| 9 |
-
from markdown import markdown
|
| 10 |
-
import json
|
| 11 |
from haystack import Document
|
| 12 |
-
import pandas as pd
|
| 13 |
from haystack.document_stores import PineconeDocumentStore
|
| 14 |
-
from haystack.nodes import
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
from sentence_transformers import SentenceTransformer
|
| 22 |
-
|
| 23 |
index_name = "qa_demo"
|
| 24 |
|
| 25 |
|
|
@@ -176,8 +182,8 @@ for data_file in data_files:
|
|
| 176 |
# Upload file
|
| 177 |
if data_file:
|
| 178 |
file_path = Path(FILE_UPLOAD_PATH) / f"{uuid.uuid4().hex}_{data_file.name}"
|
| 179 |
-
with
|
| 180 |
-
|
| 181 |
ALL_FILES.append(file_path)
|
| 182 |
st.sidebar.write(str(data_file.name) + " ✅ ")
|
| 183 |
META_DATA.append({"filename":data_file.name})
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import logging
|
| 3 |
import os
|
| 4 |
+
import shutil
|
| 5 |
import sys
|
| 6 |
+
import uuid
|
|
|
|
| 7 |
from json import JSONDecodeError
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
import pandas as pd
|
| 11 |
+
import pinecone
|
| 12 |
import streamlit as st
|
| 13 |
from annotated_text import annotation
|
|
|
|
|
|
|
| 14 |
from haystack import Document
|
|
|
|
| 15 |
from haystack.document_stores import PineconeDocumentStore
|
| 16 |
+
from haystack.nodes import (
|
| 17 |
+
DocxToTextConverter,
|
| 18 |
+
EmbeddingRetriever,
|
| 19 |
+
FARMReader,
|
| 20 |
+
FileTypeClassifier,
|
| 21 |
+
PDFToTextConverter,
|
| 22 |
+
PreProcessor,
|
| 23 |
+
TextConverter,
|
| 24 |
+
)
|
| 25 |
+
from haystack.pipelines import ExtractiveQAPipeline, Pipeline
|
| 26 |
+
from markdown import markdown
|
| 27 |
from sentence_transformers import SentenceTransformer
|
| 28 |
+
|
| 29 |
index_name = "qa_demo"
|
| 30 |
|
| 31 |
|
|
|
|
| 182 |
# Upload file
|
| 183 |
if data_file:
|
| 184 |
file_path = Path(FILE_UPLOAD_PATH) / f"{uuid.uuid4().hex}_{data_file.name}"
|
| 185 |
+
with open(file_path, "wb") as f:
|
| 186 |
+
f.write(data_file.getbuffer())
|
| 187 |
ALL_FILES.append(file_path)
|
| 188 |
st.sidebar.write(str(data_file.name) + " ✅ ")
|
| 189 |
META_DATA.append({"filename":data_file.name})
|