mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
update error messages copy to be more generic
This commit is contained in:
parent
5a53f086ee
commit
5a2539a7bd
9 changed files with 12 additions and 12 deletions
|
|
@ -1343,7 +1343,7 @@ function mapStopReason(
|
|||
case "stop_sequence":
|
||||
return { stopReason: "stop" }; // We don't supply stop sequences, so this should never happen
|
||||
case "sensitive": // Content flagged by safety filters (not yet in SDK types)
|
||||
return { stopReason: "error", errorMessage: "Anthropic stop_reason: sensitive" };
|
||||
return { stopReason: "error", errorMessage: "Provider stopped with: sensitive" };
|
||||
default:
|
||||
// Handle unknown stop reasons gracefully (API may add new values)
|
||||
throw new Error(`Unhandled stop reason: ${reason}`);
|
||||
|
|
|
|||
|
|
@ -971,7 +971,7 @@ function mapStopReason(reason: string | undefined): { stopReason: StopReason; er
|
|||
return { stopReason: "toolUse" };
|
||||
default:
|
||||
return reason
|
||||
? { stopReason: "error", errorMessage: `Bedrock stopped with: ${reason}` }
|
||||
? { stopReason: "error", errorMessage: `Provider stopped with: ${reason}` }
|
||||
: { stopReason: "error" };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ export const stream: StreamFunction<"google-generative-ai", GoogleOptions> = (
|
|||
}
|
||||
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
||||
const errorMessage = output.rawStopReason
|
||||
? `Gemini stopped with ${output.rawStopReason}`
|
||||
? `Provider stopped with: ${output.rawStopReason}`
|
||||
: "An unknown error occurred";
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ export const stream: StreamFunction<"google-vertex", GoogleVertexOptions> = (
|
|||
}
|
||||
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
||||
const errorMessage = output.rawStopReason
|
||||
? `Gemini stopped with ${output.rawStopReason}`
|
||||
? `Provider stopped with: ${output.rawStopReason}`
|
||||
: "An unknown error occurred";
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -670,8 +670,8 @@ function mapChatStopReason(reason: string | null): { stopReason: StopReason; err
|
|||
case "tool_calls":
|
||||
return { stopReason: "toolUse" };
|
||||
case "error":
|
||||
return { stopReason: "error", errorMessage: "Mistral stopped with: error" };
|
||||
return { stopReason: "error", errorMessage: "Provider stopped with: error" };
|
||||
default:
|
||||
return { stopReason: "error", errorMessage: `Mistral stopped with: ${reason}` };
|
||||
return { stopReason: "error", errorMessage: `Provider stopped with: ${reason}` };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ describe("Anthropic raw SSE parsing", () => {
|
|||
|
||||
expect(result.stopReason).toBe("error");
|
||||
expect(result.rawStopReason).toBe("sensitive");
|
||||
expect(result.errorMessage).toBe("Anthropic stop_reason: sensitive");
|
||||
expect(result.errorMessage).toBe("Provider stopped with: sensitive");
|
||||
});
|
||||
|
||||
it("treats message_delta without usage as a no-op for usage accumulation", async () => {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,6 @@ describe("Bedrock raw stop reasons", () => {
|
|||
|
||||
expect(message.stopReason).toBe("error");
|
||||
expect(message.rawStopReason).toBe("guardrail_intervened");
|
||||
expect(message.errorMessage).toBe("Bedrock stopped with: guardrail_intervened");
|
||||
expect(message.errorMessage).toBe("Provider stopped with: guardrail_intervened");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ describe("Google raw stop reasons", () => {
|
|||
|
||||
expect(message.stopReason).toBe("error");
|
||||
expect(message.rawStopReason).toBe("MALFORMED_FUNCTION_CALL");
|
||||
expect(message.errorMessage).toBe("Gemini stopped with MALFORMED_FUNCTION_CALL");
|
||||
expect(message.errorMessage).toBe("Provider stopped with: MALFORMED_FUNCTION_CALL");
|
||||
});
|
||||
|
||||
it("preserves raw Gemini finish reasons for Google Vertex errors", async () => {
|
||||
|
|
@ -101,6 +101,6 @@ describe("Google raw stop reasons", () => {
|
|||
|
||||
expect(message.stopReason).toBe("error");
|
||||
expect(message.rawStopReason).toBe("SAFETY");
|
||||
expect(message.errorMessage).toBe("Gemini stopped with SAFETY");
|
||||
expect(message.errorMessage).toBe("Provider stopped with: SAFETY");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ describe("Mistral raw stop reasons", () => {
|
|||
|
||||
expect(message.stopReason).toBe("error");
|
||||
expect(message.rawStopReason).toBe("error");
|
||||
expect(message.errorMessage).toBe("Mistral stopped with: error");
|
||||
expect(message.errorMessage).toBe("Provider stopped with: error");
|
||||
});
|
||||
|
||||
it("treats unknown Mistral finish reasons as provider error stops", async () => {
|
||||
|
|
@ -72,6 +72,6 @@ describe("Mistral raw stop reasons", () => {
|
|||
|
||||
expect(message.stopReason).toBe("error");
|
||||
expect(message.rawStopReason).toBe("unmapped_error");
|
||||
expect(message.errorMessage).toBe("Mistral stopped with: unmapped_error");
|
||||
expect(message.errorMessage).toBe("Provider stopped with: unmapped_error");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue