Skip to content

Commit

Permalink
change 'categories' to 'spaces'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhravya committed Apr 3, 2024
1 parent 8664a8b commit a5a4442
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
12 changes: 3 additions & 9 deletions apps/cf-ai-backend/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ type RouteHandler = (request: Request, store: CloudflareVectorizeStore, embeddin

const routeMap = new Map<string, Record<string, RouteHandler>>();

routeMap.set('/add', {
POST: apiAdd.POST,
});
routeMap.set('/add', apiAdd);

routeMap.set('/query', {
GET: apiQuery.GET,
});
routeMap.set('/query', apiQuery);

routeMap.set('/ask', {
POST: apiAsk.POST,
});
routeMap.set('/ask', apiAsk);

// Add more route mappings as needed
// routeMap.set('/api/otherRoute', { ... });
Expand Down
4 changes: 2 additions & 2 deletions apps/cf-ai-backend/src/routes/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function POST(request: Request, store: CloudflareVectorizeStore) {
pageContent: string,
title?: string,
description?: string,
category?: string,
space?: string,
url: string,
user: string
};
Expand All @@ -23,7 +23,7 @@ export async function POST(request: Request, store: CloudflareVectorizeStore) {
metadata: {
title: body.title ?? "",
description: body.description ?? "",
category: body.category ?? "",
space: body.space ?? "",
url: body.url,
user: body.user,
},
Expand Down
8 changes: 4 additions & 4 deletions apps/cf-ai-backend/src/routes/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function GET(request: Request, _: CloudflareVectorizeStore, embeddi
const query = queryparams.get("q");
const topK = parseInt(queryparams.get("topK") ?? "5");
const user = queryparams.get("user")
const category = queryparams.get("category")
const space = queryparams.get("space")

const sourcesOnly = (queryparams.get("sourcesOnly") ?? "false")

Expand All @@ -26,9 +26,9 @@ export async function GET(request: Request, _: CloudflareVectorizeStore, embeddi
}
}

if (category) {
filter.category = {
$eq: category
if (space) {
filter.space = {
$eq: space
}
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/db/prepare.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CREATE TABLE `storedContent` (
`title` text(255),
`description` text(255),
`url` text NOT NULL,
`category` text(255),
`space` text(255),
`savedAt` integer NOT NULL,
`baseUrl` text(255),
`image` text(255)
Expand Down Expand Up @@ -64,6 +64,6 @@ CREATE UNIQUE INDEX `storedContent_url_unique` ON `storedContent` (`url`);--> st
CREATE INDEX `storedContent_url_idx` ON `storedContent` (`url`);--> statement-breakpoint
CREATE INDEX `storedContent_savedAt_idx` ON `storedContent` (`savedAt`);--> statement-breakpoint
CREATE INDEX `storedContent_title_idx` ON `storedContent` (`title`);--> statement-breakpoint
CREATE INDEX `storedContent_category_idx` ON `storedContent` (`category`);--> statement-breakpoint
CREATE INDEX `storedContent_space_idx` ON `storedContent` (`space`);--> statement-breakpoint
CREATE INDEX `userStoredContent_idx` ON `userStoredContent` (`userId`,`contentId`);--> statement-breakpoint
CREATE UNIQUE INDEX `unique_user_content` ON `userStoredContent` (`userId`,`contentId`);
4 changes: 2 additions & 2 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Sidebar() {
image: 'https://code.visualstudio.com/favicon.ico',
baseUrl: 'https://code.visualstudio.com',
savedAt: new Date(),
category: 'Development',
space: 'Development',
},
{
id: 1,
Expand All @@ -38,7 +38,7 @@ export default function Sidebar() {
image: 'https://github.com/favicon.ico',
baseUrl: 'https://github.com',
savedAt: new Date(),
category: 'Development',
space: 'Development',
},
];

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/server/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const storedContent = createTable(
title: text("title", { length: 255 }),
description: text("description", { length: 255 }),
url: text("url").notNull().unique(),
category: text("category", { length: 255 }),
space: text("space", { length: 255 }),
savedAt: int("savedAt", { mode: "timestamp" }).notNull(),
baseUrl: text("baseUrl", { length: 255 }),
image: text("image", { length: 255 }),
Expand All @@ -123,7 +123,7 @@ export const storedContent = createTable(
urlIdx: index("storedContent_url_idx").on(sc.url),
savedAtIdx: index("storedContent_savedAt_idx").on(sc.savedAt),
titleInx: index("storedContent_title_idx").on(sc.title),
categoryIdx: index("storedContent_category_idx").on(sc.category),
spaceIdx: index("storedContent_space_idx").on(sc.space),
}),
);

Expand Down

0 comments on commit a5a4442

Please sign in to comment.