diff options
| author | Dhravya <[email protected]> | 2024-06-11 19:27:13 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-06-11 19:27:13 -0500 |
| commit | aabdef4b0d953e547aee798d649a1e8bd2e8ce2d (patch) | |
| tree | d52d14df1f377dc911a585330eacdd4c0343a978 | |
| parent | minor changes and improvements (diff) | |
| download | supermemory-aabdef4b0d953e547aee798d649a1e8bd2e8ce2d.tar.xz supermemory-aabdef4b0d953e547aee798d649a1e8bd2e8ce2d.zip | |
some documentation for backend
| -rw-r--r-- | apps/cf-ai-backend/README.md | 74 | ||||
| -rw-r--r-- | apps/cf-ai-backend/src/index.ts | 3 | ||||
| -rw-r--r-- | package.json | 1 |
3 files changed, 37 insertions, 41 deletions
diff --git a/apps/cf-ai-backend/README.md b/apps/cf-ai-backend/README.md index 86409f29..91d6b77e 100644 --- a/apps/cf-ai-backend/README.md +++ b/apps/cf-ai-backend/README.md @@ -1,58 +1,50 @@ -# Hono minimal project +baseURL: https://new-cf-ai-backend.dhravya.workers.dev -This is a minimal project with [Hono](https://github.com/honojs/hono/) for Cloudflare Workers. +Authentication: +You must authenticate with a header and `Authorization: bearer token` for each request in `/api/*` routes. -## Features +### Add content: -- Minimal -- TypeScript -- Wrangler to develop and deploy. -- [Jest](https://jestjs.io/ja/) for testing. - -## Usage - -Initialize +POST `/api/add` with ``` -npx create-cloudflare my-app https://github.com/honojs/hono-minimal +body { + pageContent: z.string(), + title: z.string().optional(), + description: z.string().optional(), + space: z.string().optional(), + url: z.string(), + user: z.string(), +} ``` -Install +### Query without user data -``` -yarn install -``` +GET `/api/ask` with +query `?query=testing` -Develop +(this is temp but works perfectly, will change soon for chat use cases specifically) -``` -yarn dev -``` +### Query vectorize and get results in natural language -Test +POST `/api/chat` with ``` -yarn test -``` - -Deploy +query paramters (?query=...&" { + query: z.string(), + topK: z.number().optional().default(10), + user: z.string(), + spaces: z.string().optional(), + sourcesOnly: z.string().optional().default("false"), + model: z.string().optional().default("gpt-4o"), + } +body z.object({ + chatHistory: z.array(contentObj).optional(), +}); ``` -yarn deploy -``` - -## Examples - -See: <https://github.com/honojs/examples> - -## For more information - -See: <https://honojs.dev> - -## Author - -Yusuke Wada <https://github.com/yusukebe> -## License +### Delete vectors -MIT +DELETE `/api/delete` with +query param websiteUrl, user diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 19770dec..1e128bbd 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -14,9 +14,12 @@ import { bearerAuth } from "hono/bearer-auth"; import { zValidator } from "@hono/zod-validator"; import chunkText from "./utils/chonker"; import { systemPrompt, template } from "./prompts/prompt1"; +import { swaggerUI } from "@hono/swagger-ui"; const app = new Hono<{ Bindings: Env }>(); +app.get("/doc", swaggerUI({ url: "/doc" })); + // ------- MIDDLEWARES ------- app.use("*", poweredBy()); app.use("*", timing()); diff --git a/package.json b/package.json index 1fc76d17..a58b09c6 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@aws-sdk/s3-request-presigner": "^3.577.0", "@cloudflare/puppeteer": "^0.0.8", "@headlessui/react": "^2.0.4", + "@hono/swagger-ui": "^0.2.2", "@hookform/resolvers": "^3.4.2", "@iarna/toml": "^2.2.5", "@langchain/cloudflare": "^0.0.6", |