MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / POST

Function POST

examples/nextjs/app/api/langbase/pipes/run-stream/route.ts:5–35  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

3import {NextRequest} from 'next/server';
4
5export async function POST(req: NextRequest) {
6 const runOptions = await req.json();
7
8 // 1. Initiate the Pipe.
9 const pipe = new Pipe(pipeSummary());
10
11 // 2. Run the Pipe.
12 try {
13 const {stream, threadId} = await pipe.run(runOptions);
14 // 3. Return the ReadableStream directly with the threadId in the headers
15 // to be used on the client side to mainain a single chat thread.
16 return new Response(stream, {
17 status: 200,
18 headers: {
19 'lb-thread-id': threadId ?? '',
20 },
21 });
22 } catch (error: any) {
23 return new Response(
24 JSON.stringify({
25 error,
26 }),
27 {
28 status: error.status || 500,
29 headers: {
30 'Content-Type': 'application/json',
31 },
32 },
33 );
34 }
35}

Callers

nothing calls this directly

Calls 2

runMethod · 0.95
pipeSummaryFunction · 0.50

Tested by

no test coverage detected