Skip to content

Commit

Permalink
prepare statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhravya committed Apr 11, 2024
1 parent 93c49b6 commit 22effd2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/cf-ai-backend/src/routes/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export async function POST(request: Request, _: CloudflareVectorizeStore, embedd
// if (responses.count === 0) {
// return new Response(JSON.stringify({ message: "No Results Found" }), { status: 404 });
// }
console.log(responses.matches);

const highScoreIds = responses.matches.filter(({ score }) => score > 0.35).map(({ id }) => id);
const highScoreIds = responses.matches.filter(({ score }) => score > 0.3).map(({ id }) => id);

if (sourcesOnly === 'true') {
return new Response(JSON.stringify({ ids: highScoreIds }), { status: 200 });
Expand Down
4 changes: 3 additions & 1 deletion apps/web/db/prepare.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CREATE TABLE `session` (
--> statement-breakpoint
CREATE TABLE `space` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`name` text DEFAULT 'all' NOT NULL,
`name` text DEFAULT 'none' NOT NULL,
`user` text(255),
FOREIGN KEY (`user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
Expand All @@ -47,6 +47,7 @@ CREATE TABLE `storedContent` (
`url` text NOT NULL,
`savedAt` integer NOT NULL,
`baseUrl` text(255),
`type` text DEFAULT 'page',
`image` text(255),
`user` text(255),
FOREIGN KEY (`user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
Expand All @@ -69,6 +70,7 @@ CREATE TABLE `verificationToken` (
--> statement-breakpoint
CREATE INDEX `account_userId_idx` ON `account` (`userId`);--> statement-breakpoint
CREATE INDEX `session_userId_idx` ON `session` (`userId`);--> statement-breakpoint
CREATE UNIQUE INDEX `space_name_unique` ON `space` (`name`);--> statement-breakpoint
CREATE INDEX `spaces_name_idx` ON `space` (`name`);--> statement-breakpoint
CREATE INDEX `spaces_user_idx` ON `space` (`user`);--> statement-breakpoint
CREATE INDEX `storedContent_url_idx` ON `storedContent` (`url`);--> statement-breakpoint
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/store/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function POST(req: NextRequest) {
let storeToSpace = data.space;

if (!storeToSpace) {
storeToSpace = "all";
storeToSpace = "none";
}

const storedContentId = await db.insert(storedContent).values({
Expand Down

0 comments on commit 22effd2

Please sign in to comment.