diff --git a/apps/web/app/(dash)/home/history.tsx b/apps/web/app/(dash)/home/history.tsx index e09a5c82..c1f8d9d4 100644 --- a/apps/web/app/(dash)/home/history.tsx +++ b/apps/web/app/(dash)/home/history.tsx @@ -20,7 +20,7 @@ const History = memo(({ setQuery }: { setQuery: (q: string) => void }) => { return; } console.log(suggestions); - setSuggestions(suggestions.data.reverse()); + setSuggestions(suggestions.data.reverse().slice(0, 3)); })(); }, []); diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts index 12d2c29e..fbccd195 100644 --- a/apps/web/app/actions/doers.ts +++ b/apps/web/app/actions/doers.ts @@ -777,8 +777,6 @@ export async function getQuerySuggestions() { .map((c) => `${c.title} \n\n${c.content}`) .join(" "); - const sentences = getRandomSentences(fullQuery); - const suggestionsCall = (await env.AI.run( // @ts-ignore "@cf/meta/llama-3.1-8b-instruct", @@ -786,11 +784,11 @@ export async function getQuerySuggestions() { messages: [ { role: "system", - content: `You are a model that suggests questions based on the user's content.`, + content: `You are a model that suggests questions based on the user's content. you MUST suggest atleast 1 question to ask. Create 3 suggestions at most.`, }, { role: "user", - content: `Run the function based on this input: ${sentences}`, + content: `Run the function based on this input: ${fullQuery.slice(0, 2000)}`, }, ], tools: [ @@ -823,6 +821,11 @@ export async function getQuerySuggestions() { tool_calls: { name: string; arguments: { querySuggestions: string[] } }[]; }; + console.log( + "I RAN AN AI CALLS OWOWOWOWOW", + JSON.stringify(suggestionsCall, null, 2), + ); + const suggestions = suggestionsCall.tool_calls?.[0]?.arguments?.querySuggestions; @@ -833,9 +836,11 @@ export async function getQuerySuggestions() { }; } - await env.RECOMMENDATIONS.put(data.user.id, JSON.stringify(suggestions), { - expirationTtl: 60 * 2, - }); + if (suggestions.length > 0) { + await env.RECOMMENDATIONS.put(data.user.id, JSON.stringify(suggestions), { + expirationTtl: 60 * 2, + }); + } return { success: true, diff --git a/apps/web/server/db/index.ts b/apps/web/server/db/index.ts index 4d671bea..a9ec9106 100644 --- a/apps/web/server/db/index.ts +++ b/apps/web/server/db/index.ts @@ -2,4 +2,7 @@ import { drizzle } from "drizzle-orm/d1"; import * as schema from "./schema"; -export const db = drizzle(process.env.DATABASE, { schema, logger: true }); +export const db = drizzle(process.env.DATABASE, { + schema, + logger: process.env.NODE_ENV === "development", +}); diff --git a/apps/web/wrangler.toml b/apps/web/wrangler.toml index 4f97f786..7f3fa047 100644 --- a/apps/web/wrangler.toml +++ b/apps/web/wrangler.toml @@ -14,6 +14,8 @@ env.production.kv_namespaces = [ { binding = "RECOMMENDATIONS", id = "83bc7055226c4657948141c2ff9a5425" } ] +[ai] +binding = "AI" [placement] mode = "smart"