mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
fix(ai): map Z.AI's sensitive finish reason to content-filter (#66643)
This commit is contained in:
parent
a956150945
commit
ac2263f34c
2 changed files with 12 additions and 0 deletions
|
|
@ -952,6 +952,8 @@ const mapFinishReason = Effect.fnUntraced(function* (event: OpenAIChatEvent, rea
|
|||
case "length":
|
||||
return "length" as const
|
||||
case "content_filter":
|
||||
// Z.AI ends a response its safety review blocked with "sensitive".
|
||||
case "sensitive":
|
||||
return "content-filter" as const
|
||||
case "function_call":
|
||||
case "tool_calls":
|
||||
|
|
|
|||
|
|
@ -657,6 +657,16 @@ describe("OpenAI-compatible Chat route", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("maps Z.AI's sensitive finish to a content-filter finish", () =>
|
||||
Effect.gen(function* () {
|
||||
const filtered = yield* LLMClient.generate(request).pipe(
|
||||
Effect.provide(fixedResponse(sseEvents(deltaChunk({}, "sensitive")))),
|
||||
)
|
||||
|
||||
expect(filtered.finishReason).toEqual({ normalized: "content-filter", raw: "sensitive" })
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("names the content filter that blocked a response", () =>
|
||||
Effect.gen(function* () {
|
||||
const finish = (choice: object) =>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue