mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-19 07:42:43 +00:00
better error handling
This commit is contained in:
parent
568531f323
commit
eb2baf6f31
2 changed files with 10 additions and 4 deletions
|
|
@ -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());
|
||||
})();
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue