diff options
| author | Dhravya Shah <[email protected]> | 2025-01-30 18:31:46 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-01-30 18:31:46 -0700 |
| commit | 65ffa81f1aed5dca6ad34816090b3066299696fb (patch) | |
| tree | 7a1af2317d13f1ca32282cff6962edbe380599ed /apps/backend/src | |
| parent | fix: internal server error (diff) | |
| download | archived-supermemory-65ffa81f1aed5dca6ad34816090b3066299696fb.tar.xz archived-supermemory-65ffa81f1aed5dca6ad34816090b3066299696fb.zip | |
auto-provision changes
Diffstat (limited to 'apps/backend/src')
| -rw-r--r-- | apps/backend/src/routes/actions.ts | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/apps/backend/src/routes/actions.ts b/apps/backend/src/routes/actions.ts index 1ac02fdd..142d2a01 100644 --- a/apps/backend/src/routes/actions.ts +++ b/apps/backend/src/routes/actions.ts @@ -469,7 +469,6 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() try { // Generate embedding for the search query - const embeddings = await c.env.AI.run("@cf/baai/bge-base-en-v1.5", { text: query, }); @@ -503,7 +502,7 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() ) .orderBy( sql`1 - (embeddings <=> ${JSON.stringify(embeddings.data[0])}::vector) desc` - ) //figure out a better way to do order by my brain isn't working at this time. but youcan't do vector search twice + ) .limit(limit); return c.json({ @@ -623,7 +622,24 @@ const actions = new Hono<{ Variables: Variables; Bindings: Env }>() .limit(1); if (!space[0]) { - return { spaceId, allowed: false, error: "Space not found" }; + // create a new space for the user with the given id + const newSpace = await db + .insert(spaceInDb) + .values({ + uuid: spaceId, + name: spaceId, + isPublic: false, + ownerId: user.id, + createdAt: new Date(), + updatedAt: new Date(), + }) + .returning(); + + return { + spaceId: newSpace[0].id, + allowed: true, + error: null, + }; } const spaceData = space[0] as Space; |