mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-10 22:41:17 +00:00
fix weird wrangler problems in prod for recommendations]
This commit is contained in:
parent
3f8075a02c
commit
726e642bba
2 changed files with 29 additions and 24 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
Loading…
Add table
Reference in a new issue