diff options
| author | Dhravya <[email protected]> | 2024-04-10 00:11:59 -0700 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-04-10 00:11:59 -0700 |
| commit | 338e4f378c0752e298f2a2021feda953830ddd02 (patch) | |
| tree | 534747073b32c7ec3d6ae8b54a2bf65c79b8bf87 /apps/web/src | |
| parent | removed all pnpm-lock files (diff) | |
| download | supermemory-338e4f378c0752e298f2a2021feda953830ddd02.tar.xz supermemory-338e4f378c0752e298f2a2021feda953830ddd02.zip | |
spaces in the API
Diffstat (limited to 'apps/web/src')
| -rw-r--r-- | apps/web/src/app/api/chat/route.ts | 4 | ||||
| -rw-r--r-- | apps/web/src/components/Main.tsx | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/apps/web/src/app/api/chat/route.ts b/apps/web/src/app/api/chat/route.ts index ef59fd43..aec5b0ea 100644 --- a/apps/web/src/app/api/chat/route.ts +++ b/apps/web/src/app/api/chat/route.ts @@ -25,6 +25,8 @@ export async function POST(req: NextRequest) { const session = { session: sessionData[0], user: user[0] } const query = new URL(req.url).searchParams.get("q"); + const spaces = new URL(req.url).searchParams.get("spaces"); + const sourcesOnly = new URL(req.url).searchParams.get("sourcesOnly") ?? "false"; const chatHistory = await req.json() as { @@ -38,7 +40,7 @@ export async function POST(req: NextRequest) { } - const resp = await fetch(`https://cf-ai-backend.dhravya.workers.dev/chat?q=${query}&user=${session.user.email ?? session.user.name}&sourcesOnly=${sourcesOnly}`, { + const resp = await fetch(`https://cf-ai-backend.dhravya.workers.dev/chat?q=${query}&user=${session.user.email ?? session.user.name}&sourcesOnly=${sourcesOnly}&spaces=${spaces}`, { headers: { "X-Custom-Auth-Key": env.BACKEND_SECURITY_KEY, }, diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index 3d0fc18a..4e0392c9 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -37,6 +37,8 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { const textArea = useRef<HTMLDivElement>(null); const main = useRef<HTMLDivElement>(null); + const [selectedSpaces, setSelectedSpaces] = useState<string[]>([]); + useEffect(() => { const search = searchParams.get('q'); if (search && search.trim().length > 0) { @@ -182,7 +184,7 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { ids: string[]; }; - setIsAiLoading(false) + setIsAiLoading(false); setChatHistory((prev) => { const lastMessage = prev[prev.length - 1]; return [ @@ -197,8 +199,7 @@ export default function Main({ sidebarOpen }: { sidebarOpen: boolean }) { ]; }); - // TODO: PASS THE `SPACE` TO THE API - const response = await fetch(`/api/chat?q=${_value}`, { + const response = await fetch(`/api/chat?q=${_value}&spaces=${selectedSpaces.join(",")}`, { method: 'POST', body: JSON.stringify({ chatHistory: modifyChatHistory(chatHistory), |