mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 13:00:33 +00:00
Better error messages on OpenRouter via openai-completions
This commit is contained in:
parent
c84f2f25de
commit
fe98895706
1 changed files with 3 additions and 0 deletions
|
|
@ -307,6 +307,9 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions"> = (
|
||||||
for (const block of output.content) delete (block as any).index;
|
for (const block of output.content) delete (block as any).index;
|
||||||
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
||||||
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
||||||
|
// Some providers via OpenRouter give additional information in this field.
|
||||||
|
const rawMetadata = (error as any)?.error?.metadata?.raw;
|
||||||
|
if (rawMetadata) output.errorMessage += `\n${rawMetadata}`;
|
||||||
stream.push({ type: "error", reason: output.stopReason, error: output });
|
stream.push({ type: "error", reason: output.stopReason, error: output });
|
||||||
stream.end();
|
stream.end();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue