aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorcodetorso <[email protected]>2024-06-18 03:02:18 -0600
committercodetorso <[email protected]>2024-06-18 03:02:18 -0600
commit242cbf721acaebc2f77ce161cef10d2c04261388 (patch)
treedfb5f78dddcd86925c1f7f0ea6527340d7a9bb8a /apps
parentadd js docs (diff)
downloadarchived-supermemory-242cbf721acaebc2f77ce161cef10d2c04261388.tar.xz
archived-supermemory-242cbf721acaebc2f77ce161cef10d2c04261388.zip
Add Editor Endpoint
Diffstat (limited to 'apps')
-rw-r--r--apps/cf-ai-backend/src/index.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts
index 75a3b8e8..c4ffa6b5 100644
--- a/apps/cf-ai-backend/src/index.ts
+++ b/apps/cf-ai-backend/src/index.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
import { Hono } from "hono";
-import { CoreMessage, streamText } from "ai";
+import { CoreMessage, generateText, streamText } from "ai";
import { chatObj, Env, vectorObj } from "./types";
import {
batchCreateChunksAndEmbeddings,
@@ -331,4 +331,20 @@ app.delete(
},
);
+app.get('/api/editorai', zValidator(
+ "query",
+ z.object({
+ context: z.string(),
+ request: z.string(),
+ }),
+), async (c)=> {
+ const { context, request } = c.req.valid("query");
+
+ const { model } = await initQuery(c);
+
+ const {text} = await generateText({ model, prompt: `${request}-${context}` });
+
+ return c.json({completion: text});
+})
+
export default app;