MCPcopy
hub / github.com/msgbyte/tianji / writeAIRouterStreamError

Function writeAIRouterStreamError

src/server/model/aiRouter.ts:1334–1359  ·  view source on GitHub ↗
(
  res: Response,
  protocol: AIRouterProtocol,
  message: string,
  type: string
)

Source from the content-addressed store, hash-verified

1332}
1333
1334function writeAIRouterStreamError(
1335 res: Response,
1336 protocol: AIRouterProtocol,
1337 message: string,
1338 type: string
1339) {
1340 if (protocol === AI_ROUTER_PROTOCOLS.ANTHROPIC_MESSAGES) {
1341 writeAIGatewayAnthropicStreamError(res, new Error(message));
1342 return;
1343 }
1344
1345 if (res.writableEnded || res.destroyed) {
1346 return;
1347 }
1348
1349 res.write(
1350 `data: ${JSON.stringify({
1351 error: {
1352 message,
1353 type,
1354 },
1355 })}\n\n`
1356 );
1357 res.write('data: [DONE]\n\n');
1358 res.end();
1359}
1360
1361async function createAIRouterRuntimeFailureLog(args: {
1362 workspaceId: string;

Callers 2

Calls 3

writeMethod · 0.80
endMethod · 0.65

Tested by

no test coverage detected