(c: any)
| 113 | |
| 114 | // Main endpoint handler |
| 115 | const handleRun = async (c: any) => { |
| 116 | try { |
| 117 | const body = await c.req.json(); |
| 118 | |
| 119 | const llmKey = (body.llmApiKey as string) || ''; |
| 120 | const hiddenChars = new Array(45).fill('*').join(''); |
| 121 | const redactedKey = llmKey.length |
| 122 | ? llmKey.slice(0, 8) + hiddenChars |
| 123 | : ''; |
| 124 | |
| 125 | const logData = { ...body, llmApiKey: redactedKey }; |
| 126 | logger('pipe.request', logData, 'Pipe Request Body'); |
| 127 | |
| 128 | const validatedBody = validateRequestBody(body); |
| 129 | |
| 130 | const rawLlmResponse = await callLLM(validatedBody); |
| 131 | |
| 132 | return processLlmResponse(c, validatedBody, rawLlmResponse); |
| 133 | } catch (error: unknown) { |
| 134 | return handleGenerateError(c, error); |
| 135 | } |
| 136 | }; |
| 137 | |
| 138 | // Register the endpoint |
| 139 | export const registerBetaPipesRun = (app: Hono) => { |
nothing calls this directly
no test coverage detected