feat(app): allow stopping requests

This commit is contained in:
Willie Zutz 2025-05-14 11:19:06 -06:00
parent 936f651372
commit ce1a38febc
7 changed files with 227 additions and 68 deletions

View file

@ -124,6 +124,8 @@ export const POST = async (req: Request) => {
if (!searchHandler) {
return Response.json({ message: 'Invalid focus mode' }, { status: 400 });
}
const abortController = new AbortController();
const { signal } = abortController;
const emitter = await searchHandler.searchAndAnswer(
body.query,
@ -133,6 +135,7 @@ export const POST = async (req: Request) => {
body.optimizationMode,
[],
body.systemInstructions || '',
signal,
);
if (!body.stream) {
@ -180,9 +183,6 @@ export const POST = async (req: Request) => {
const encoder = new TextEncoder();
const abortController = new AbortController();
const { signal } = abortController;
const stream = new ReadableStream({
start(controller) {
let sources: any[] = [];