Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,13 +46,14 @@ def get_csv_file(csv_docs):
|
|
| 46 |
csv_doc = csv_loader.load()
|
| 47 |
return csv_doc
|
| 48 |
|
| 49 |
-
def get_json_file(json_docs):
|
| 50 |
temp_dir = tempfile.TemporaryDirectory()
|
| 51 |
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
| 52 |
with open(temp_filepath, "wb") as f:
|
| 53 |
f.write(json_docs.getvalue())
|
| 54 |
json_loader = JSONLoader(temp_filepath,
|
| 55 |
-
|
|
|
|
| 56 |
json_doc = json_loader.load()
|
| 57 |
return json_doc
|
| 58 |
|
|
@@ -151,7 +152,7 @@ def main():
|
|
| 151 |
doc_list.extend(get_csv_file(file))
|
| 152 |
elif file.type == 'application/json':
|
| 153 |
# file is .json
|
| 154 |
-
doc_list.extend(get_json_file(file))
|
| 155 |
|
| 156 |
# get the text chunks
|
| 157 |
text_chunks = get_text_chunks(doc_list)
|
|
|
|
| 46 |
csv_doc = csv_loader.load()
|
| 47 |
return csv_doc
|
| 48 |
|
| 49 |
+
def get_json_file(json_docs, jq_schema):
|
| 50 |
temp_dir = tempfile.TemporaryDirectory()
|
| 51 |
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
| 52 |
with open(temp_filepath, "wb") as f:
|
| 53 |
f.write(json_docs.getvalue())
|
| 54 |
json_loader = JSONLoader(temp_filepath,
|
| 55 |
+
jq_schema,
|
| 56 |
+
text_content=False)
|
| 57 |
json_doc = json_loader.load()
|
| 58 |
return json_doc
|
| 59 |
|
|
|
|
| 152 |
doc_list.extend(get_csv_file(file))
|
| 153 |
elif file.type == 'application/json':
|
| 154 |
# file is .json
|
| 155 |
+
doc_list.extend(get_json_file(file, jq_schema))
|
| 156 |
|
| 157 |
# get the text chunks
|
| 158 |
text_chunks = get_text_chunks(doc_list)
|