diff options
| author | codetorso <[email protected]> | 2024-06-18 03:02:18 -0600 |
|---|---|---|
| committer | codetorso <[email protected]> | 2024-06-18 03:02:18 -0600 |
| commit | 242cbf721acaebc2f77ce161cef10d2c04261388 (patch) | |
| tree | dfb5f78dddcd86925c1f7f0ea6527340d7a9bb8a /apps | |
| parent | add js docs (diff) | |
| download | archived-supermemory-242cbf721acaebc2f77ce161cef10d2c04261388.tar.xz archived-supermemory-242cbf721acaebc2f77ce161cef10d2c04261388.zip | |
Add Editor Endpoint
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/cf-ai-backend/src/index.ts | 18 |
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; |