{"version":3,"file":"_server.ts-sovP_dKD.js","sources":["../../../.svelte-kit/adapter-node/entries/endpoints/llm/_server.ts.js"],"sourcesContent":["import { d as private_env } from \"../../../chunks/shared-server.js\";\nimport { r as redirect } from \"../../../chunks/index.js\";\nimport { b as base } from \"../../../chunks/paths.js\";\nimport { L as LlamaCppService } from \"../../../chunks/LlamaCppService.js\";\nconst POST = async ({ locals, request }) => {\n const body = await request.json();\n console.log(private_env.LLM_API_URL);\n const abortController = new AbortController();\n let llmService = new LlamaCppService(private_env.LLM_API_URL);\n let llmGenerator = await llmService.predict(body.userprompt, { abortController });\n const stream = new ReadableStream({\n async start(controller) {\n try {\n for await (const output of await llmGenerator({ prompt: body.userprompt })) {\n controller.enqueue(output.token.text);\n }\n } catch (error2) {\n if (error2.name === \"AbortError\") {\n console.log(\"Request was aborted during LLMServer prediction.\");\n } else {\n console.error(\"Error during LLMServer prediction:\", error2);\n }\n }\n controller.close();\n },\n cancel() {\n console.log(\"ReadableStream canceled and aborted\");\n abortController.abort();\n }\n });\n return new Response(stream, {\n headers: {\n \"content-type\": \"text/event-stream\"\n }\n });\n};\nconst GET = async () => {\n throw redirect(302, `${base}/`);\n};\nexport {\n GET,\n POST\n};\n"],"names":[],"mappings":";;;;;;AAIK,MAAC,IAAI,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK;AAC5C,EAAE,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;AACpC,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AACvC,EAAE,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAChD,EAAE,IAAI,UAAU,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAChE,EAAE,IAAI,YAAY,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;AACpF,EAAE,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