@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed Anthropic streams that end before `message_stop` to be treated as errors instead of successful partial responses ([#3936](https://github.com/badlogic/pi-mono/issues/3936)).
|
||||||
- Fixed generated OpenAI-compatible DeepSeek V4 models to carry the provider-specific reasoning effort mapping outside the direct DeepSeek provider ([#3940](https://github.com/badlogic/pi-mono/issues/3940)).
|
- Fixed generated OpenAI-compatible DeepSeek V4 models to carry the provider-specific reasoning effort mapping outside the direct DeepSeek provider ([#3940](https://github.com/badlogic/pi-mono/issues/3940)).
|
||||||
- Fixed DeepSeek V4 Flash and V4 Pro pricing metadata to match current official rates ([#3910](https://github.com/badlogic/pi-mono/issues/3910)).
|
- Fixed DeepSeek V4 Flash and V4 Pro pricing metadata to match current official rates ([#3910](https://github.com/badlogic/pi-mono/issues/3910)).
|
||||||
- Fixed DeepSeek prompt cache hits to be tracked from `prompt_cache_hit_tokens` in OpenAI-compatible usage responses ([#3880](https://github.com/badlogic/pi-mono/issues/3880)).
|
- Fixed DeepSeek prompt cache hits to be tracked from `prompt_cache_hit_tokens` in OpenAI-compatible usage responses ([#3880](https://github.com/badlogic/pi-mono/issues/3880)).
|
||||||
|
|||||||
@@ -384,6 +384,9 @@ async function* iterateAnthropicEvents(
|
|||||||
throw new Error("Attempted to iterate over an Anthropic response with no body");
|
throw new Error("Attempted to iterate over an Anthropic response with no body");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sawMessageStart = false;
|
||||||
|
let sawMessageEnd = false;
|
||||||
|
|
||||||
for await (const sse of iterateSseMessages(response.body, signal)) {
|
for await (const sse of iterateSseMessages(response.body, signal)) {
|
||||||
if (sse.event === "error") {
|
if (sse.event === "error") {
|
||||||
throw new Error(sse.data);
|
throw new Error(sse.data);
|
||||||
@@ -394,7 +397,13 @@ async function* iterateAnthropicEvents(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield parseJsonWithRepair<RawMessageStreamEvent>(sse.data);
|
const event = parseJsonWithRepair<RawMessageStreamEvent>(sse.data);
|
||||||
|
if (event.type === "message_start") {
|
||||||
|
sawMessageStart = true;
|
||||||
|
} else if (event.type === "message_stop") {
|
||||||
|
sawMessageEnd = true;
|
||||||
|
}
|
||||||
|
yield event;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
const message = error instanceof Error ? error.message : String(error);
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -402,6 +411,10 @@ async function* iterateAnthropicEvents(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sawMessageStart && !sawMessageEnd) {
|
||||||
|
throw new Error("Anthropic stream ended before message_stop");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOptions> = (
|
export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOptions> = (
|
||||||
|
|||||||
Reference in New Issue
Block a user