GeezerVison is showing github.com — fix(mistral): pass through reasoning effort (#42164) · plazoleta-dev/FlupCode@bcc4dce
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/core/test/provider-mistral.test.ts +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,6 +27,32 @@ test("Mistral sends promptCacheKey as prompt_cache_key", async () => { | 27 | 27 | expect(body?.prompt_cache_key).toBe("session-123") | 28 | 28 | }) | 29 | 29 |
| | 30 | +test("Mistral passes through unknown reasoning effort", async () => { | | 31 | + let body: Record<string, unknown> | undefined | | 32 | + const mockFetch = Object.assign( | | 33 | + async (_input: Parameters<typeof fetch>[0], init?: RequestInit) => { | | 34 | + body = JSON.parse(String(init?.body)) | | 35 | + return Response.json({ | | 36 | + id: "response-1", | | 37 | + created: 0, | | 38 | + model: "mistral-large-latest", | | 39 | + object: "chat.completion", | | 40 | + choices: [{ index: 0, message: { role: "assistant", content: "Hello" }, finish_reason: "stop" }], | | 41 | + usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, | | 42 | + }) | | 43 | + }, | | 44 | + { preconnect: fetch.preconnect }, | | 45 | + ) | | 46 | + const model = createMistral({ apiKey: "test", fetch: mockFetch })("mistral-large-latest") | | 47 | + | | 48 | + await model.doGenerate({ | | 49 | + prompt: [{ role: "user", content: [{ type: "text", text: "Hello" }] }], | | 50 | + providerOptions: { mistral: { reasoningEffort: "custom" } }, | | 51 | + }) | | 52 | + | | 53 | + expect(body?.reasoning_effort).toBe("custom") | | 54 | +}) | | 55 | + | 30 | 56 | test("Mistral round-trips native reasoning in assistant history", async () => { | 31 | 57 | let body: { messages?: unknown[] } | undefined | 32 | 58 | const mockFetch = Object.assign( | |
Collapse file +16-11Lines changed: 16 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,10 +2,12 @@ diff --git a/dist/index.d.mts b/dist/index.d.mts | 2 | 2 | index 1bde0b9f8cbe6771a52c1041095c9dddfe8e5b6c..0ca2ffb2a0c9327aed5ddcf0004500dc8b42569f 100644 | 3 | 3 | --- a/dist/index.d.mts | 4 | 4 | +++ b/dist/index.d.mts | 5 | | -@@ -14,6 +14,7 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ | 6 | | - none: "none"; | 7 | | - high: "high"; | 8 | | - }>>; | | 5 | +@@ -13,7 +13,5 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ | | 6 | +- reasoningEffort: z.ZodOptional<z.ZodEnum<{ | | 7 | +- none: "none"; | | 8 | +- high: "high"; | | 9 | +- }>>; | | 10 | ++ reasoningEffort: z.ZodOptional<z.ZodString>; | 9 | 11 | + promptCacheKey: z.ZodOptional<z.ZodString>; | 10 | 12 | }, z.core.$strip>; | 11 | 13 | type MistralLanguageModelOptions = z.infer<typeof mistralLanguageModelOptions>; | @@ -14,10 +16,12 @@ diff --git a/dist/index.d.ts b/dist/index.d.ts | 14 | 16 | index 1bde0b9f8cbe6771a52c1041095c9dddfe8e5b6c..0ca2ffb2a0c9327aed5ddcf0004500dc8b42569f 100644 | 15 | 17 | --- a/dist/index.d.ts | 16 | 18 | +++ b/dist/index.d.ts | 17 | | -@@ -14,6 +14,7 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ | 18 | | - none: "none"; | 19 | | - high: "high"; | 20 | | - }>>; | | 19 | +@@ -13,7 +13,5 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ | | 20 | +- reasoningEffort: z.ZodOptional<z.ZodEnum<{ | | 21 | +- none: "none"; | | 22 | +- high: "high"; | | 23 | +- }>>; | | 24 | ++ reasoningEffort: z.ZodOptional<z.ZodString>; | 21 | 25 | + promptCacheKey: z.ZodOptional<z.ZodString>; | 22 | 26 | }, z.core.$strip>; | 23 | 27 | type MistralLanguageModelOptions = z.infer<typeof mistralLanguageModelOptions>; | @@ -69,7 +73,7 @@ index d3f904c12a1d582cc7b9e9a2d30273e1a8505b28..267f34e20ea392b7a85ad5259d72d506 | 69 | 73 | * - `'none'`: Disable reasoning | 70 | 74 | */ | 71 | 75 | - reasoningEffort: import_v4.z.enum(["high", "none"]).optional() | 72 | | -+ reasoningEffort: import_v4.z.enum(["high", "none"]).optional(), | | 76 | ++ reasoningEffort: import_v4.z.string().optional(), | 73 | 77 | + promptCacheKey: import_v4.z.string().optional() | 74 | 78 | }); | 75 | 79 |
| @@ -268,7 +272,7 @@ index d2eff622c1b84a96bdeb4012cb0206a33012a04d..3bff11ddd6136ada45809568828cbc8f | 268 | 272 | * - `'none'`: Disable reasoning | 269 | 273 | */ | 270 | 274 | - reasoningEffort: z.enum(["high", "none"]).optional() | 271 | | -+ reasoningEffort: z.enum(["high", "none"]).optional(), | | 275 | ++ reasoningEffort: z.string().optional(), | 272 | 276 | + promptCacheKey: z.string().optional() | 273 | 277 | }); | 274 | 278 |
| @@ -655,7 +659,8 @@ index 54b29c08517d348995b6ca093b11160e453d5c8b..de30c3e7d924889339e38b1067cb26e9 | 655 | 659 | @@ -64,6 +64,11 @@ export const mistralLanguageModelOptions = z.object({ | 656 | 660 | * - `'none'`: Disable reasoning | 657 | 661 | */ | 658 | | - reasoningEffort: z.enum(['high', 'none']).optional(), | | 662 | +- reasoningEffort: z.enum(['high', 'none']).optional(), | | 663 | ++ reasoningEffort: z.string().optional(), | 659 | 664 | + | 660 | 665 | + /** | 661 | 666 | + * A stable identifier used to route requests with shared prompt prefixes. | |
|