Skip to content

Commit

Permalink
spaces not showing bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhravya committed Apr 12, 2024
1 parent 09289dc commit 18b1a06
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions apps/cf-ai-backend/src/routes/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export async function POST(request: Request, _: CloudflareVectorizeStore, embedd
const query = queryparams.get('q');
const topK = parseInt(queryparams.get('topK') ?? '5');
const user = queryparams.get('user');
const spaces = queryparams.get('spaces');
const spacesArray = spaces ? spaces.split(',') : undefined;
const spaces = queryparams.get('spaces') ?? undefined;
const sp = spaces === 'null' ? undefined : spaces;
const spacesArray = sp ? sp.split(',') : undefined;

const sourcesOnly = queryparams.get('sourcesOnly') ?? 'false';

Expand Down Expand Up @@ -60,10 +61,11 @@ 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.3).map(({ id }) => id);

console.log('highscoreIds', highScoreIds);

if (sourcesOnly === 'true') {
return new Response(JSON.stringify({ ids: highScoreIds }), { status: 200 });
}
Expand Down
9 changes: 7 additions & 2 deletions apps/web/src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ export async function POST(req: NextRequest) {
},
);

console.log(resp.status);
console.log(resp.statusText);
console.log("sourcesOnly", sourcesOnly);

if (sourcesOnly == "true") {
const data = await resp.json();
console.log("data", data);
return new Response(JSON.stringify(data), { status: 200 });
}

if (resp.status !== 200 || !resp.ok) {
const errorData = await resp.json();
Expand Down
11 changes: 4 additions & 7 deletions apps/web/src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,11 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) {
},
);

console.log(await sourcesResponse.json());

// const sourcesInJson = (await sourcesResponse.json()) as {
// ids: string[];
// };
const sourcesInJson = (await sourcesResponse.json()) as {
ids: string[];
};

// console.log(sourcesInJson)
const sourcesInJson = { ids: [] };
console.log(sourcesInJson);

setIsAiLoading(false);
setChatHistory((prev) => {
Expand Down

0 comments on commit 18b1a06

Please sign in to comment.