GeezerVison is showing github.com — fix(server): text generators accept replies without finish_reason or … · Ryoku-dev/hyakki@3dbe40e
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/textGeneration
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/textGeneration/TextGenerators.test.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,13 +47,13 @@ it.effect.each([ | 47 | 47 | kind: "openaiCompatible", | 48 | 48 | path: "/v1/chat/completions", | 49 | 49 | auth: ["authorization", "Bearer secret"], | 50 | | - reply: { choices: [{ finish_reason: "stop", message: { content: '{"title":"Fix login"}' } }] }, | | 50 | + reply: { choices: [{ message: { content: '{"title":"Fix login"}' } }] }, | 51 | 51 | }, | 52 | 52 | { | 53 | 53 | kind: "anthropic", | 54 | 54 | path: "/v1/messages", | 55 | 55 | auth: ["x-api-key", "secret"], | 56 | | - reply: { stop_reason: "end_turn", content: [{ type: "text", text: '{"title":"Fix login"}' }] }, | | 56 | + reply: { content: [{ type: "text", text: '{"title":"Fix login"}' }] }, | 57 | 57 | }, | 58 | 58 | ] as const)("$kind generates structured text with its API's request shape", (api) => | 59 | 59 | Effect.gen(function* () { | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/textGeneration/textGeneratorDrivers.ts +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -126,8 +126,8 @@ const readModel = (entry: { readonly id: string; readonly name?: string | undefi | 126 | 126 | const ChatCompletion = Schema.Struct({ | 127 | 127 | choices: Schema.Array( | 128 | 128 | Schema.Struct({ | 129 | | - finish_reason: Schema.NullOr(Schema.String), | 130 | | - message: Schema.Struct({ content: Schema.NullOr(Schema.String) }), | | 129 | + finish_reason: Schema.optional(Schema.NullOr(Schema.String)), | | 130 | + message: Schema.Struct({ content: Schema.optional(Schema.NullOr(Schema.String)) }), | 131 | 131 | }), | 132 | 132 | ), | 133 | 133 | }); | @@ -172,7 +172,7 @@ const openAICompatible: TextGeneratorDriver = { | 172 | 172 |
| 173 | 173 | const ANTHROPIC_VERSION = "2023-06-01"; | 174 | 174 | const AnthropicMessage = Schema.Struct({ | 175 | | - stop_reason: Schema.NullOr(Schema.String), | | 175 | + stop_reason: Schema.optional(Schema.NullOr(Schema.String)), | 176 | 176 | content: Schema.Array( | 177 | 177 | Schema.Struct({ type: Schema.String, text: Schema.optional(Schema.String) }), | 178 | 178 | ), | |
|