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

Function handleRun

packages/baseai/src/dev/routes/v1/pipes/run.ts:116–150  ·  view source on GitHub ↗
(c: any)

Source from the content-addressed store, hash-verified

114
115// Main endpoint handler
116const handleRun = async (c: any) => {
117 try {
118 const body = await c.req.json();
119
120 const llmKey = (body.llmApiKey as string) || '';
121 const hiddenChars = new Array(45).fill('*').join('');
122 const redactedKey = llmKey.length
123 ? llmKey.slice(0, 8) + hiddenChars
124 : '';
125
126 const logData = { ...body, llmApiKey: redactedKey };
127 logger('pipe.request', logData, 'Pipe Request Body');
128
129 const validatedBody = validateRequestBody(body);
130
131 const { pipe, messages, llmApiKey, stream, variables } = validatedBody;
132 const model = pipe.model as PipeModelT;
133
134 const rawLlmResponse = await callLLM({
135 pipe: {
136 ...pipe,
137 model
138 },
139 messages,
140 llmApiKey,
141 stream,
142 variables,
143 paramsTools: validatedBody.tools
144 });
145
146 return processLlmResponse(c, validatedBody, rawLlmResponse);
147 } catch (error: unknown) {
148 return handleGenerateError(c, error);
149 }
150};
151
152// Register the endpoint
153export const registerV1PipesRun = (app: Hono) => {

Callers

nothing calls this directly

Calls 5

loggerFunction · 0.90
callLLMFunction · 0.90
validateRequestBodyFunction · 0.70
processLlmResponseFunction · 0.70
handleGenerateErrorFunction · 0.70

Tested by

no test coverage detected