浏览代码

fix: memory

Timothy J. Baek 11 月之前
父节点
当前提交
8ec3934599
共有 2 个文件被更改,包括 16 次插入12 次删除
  1. 8 6
      src/routes/(app)/+page.svelte
  2. 8 6
      src/routes/(app)/c/[id]/+page.svelte

+ 8 - 6
src/routes/(app)/+page.svelte

@@ -264,12 +264,14 @@
 			});
 			});
 
 
 			if (res) {
 			if (res) {
-				userContext = res.documents.reduce((acc, doc, index) => {
-					const createdAtTimestamp = res.metadatas[index][0].created_at;
-					const createdAtDate = new Date(createdAtTimestamp * 1000).toISOString().split('T')[0];
-					acc.push(`${index + 1}. [${createdAtDate}]. ${doc[0]}`);
-					return acc;
-				}, []);
+				if (res.documents[0].length > 0) {
+					userContext = res.documents.reduce((acc, doc, index) => {
+						const createdAtTimestamp = res.metadatas[index][0].created_at;
+						const createdAtDate = new Date(createdAtTimestamp * 1000).toISOString().split('T')[0];
+						acc.push(`${index + 1}. [${createdAtDate}]. ${doc[0]}`);
+						return acc;
+					}, []);
+				}
 
 
 				console.log(userContext);
 				console.log(userContext);
 			}
 			}

+ 8 - 6
src/routes/(app)/c/[id]/+page.svelte

@@ -270,12 +270,14 @@
 			});
 			});
 
 
 			if (res) {
 			if (res) {
-				userContext = res.documents.reduce((acc, doc, index) => {
-					const createdAtTimestamp = res.metadatas[index][0].created_at;
-					const createdAtDate = new Date(createdAtTimestamp * 1000).toISOString().split('T')[0];
-					acc.push(`${index + 1}. [${createdAtDate}]. ${doc[0]}`);
-					return acc;
-				}, []);
+				if (res.documents[0].length > 0) {
+					userContext = res.documents.reduce((acc, doc, index) => {
+						const createdAtTimestamp = res.metadatas[index][0].created_at;
+						const createdAtDate = new Date(createdAtTimestamp * 1000).toISOString().split('T')[0];
+						acc.push(`${index + 1}. [${createdAtDate}]. ${doc[0]}`);
+						return acc;
+					}, []);
+				}
 
 
 				console.log(userContext);
 				console.log(userContext);
 			}
 			}