diff options
| author | Dhravya Shah <[email protected]> | 2024-07-24 08:50:37 -0500 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2024-07-24 08:50:37 -0500 |
| commit | 726e642bba67e63b45d914871142b59e59065d5e (patch) | |
| tree | b1bbfb29d771924e886e198394df607d71e3580a /apps | |
| parent | Merge pull request #154 from supermemoryai/filtering (diff) | |
| download | supermemory-726e642bba67e63b45d914871142b59e59065d5e.tar.xz supermemory-726e642bba67e63b45d914871142b59e59065d5e.zip | |
fix weird wrangler problems in prod for recommendations]
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/app/actions/doers.ts | 29 | ||||
| -rw-r--r-- | apps/web/wrangler.toml | 24 |
2 files changed, 29 insertions, 24 deletions
diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts index 49863173..383efda7 100644 --- a/apps/web/app/actions/doers.ts +++ b/apps/web/app/actions/doers.ts @@ -24,6 +24,7 @@ import { redirect } from "next/navigation"; import { tweetToMd } from "@repo/shared-types/utils"; import { ensureAuth } from "../api/ensureAuth"; import { getRandomSentences } from "@/lib/utils"; +import { getRequestContext } from "@cloudflare/next-on-pages"; export const completeOnboarding = async (): ServerActionReturnType<boolean> => { const data = await auth(); @@ -35,10 +36,10 @@ export const completeOnboarding = async (): ServerActionReturnType<boolean> => { try { const res = await db - .update(users) - .set({ hasOnboarded: true }) - .where(eq(users.id, data.user.id)) - .returning({ hasOnboarded: users.hasOnboarded }); + .update(users) + .set({ hasOnboarded: true }) + .where(eq(users.id, data.user.id)) + .returning({ hasOnboarded: users.hasOnboarded }); if (res.length === 0 || !res[0]?.hasOnboarded) { return { success: false, data: false, error: "Failed to update user" }; @@ -48,9 +49,7 @@ export const completeOnboarding = async (): ServerActionReturnType<boolean> => { } catch (e) { return { success: false, data: false, error: (e as Error).message }; } - - -} +}; export const createSpace = async ( input: string | FormData, @@ -746,7 +745,9 @@ export async function getQuerySuggestions() { return { error: "Not authenticated", success: false }; } - const recommendations = await process.env.RECOMMENDATIONS.get(data.user.id); + const { env } = getRequestContext(); + + const recommendations = await env.RECOMMENDATIONS.get(data.user.id); if (recommendations) { return { @@ -775,7 +776,7 @@ export async function getQuerySuggestions() { const sentences = getRandomSentences(fullQuery); - const suggestionsCall = (await process.env.AI.run( + const suggestionsCall = (await env.AI.run( // @ts-ignore "@cf/meta/llama-3.1-8b-instruct", { @@ -829,13 +830,9 @@ export async function getQuerySuggestions() { }; } - await process.env.RECOMMENDATIONS.put( - data.user.id, - JSON.stringify(suggestions), - { - expirationTtl: 60 * 5, - }, - ); + await env.RECOMMENDATIONS.put(data.user.id, JSON.stringify(suggestions), { + expirationTtl: 60 * 5, + }); return { success: true, diff --git a/apps/web/wrangler.toml b/apps/web/wrangler.toml index 8f4c75db..4f97f786 100644 --- a/apps/web/wrangler.toml +++ b/apps/web/wrangler.toml @@ -3,6 +3,18 @@ compatibility_date = "2024-03-29" compatibility_flags = [ "nodejs_compat" ] pages_build_output_dir = ".vercel/output/static" + +kv_namespaces = [ + { binding = "CANVAS_SNAPS", id = "6df98c892b3744ccb0c631d9f60d6697" }, + { binding = "RECOMMENDATIONS", id = "83bc7055226c4657948141c2ff9a5425" } +] + +env.production.kv_namespaces = [ + { binding = "CANVAS_SNAPS", id = "6df98c892b3744ccb0c631d9f60d6697" }, + { binding = "RECOMMENDATIONS", id = "83bc7055226c4657948141c2ff9a5425" } +] + + [placement] mode = "smart" @@ -15,23 +27,19 @@ binding = "DATABASE" database_name = "dev-d1-anycontext" database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c" -[[kv_namespaces]] -binding = "CANVAS_SNAPS" -id = "c6446f7190dd4afebe1c318df3400518" - -[[kv_namespaces]] -binding = "RECOMMENDATIONS" -id = "83bc7055226c4657948141c2ff9a5425" [[env.production.d1_databases]] binding = "DATABASE" database_name = "prod-d1-supermemory" database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395" +[env.preview.ai] +binding = "AI" + [[env.preview.d1_databases]] binding = "DATABASE" database_name = "dev-d1-anycontext" database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c" -[ai] +[env.production.ai] binding = "AI"
\ No newline at end of file |