diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index cbb925fde..ce4362215 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -264,12 +264,14 @@ }); 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); } diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 8680895e0..8f9051d61 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -270,12 +270,14 @@ }); 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); }