Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix/json format (#465)

Jyongc67ecff3fe38
diff --git a/api/core/data_loader/loader/excel.py b/api/core/data_loader/loader/excel.py
index 7dd62f50943..08c04627283 100644
--- a/api/core/data_loader/loader/excel.py
+++ b/api/core/data_loader/loader/excel.py
@@ -36,8 +36,9 @@ class ExcelLoader(BaseLoader):
if keys == []:
keys = list(map(str, row))
else:
- row_dict = dict(zip(keys, row))
+ row_dict = dict(zip(keys, list(map(str, row))))
row_dict = {k: v for k, v in row_dict.items() if v}
- data.append(json.dumps(row_dict, ensure_ascii=False))
+ item = ''.join(f'{k}:{v}\n' for k, v in row_dict.items())
+ data.append(item)
return [Document(page_content='\n\n'.join(data))]
diff --git a/api/core/data_loader/loader/notion.py b/api/core/data_loader/loader/notion.py
index 913128d9fe7..8235c58cf25 100644
--- a/api/core/data_loader/loader/notion.py
+++ b/api/core/data_loader/loader/notion.py
@@ -134,6 +134,16 @@ class NotionLoader(BaseLoader):
else:
value = property_value[type]
data[property_name] = value
+ row_dict = {k: v for k, v in data.items() if v}
+ row_content = ''
+ for key, value in row_dict.items():
+ if isinstance(value, dict):
+ value_dict = {k: v for k, v in value.items() if v}
+ value_content = ''.join(f'{k}:{v} ' for k, v in value_dict.items())
+ row_content = row_content + f'{key}:{value_content}\n'
+ else:
+ row_content = row_content + f'{key}:{value}\n'
+ database_content_list.append(row_content)
database_content_list.append(json.dumps(data, ensure_ascii=False))
return "\n\n".join(database_content_list)