diff options
| author | Dhravya Shah <[email protected]> | 2024-07-23 23:38:32 -0500 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2024-07-23 23:38:32 -0500 |
| commit | eb2baf6f315969e6689df05c30eeb34def480700 (patch) | |
| tree | 076990834e990a9f4f0c06f2012541d5840b0ca6 | |
| parent | added recommended items (diff) | |
| download | supermemory-eb2baf6f315969e6689df05c30eeb34def480700.tar.xz supermemory-eb2baf6f315969e6689df05c30eeb34def480700.zip | |
better error handling
| -rw-r--r-- | apps/web/app/(dash)/home/history.tsx | 3 | ||||
| -rw-r--r-- | apps/web/app/actions/doers.ts | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/apps/web/app/(dash)/home/history.tsx b/apps/web/app/(dash)/home/history.tsx index 3e6825eb..e09a5c82 100644 --- a/apps/web/app/(dash)/home/history.tsx +++ b/apps/web/app/(dash)/home/history.tsx @@ -16,10 +16,11 @@ const History = memo(({ setQuery }: { setQuery: (q: string) => void }) => { const suggestions = await getQuerySuggestions(); if (!suggestions.success || !suggestions.data) { console.error(suggestions.error); + setSuggestions([]); return; } console.log(suggestions); - setSuggestions(suggestions.data.reverse().slice(0, 3)); + setSuggestions(suggestions.data.reverse()); })(); }, []); diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts index 0c1aa8d9..eaf98497 100644 --- a/apps/web/app/actions/doers.ts +++ b/apps/web/app/actions/doers.ts @@ -734,9 +734,16 @@ export async function getQuerySuggestions() { .from(storedContent) .where(eq(storedContent.userId, data.user.id)) .orderBy(sql`random()`) - .limit(3) + .limit(5) .all(); + if (content.length === 0) { + return { + success: true, + data: [], + }; + } + const fullQuery = content.map((c) => `${c.title} \n\n${c.content}`).join(" "); const sentences = getRandomSentences(fullQuery); @@ -788,8 +795,6 @@ export async function getQuerySuggestions() { const suggestions = suggestionsCall.tool_calls?.[0]?.arguments?.querySuggestions; - console.log(suggestions); - if (!suggestions || suggestions.length === 0) { return { success: false, |