mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
set up cf ai worker
This commit is contained in:
parent
eba818ffb4
commit
5bfb731e03
30 changed files with 179 additions and 177 deletions
|
|
@ -1 +1 @@
|
|||
Dzt6IsHhCHGe9WiNGLhTL
|
||||
OaB3peodHjkZq3Assb5S1
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
{
|
||||
"pages": {
|
||||
"/not-found": [
|
||||
"static/chunks/webpack-511881c2eef3fe2b.js",
|
||||
"static/chunks/webpack-363780e1c974ae15.js",
|
||||
"static/chunks/30b509c0-d7721ce4b2012053.js",
|
||||
"static/chunks/25-2f3c60275645c813.js",
|
||||
"static/chunks/main-app-8b951cccf46caf8d.js",
|
||||
"static/chunks/app/not-found-dbc30055295c6650.js"
|
||||
],
|
||||
"/layout": [
|
||||
"static/chunks/webpack-511881c2eef3fe2b.js",
|
||||
"static/chunks/webpack-363780e1c974ae15.js",
|
||||
"static/chunks/30b509c0-d7721ce4b2012053.js",
|
||||
"static/chunks/25-2f3c60275645c813.js",
|
||||
"static/chunks/main-app-8b951cccf46caf8d.js",
|
||||
"static/css/f49cbca4efddb667.css",
|
||||
"static/chunks/app/layout-8724649705a2decf.js"
|
||||
"static/css/cd3763a5087d66d7.css",
|
||||
"static/chunks/app/layout-7fc1a26d3b06a390.js"
|
||||
],
|
||||
"/page": [
|
||||
"static/chunks/webpack-511881c2eef3fe2b.js",
|
||||
"static/chunks/webpack-363780e1c974ae15.js",
|
||||
"static/chunks/30b509c0-d7721ce4b2012053.js",
|
||||
"static/chunks/25-2f3c60275645c813.js",
|
||||
"static/chunks/main-app-8b951cccf46caf8d.js",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"/favicon.ico/route":"/favicon.ico","/api/[...nextauth]/route":"/api/[...nextauth]","/api/hello/route":"/api/hello","/page":"/","/_not-found":"/_not-found","/api/store/route":"/api/store"}
|
||||
{"/favicon.ico/route":"/favicon.ico","/api/[...nextauth]/route":"/api/[...nextauth]","/_not-found":"/_not-found","/page":"/","/api/store/route":"/api/store","/api/hello/route":"/api/hello"}
|
||||
|
|
@ -5,24 +5,24 @@
|
|||
"devFiles": [],
|
||||
"ampDevFiles": [],
|
||||
"lowPriorityFiles": [
|
||||
"static/Dzt6IsHhCHGe9WiNGLhTL/_buildManifest.js",
|
||||
"static/Dzt6IsHhCHGe9WiNGLhTL/_ssgManifest.js"
|
||||
"static/OaB3peodHjkZq3Assb5S1/_buildManifest.js",
|
||||
"static/OaB3peodHjkZq3Assb5S1/_ssgManifest.js"
|
||||
],
|
||||
"rootMainFiles": [
|
||||
"static/chunks/webpack-511881c2eef3fe2b.js",
|
||||
"static/chunks/webpack-363780e1c974ae15.js",
|
||||
"static/chunks/30b509c0-d7721ce4b2012053.js",
|
||||
"static/chunks/25-2f3c60275645c813.js",
|
||||
"static/chunks/main-app-8b951cccf46caf8d.js"
|
||||
],
|
||||
"pages": {
|
||||
"/_app": [
|
||||
"static/chunks/webpack-511881c2eef3fe2b.js",
|
||||
"static/chunks/webpack-363780e1c974ae15.js",
|
||||
"static/chunks/framework-c25027af42eb8c45.js",
|
||||
"static/chunks/main-2d7b2ac4e61285c5.js",
|
||||
"static/chunks/pages/_app-508d387925ef2fa9.js"
|
||||
],
|
||||
"/_error": [
|
||||
"static/chunks/webpack-511881c2eef3fe2b.js",
|
||||
"static/chunks/webpack-363780e1c974ae15.js",
|
||||
"static/chunks/framework-c25027af42eb8c45.js",
|
||||
"static/chunks/main-2d7b2ac4e61285c5.js",
|
||||
"static/chunks/pages/_error-e16765248192e4ee.js"
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
self.__PRERENDER_MANIFEST="{\"version\":4,\"routes\":{\"/favicon.ico\":{\"initialHeaders\":{\"cache-control\":\"public, max-age=0, must-revalidate\",\"content-type\":\"image/x-icon\",\"x-next-cache-tags\":\"_N_T_/layout,_N_T_/favicon.ico/layout,_N_T_/favicon.ico/route,_N_T_/favicon.ico\"},\"experimentalBypassFor\":[{\"type\":\"header\",\"key\":\"Next-Action\"},{\"type\":\"header\",\"key\":\"content-type\",\"value\":\"multipart/form-data\"}],\"initialRevalidateSeconds\":false,\"srcRoute\":\"/favicon.ico\",\"dataRoute\":null}},\"dynamicRoutes\":{},\"notFoundRoutes\":[],\"preview\":{\"previewModeId\":\"28df19619c2e1683a407a6323c063b4e\",\"previewModeSigningKey\":\"5ed17b233dddac246ccc5bc2348bbac695490faf8a0d6aeedd74563724bdbcb2\",\"previewModeEncryptionKey\":\"17c5ff193df2829a76126e357e9c8602037791ec19c8cb6f80e61203027eccde\"}}"
|
||||
self.__PRERENDER_MANIFEST="{\"version\":4,\"routes\":{\"/favicon.ico\":{\"initialHeaders\":{\"cache-control\":\"public, max-age=0, must-revalidate\",\"content-type\":\"image/x-icon\",\"x-next-cache-tags\":\"_N_T_/layout,_N_T_/favicon.ico/layout,_N_T_/favicon.ico/route,_N_T_/favicon.ico\"},\"experimentalBypassFor\":[{\"type\":\"header\",\"key\":\"Next-Action\"},{\"type\":\"header\",\"key\":\"content-type\",\"value\":\"multipart/form-data\"}],\"initialRevalidateSeconds\":false,\"srcRoute\":\"/favicon.ico\",\"dataRoute\":null}},\"dynamicRoutes\":{},\"notFoundRoutes\":[],\"preview\":{\"previewModeId\":\"92fd96037866b5b4b21d0d0e3d3c89a7\",\"previewModeSigningKey\":\"5f32c1e389592c2eef6cb19ba8f03f76432dcbae3a51929dc428c86076f7e54e\",\"previewModeEncryptionKey\":\"1481818f54786afb3e193735b1a444c6213869c1606f6d63e0e839a88bf6a456\"}}"
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":4,"routes":{"/favicon.ico":{"initialHeaders":{"cache-control":"public, max-age=0, must-revalidate","content-type":"image/x-icon","x-next-cache-tags":"_N_T_/layout,_N_T_/favicon.ico/layout,_N_T_/favicon.ico/route,_N_T_/favicon.ico"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data"}],"initialRevalidateSeconds":false,"srcRoute":"/favicon.ico","dataRoute":null}},"dynamicRoutes":{},"notFoundRoutes":[],"preview":{"previewModeId":"28df19619c2e1683a407a6323c063b4e","previewModeSigningKey":"5ed17b233dddac246ccc5bc2348bbac695490faf8a0d6aeedd74563724bdbcb2","previewModeEncryptionKey":"17c5ff193df2829a76126e357e9c8602037791ec19c8cb6f80e61203027eccde"}}
|
||||
{"version":4,"routes":{"/favicon.ico":{"initialHeaders":{"cache-control":"public, max-age=0, must-revalidate","content-type":"image/x-icon","x-next-cache-tags":"_N_T_/layout,_N_T_/favicon.ico/layout,_N_T_/favicon.ico/route,_N_T_/favicon.ico"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data"}],"initialRevalidateSeconds":false,"srcRoute":"/favicon.ico","dataRoute":null}},"dynamicRoutes":{},"notFoundRoutes":[],"preview":{"previewModeId":"92fd96037866b5b4b21d0d0e3d3c89a7","previewModeSigningKey":"5f32c1e389592c2eef6cb19ba8f03f76432dcbae3a51929dc428c86076f7e54e","previewModeEncryptionKey":"1481818f54786afb3e193735b1a444c6213869c1606f6d63e0e839a88bf6a456"}}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"/favicon.ico/route": "app/favicon.ico/route.js",
|
||||
"/api/[...nextauth]/route": "app/api/[...nextauth]/route.js",
|
||||
"/api/hello/route": "app/api/hello/route.js",
|
||||
"/page": "app/page.js",
|
||||
"/_not-found": "app/_not-found.js",
|
||||
"/api/store/route": "app/api/store/route.js"
|
||||
"/page": "app/page.js",
|
||||
"/api/store/route": "app/api/store/route.js",
|
||||
"/api/hello/route": "app/api/hello/route.js"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
{"version":1,"functions":{"/api/[...nextauth]":{},"/api/hello":{},"/":{},"/_not-found":{},"/api/store":{}}}
|
||||
{"version":1,"functions":{"/api/[...nextauth]":{},"/_not-found":{},"/api/store":{},"/api/hello":{},"/":{}}}
|
||||
|
|
@ -1 +1 @@
|
|||
self.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-c67a75d1b6f99dc8.js"],devFiles:[],ampDevFiles:[],lowPriorityFiles:["static/Dzt6IsHhCHGe9WiNGLhTL/_buildManifest.js","static/Dzt6IsHhCHGe9WiNGLhTL/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-511881c2eef3fe2b.js","static/chunks/30b509c0-d7721ce4b2012053.js","static/chunks/25-2f3c60275645c813.js","static/chunks/main-app-8b951cccf46caf8d.js"],pages:{"/_app":["static/chunks/webpack-511881c2eef3fe2b.js","static/chunks/framework-c25027af42eb8c45.js","static/chunks/main-2d7b2ac4e61285c5.js","static/chunks/pages/_app-508d387925ef2fa9.js"],"/_error":["static/chunks/webpack-511881c2eef3fe2b.js","static/chunks/framework-c25027af42eb8c45.js","static/chunks/main-2d7b2ac4e61285c5.js","static/chunks/pages/_error-e16765248192e4ee.js"]},ampFirstPages:[]};
|
||||
self.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-c67a75d1b6f99dc8.js"],devFiles:[],ampDevFiles:[],lowPriorityFiles:["static/OaB3peodHjkZq3Assb5S1/_buildManifest.js","static/OaB3peodHjkZq3Assb5S1/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-363780e1c974ae15.js","static/chunks/30b509c0-d7721ce4b2012053.js","static/chunks/25-2f3c60275645c813.js","static/chunks/main-app-8b951cccf46caf8d.js"],pages:{"/_app":["static/chunks/webpack-363780e1c974ae15.js","static/chunks/framework-c25027af42eb8c45.js","static/chunks/main-2d7b2ac4e61285c5.js","static/chunks/pages/_app-508d387925ef2fa9.js"],"/_error":["static/chunks/webpack-363780e1c974ae15.js","static/chunks/framework-c25027af42eb8c45.js","static/chunks/main-2d7b2ac4e61285c5.js","static/chunks/pages/_error-e16765248192e4ee.js"]},ampFirstPages:[]};
|
||||
|
|
@ -22,48 +22,6 @@
|
|||
"wasm": [],
|
||||
"assets": []
|
||||
},
|
||||
"/api/hello/route": {
|
||||
"files": [
|
||||
"server/middleware-build-manifest.js",
|
||||
"server/middleware-react-loadable-manifest.js",
|
||||
"server/next-font-manifest.js",
|
||||
"prerender-manifest.js",
|
||||
"server/edge-runtime-webpack.js",
|
||||
"server/app/api/hello/route.js"
|
||||
],
|
||||
"name": "app/api/hello/route",
|
||||
"page": "/api/hello/route",
|
||||
"matchers": [
|
||||
{
|
||||
"regexp": "^/api/hello$",
|
||||
"originalSource": "/api/hello"
|
||||
}
|
||||
],
|
||||
"wasm": [],
|
||||
"assets": []
|
||||
},
|
||||
"/page": {
|
||||
"files": [
|
||||
"server/server-reference-manifest.js",
|
||||
"server/app/page_client-reference-manifest.js",
|
||||
"server/middleware-build-manifest.js",
|
||||
"server/middleware-react-loadable-manifest.js",
|
||||
"server/next-font-manifest.js",
|
||||
"prerender-manifest.js",
|
||||
"server/edge-runtime-webpack.js",
|
||||
"server/app/page.js"
|
||||
],
|
||||
"name": "app/page",
|
||||
"page": "/page",
|
||||
"matchers": [
|
||||
{
|
||||
"regexp": "^/$",
|
||||
"originalSource": "/"
|
||||
}
|
||||
],
|
||||
"wasm": [],
|
||||
"assets": []
|
||||
},
|
||||
"/_not-found": {
|
||||
"files": [
|
||||
"server/server-reference-manifest.js",
|
||||
|
|
@ -86,6 +44,28 @@
|
|||
"wasm": [],
|
||||
"assets": []
|
||||
},
|
||||
"/page": {
|
||||
"files": [
|
||||
"server/server-reference-manifest.js",
|
||||
"server/app/page_client-reference-manifest.js",
|
||||
"server/middleware-build-manifest.js",
|
||||
"server/middleware-react-loadable-manifest.js",
|
||||
"server/next-font-manifest.js",
|
||||
"prerender-manifest.js",
|
||||
"server/edge-runtime-webpack.js",
|
||||
"server/app/page.js"
|
||||
],
|
||||
"name": "app/page",
|
||||
"page": "/page",
|
||||
"matchers": [
|
||||
{
|
||||
"regexp": "^/$",
|
||||
"originalSource": "/"
|
||||
}
|
||||
],
|
||||
"wasm": [],
|
||||
"assets": []
|
||||
},
|
||||
"/api/store/route": {
|
||||
"files": [
|
||||
"server/middleware-build-manifest.js",
|
||||
|
|
@ -105,6 +85,26 @@
|
|||
],
|
||||
"wasm": [],
|
||||
"assets": []
|
||||
},
|
||||
"/api/hello/route": {
|
||||
"files": [
|
||||
"server/middleware-build-manifest.js",
|
||||
"server/middleware-react-loadable-manifest.js",
|
||||
"server/next-font-manifest.js",
|
||||
"prerender-manifest.js",
|
||||
"server/edge-runtime-webpack.js",
|
||||
"server/app/api/hello/route.js"
|
||||
],
|
||||
"name": "app/api/hello/route",
|
||||
"page": "/api/hello/route",
|
||||
"matchers": [
|
||||
{
|
||||
"regexp": "^/api/hello$",
|
||||
"originalSource": "/api/hello"
|
||||
}
|
||||
],
|
||||
"wasm": [],
|
||||
"assets": []
|
||||
}
|
||||
},
|
||||
"version": 2
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>500: Internal Server Error</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" crossorigin="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-511881c2eef3fe2b.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/framework-c25027af42eb8c45.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/main-2d7b2ac4e61285c5.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_app-508d387925ef2fa9.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_error-e16765248192e4ee.js" defer="" crossorigin=""></script><script src="/_next/static/Dzt6IsHhCHGe9WiNGLhTL/_buildManifest.js" defer="" crossorigin=""></script><script src="/_next/static/Dzt6IsHhCHGe9WiNGLhTL/_ssgManifest.js" defer="" crossorigin=""></script></head><body><div id="__next"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"Dzt6IsHhCHGe9WiNGLhTL","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
||||
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>500: Internal Server Error</title><meta name="next-head-count" content="3"/><noscript data-n-css=""></noscript><script defer="" crossorigin="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-363780e1c974ae15.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/framework-c25027af42eb8c45.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/main-2d7b2ac4e61285c5.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_app-508d387925ef2fa9.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_error-e16765248192e4ee.js" defer="" crossorigin=""></script><script src="/_next/static/OaB3peodHjkZq3Assb5S1/_buildManifest.js" defer="" crossorigin=""></script><script src="/_next/static/OaB3peodHjkZq3Assb5S1/_ssgManifest.js" defer="" crossorigin=""></script></head><body><div id="__next"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"OaB3peodHjkZq3Assb5S1","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|
||||
|
|
@ -1 +1 @@
|
|||
self.__RSC_SERVER_MANIFEST="{\"node\":{},\"edge\":{},\"encryptionKey\":\"pDmQ3fjBg/jiSA3hYiyTDteIED53hIUE4PL6HOIWZbk=\"}"
|
||||
self.__RSC_SERVER_MANIFEST="{\"node\":{},\"edge\":{},\"encryptionKey\":\"Xz12aiWmSpv491/074P3fkwyBsGEGww1bcqDt6ANu7Q=\"}"
|
||||
|
|
@ -1 +1 @@
|
|||
{"node":{},"edge":{},"encryptionKey":"pDmQ3fjBg/jiSA3hYiyTDteIED53hIUE4PL6HOIWZbk="}
|
||||
{"node":{},"edge":{},"encryptionKey":"Xz12aiWmSpv491/074P3fkwyBsGEGww1bcqDt6ANu7Q="}
|
||||
File diff suppressed because one or more lines are too long
3
apps/web/env.d.ts
vendored
3
apps/web/env.d.ts
vendored
|
|
@ -3,7 +3,10 @@ declare global {
|
|||
interface ProcessEnv {
|
||||
[key: string]: string | undefined;
|
||||
DATABASE: D1Database;
|
||||
VECTORIZE_INDEX: VectorizeIndex;
|
||||
AI: any
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { };
|
||||
|
|
@ -1,22 +1,89 @@
|
|||
import type { NextRequest } from 'next/server'
|
||||
import { getRequestContext } from '@cloudflare/next-on-pages'
|
||||
import { Ai } from '@cloudflare/ai'
|
||||
import type {
|
||||
VectorizeIndex,
|
||||
Fetcher,
|
||||
Request,
|
||||
} from "@cloudflare/workers-types";
|
||||
|
||||
import {
|
||||
CloudflareVectorizeStore,
|
||||
CloudflareWorkersAIEmbeddings,
|
||||
} from "@langchain/cloudflare";
|
||||
import { db } from '@/server/db';
|
||||
import { sessions, users } from '@/server/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export const runtime = 'edge'
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
let responseText = 'Hello World'
|
||||
|
||||
// In the edge runtime you can use Bindings that are available in your application
|
||||
// (for more details see:
|
||||
// - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
|
||||
// - https://developers.cloudflare.com/pages/functions/bindings/
|
||||
// )
|
||||
//
|
||||
// KV Example:
|
||||
// const myKv = getRequestContext().env.MY_KV
|
||||
// await myKv.put('suffix', ' from a KV store!')
|
||||
// const suffix = await myKv.get('suffix')
|
||||
// responseText += suffix
|
||||
|
||||
return new Response(responseText)
|
||||
declare global {
|
||||
interface CloudflareEnv {
|
||||
VECTORIZE_INDEX: VectorizeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
|
||||
const token = req.cookies.get("next-auth.session-token")?.value ?? req.cookies.get("__Secure-authjs.session-token")?.value ?? req.cookies.get("authjs.session-token")?.value ?? req.headers.get("Authorization")?.replace("Bearer ", "");
|
||||
|
||||
console.log(process.env.AI)
|
||||
// if (!process.env.AI || !vec) {
|
||||
// return new Response(JSON.stringify({ message: "Missing cloudflare bindings" }), { status: 500 });
|
||||
// }
|
||||
|
||||
const user = await db.select().from(sessions).where(eq(sessions.sessionToken, token!))
|
||||
.leftJoin(users, eq(sessions.userId, users.id)).limit(1)
|
||||
|
||||
const vec = getRequestContext().env.VECTORIZE_INDEX;
|
||||
|
||||
console.log(vec ? vec : "Vector index not found")
|
||||
|
||||
|
||||
if (!user || user.length === 0) {
|
||||
return NextResponse.json({ message: "Invalid Key, session not found." }, { status: 404 });
|
||||
}
|
||||
|
||||
const embeddings = new CloudflareWorkersAIEmbeddings({
|
||||
binding: process.env.AI,
|
||||
modelName: "@cf/baai/bge-small-en-v1.5",
|
||||
});
|
||||
const store = new CloudflareVectorizeStore(embeddings, {
|
||||
index: vec,
|
||||
});
|
||||
|
||||
const body = await req.json() as {
|
||||
pageContent: string,
|
||||
title?: string,
|
||||
description?: string,
|
||||
url: string,
|
||||
};
|
||||
|
||||
|
||||
if (!body.pageContent || !body.url) {
|
||||
return new Response(JSON.stringify({ message: "Invalid Page Content" }), { status: 400 });
|
||||
}
|
||||
|
||||
await store.addDocuments([
|
||||
{
|
||||
pageContent: body.pageContent,
|
||||
metadata: {
|
||||
title: body.title ?? "",
|
||||
description: body.description ?? "",
|
||||
url: body.url,
|
||||
user: user[0].user!.name
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
const filter: VectorizeVectorMetadataFilter = {
|
||||
user: {
|
||||
$eq: user[0].user!.name
|
||||
}
|
||||
}
|
||||
|
||||
const resp = await store.similaritySearch(body.pageContent, 5, filter)
|
||||
|
||||
return new Response(JSON.stringify({ message: "OK", data: resp }), { status: 200 });
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ export const runtime = "edge";
|
|||
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const token = req.cookies.get("next-auth.session-token")?.value ?? req.cookies.get("authjs.session-token")?.value ?? req.headers.get("Authorization")?.replace("Bearer ", "");
|
||||
const token = req.cookies.get("next-auth.session-token")?.value ?? req.cookies.get("__Secure-authjs.session-token")?.value ?? req.cookies.get("authjs.session-token")?.value ?? req.headers.get("Authorization")?.replace("Bearer ", "");
|
||||
|
||||
console.log(token ? token : 'token not found lol')
|
||||
console.log(process.env.DATABASE)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ export const {
|
|||
session: ({ session, token }) => ({
|
||||
...session,
|
||||
user: {
|
||||
...session.user,
|
||||
// ...session.user,
|
||||
id: token.id as string,
|
||||
token
|
||||
token: token,
|
||||
},
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { drizzle } from 'drizzle-orm/d1';
|
|||
|
||||
import * as schema from "./schema";
|
||||
|
||||
console.log(process.env.DATABASE);
|
||||
|
||||
export const db = drizzle(
|
||||
process.env.DATABASE,
|
||||
{ schema, logger: true }
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
name = "anycontext-front"
|
||||
compatibility_date = "2024-02-23"
|
||||
|
||||
compatibility_flags = ["nodejs_compat"]
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "DATABASE"
|
||||
database_name = "dev-d1-anycontext"
|
||||
database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
|
||||
|
||||
[vars]
|
||||
GOOGLE_CLIENT_ID="872261398704-7flflshn1um5lvj2mkks9vtqem9su60c.apps.googleusercontent.com"
|
||||
GOOGLE_CLIENT_SECRET="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"
|
||||
NEXTAUTH_SECRET="sec"
|
||||
NEXTAUTH_URL="http://localhost:3000"
|
||||
|
||||
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
||||
# Note: Use secrets to store sensitive data.
|
||||
# Docs: https://developers.cloudflare.com/workers/platform/environment-variables
|
||||
# [vars]
|
||||
# MY_VARIABLE = "production_value"
|
||||
|
||||
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
||||
# Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
|
||||
# [[kv_namespaces]]
|
||||
# binding = "MY_KV_NAMESPACE"
|
||||
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
|
||||
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
||||
# Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
|
||||
# [[r2_buckets]]
|
||||
# binding = "MY_BUCKET"
|
||||
# bucket_name = "my-bucket"
|
||||
|
||||
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
||||
# Docs: https://developers.cloudflare.com/queues/get-started
|
||||
# [[queues.producers]]
|
||||
# binding = "MY_QUEUE"
|
||||
# queue = "my-queue"
|
||||
|
||||
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
||||
# Docs: https://developers.cloudflare.com/queues/get-started
|
||||
# [[queues.consumers]]
|
||||
# queue = "my-queue"
|
||||
|
||||
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
||||
# Docs: https://developers.cloudflare.com/workers/platform/services
|
||||
# [[services]]
|
||||
# binding = "MY_SERVICE"
|
||||
# service = "my-service"
|
||||
|
||||
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
||||
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
||||
# Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
|
||||
# [[durable_objects.bindings]]
|
||||
# name = "MY_DURABLE_OBJECT"
|
||||
# class_name = "MyDurableObject"
|
||||
|
||||
# Durable Object migrations.
|
||||
# Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
|
||||
# [[migrations]]
|
||||
# tag = "v1"
|
||||
# new_classes = ["MyDurableObject"]
|
||||
|
||||
# KV Example:
|
||||
# [[kv_namespaces]]
|
||||
# binding = "MY_KV"
|
||||
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
|
|
@ -35,8 +35,10 @@
|
|||
"dependencies": {
|
||||
"@auth/d1-adapter": "^0.6.0",
|
||||
"@auth/drizzle-adapter": "^0.7.0",
|
||||
"@cloudflare/ai": "^1.0.52",
|
||||
"@cloudflare/next-on-pages-next-dev": "^0.0.1",
|
||||
"@crxjs/vite-plugin": "^1.0.14",
|
||||
"@langchain/cloudflare": "^0.0.3",
|
||||
"@t3-oss/env-nextjs": "^0.9.2",
|
||||
"@types/chrome": "^0.0.261",
|
||||
"better-sqlite3": "^9.4.3",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue