GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider): serialize Mistral prompt cache keys (#38448) · argszero/opencode@fada1a5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bun.lock
  • package.json
  • packages
    • core
      • package.json
      • test
        • provider-mistral.test.ts
    • opencode
      • package.json
  • patches
    • @ai-sdk%[email protected]
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bun.lock‎

Copy file name to clipboardExpand all lines: bun.lock
+13-4Lines changed: 13 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"@standard-community/[email protected]": "patches/@standard-community%[email protected]",
150150
"[email protected]": "patches/[email protected]",
151151
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]",
152+
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]",
152153
"[email protected]": "patches/[email protected]",
153154
"[email protected]": "patches/[email protected]",
154155
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]",
Collapse file

‎packages/core/package.json‎

Copy file name to clipboardExpand all lines: packages/core/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@ai-sdk/google": "3.0.73",
7373
"@ai-sdk/google-vertex": "4.0.128",
7474
"@ai-sdk/groq": "3.0.31",
75-
"@ai-sdk/mistral": "3.0.27",
75+
"@ai-sdk/mistral": "3.0.34",
7676
"@ai-sdk/openai": "3.0.84",
7777
"@ai-sdk/openai-compatible": "2.0.41",
7878
"@ai-sdk/perplexity": "3.0.26",
Collapse file

‎packages/core/test/provider-mistral.test.ts‎

Copy file name to clipboard
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createMistral } from "@ai-sdk/mistral"
2+
import { expect, test } from "bun:test"
3+
4+
test("Mistral sends promptCacheKey as prompt_cache_key", async () => {
5+
let body: Record<string, unknown> | undefined
6+
const mockFetch = Object.assign(
7+
async (_input: Parameters<typeof fetch>[0], init?: RequestInit) => {
8+
body = JSON.parse(String(init?.body))
9+
return Response.json({
10+
id: "response-1",
11+
created: 0,
12+
model: "mistral-large-latest",
13+
object: "chat.completion",
14+
choices: [{ index: 0, message: { role: "assistant", content: "Hello" }, finish_reason: "stop" }],
15+
usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },
16+
})
17+
},
18+
{ preconnect: fetch.preconnect },
19+
)
20+
const model = createMistral({ apiKey: "test", fetch: mockFetch })("mistral-large-latest")
21+
22+
await model.doGenerate({
23+
prompt: [{ role: "user", content: [{ type: "text", text: "Hello" }] }],
24+
providerOptions: { mistral: { promptCacheKey: "session-123" } },
25+
})
26+
27+
expect(body?.prompt_cache_key).toBe("session-123")
28+
})
Collapse file

‎packages/opencode/package.json‎

Copy file name to clipboardExpand all lines: packages/opencode/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@ai-sdk/google": "3.0.73",
6767
"@ai-sdk/google-vertex": "4.0.128",
6868
"@ai-sdk/groq": "3.0.31",
69-
"@ai-sdk/mistral": "3.0.27",
69+
"@ai-sdk/mistral": "3.0.34",
7070
"@ai-sdk/openai": "3.0.84",
7171
"@ai-sdk/openai-compatible": "2.0.41",
7272
"@ai-sdk/perplexity": "3.0.26",
Collapse file

‎patches/@ai-sdk%[email protected]‎

Copy file name to clipboard
+84Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
diff --git a/dist/index.d.ts b/dist/index.d.ts
2+
index 1ca9113bed2728a616db773a8e08d8d6957447d7..15408ec429dc210b5fa43589d81b69c93bf27b2d 100644
3+
--- a/dist/index.d.ts
4+
+++ b/dist/index.d.ts
5+
@@ -14,6 +14,7 @@ declare const mistralLanguageModelOptions: z.ZodObject<{
6+
none: "none";
7+
high: "high";
8+
}>>;
9+
+ promptCacheKey: z.ZodOptional<z.ZodString>;
10+
}, z.core.$strip>;
11+
type MistralLanguageModelOptions = z.infer<typeof mistralLanguageModelOptions>;
12+
13+
diff --git a/dist/index.js b/dist/index.js
14+
index 45735e524aaff54ea058c99c729c5ffd3c507058..6aca5f6f13da0054ede31c1f1a692e4eaed37d34 100644
15+
--- a/dist/index.js
16+
+++ b/dist/index.js
17+
@@ -268,7 +268,8 @@ var mistralLanguageModelOptions = import_v4.z.object({
18+
* - `'high'`: Enable reasoning
19+
* - `'none'`: Disable reasoning
20+
*/
21+
- reasoningEffort: import_v4.z.enum(["high", "none"]).optional()
22+
+ reasoningEffort: import_v4.z.enum(["high", "none"]).optional(),
23+
+ promptCacheKey: import_v4.z.string().optional()
24+
});
25+
26+
// src/mistral-error.ts
27+
@@ -413,6 +414,7 @@ var MistralChatLanguageModel = class {
28+
top_p: topP,
29+
random_seed: seed,
30+
reasoning_effort: options.reasoningEffort,
31+
+ prompt_cache_key: options.promptCacheKey,
32+
// response format:
33+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && (responseFormat == null ? void 0 : responseFormat.schema) != null ? {
34+
type: "json_schema",
35+
diff --git a/dist/index.mjs b/dist/index.mjs
36+
index 4c22df1cd78a1ba81309c8a86ceecefef4ba4aea..30cd3b1f503860109b7fa2107cd1eb17b70c96be 100644
37+
--- a/dist/index.mjs
38+
+++ b/dist/index.mjs
39+
@@ -256,7 +256,8 @@ var mistralLanguageModelOptions = z.object({
40+
* - `'high'`: Enable reasoning
41+
* - `'none'`: Disable reasoning
42+
*/
43+
- reasoningEffort: z.enum(["high", "none"]).optional()
44+
+ reasoningEffort: z.enum(["high", "none"]).optional(),
45+
+ promptCacheKey: z.string().optional()
46+
});
47+
48+
// src/mistral-error.ts
49+
@@ -403,6 +404,7 @@ var MistralChatLanguageModel = class {
50+
top_p: topP,
51+
random_seed: seed,
52+
reasoning_effort: options.reasoningEffort,
53+
+ prompt_cache_key: options.promptCacheKey,
54+
// response format:
55+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && (responseFormat == null ? void 0 : responseFormat.schema) != null ? {
56+
type: "json_schema",
57+
diff --git a/src/mistral-chat-language-model.ts b/src/mistral-chat-language-model.ts
58+
index 480c472d534bedbe8897979673453bd1c29a70b7..e46496da94f7d4af9822897202ca6baae67dae3a 100644
59+
--- a/src/mistral-chat-language-model.ts
60+
+++ b/src/mistral-chat-language-model.ts
61+
@@ -129,6 +129,7 @@ export class MistralChatLanguageModel implements LanguageModelV3 {
62+
top_p: topP,
63+
random_seed: seed,
64+
reasoning_effort: options.reasoningEffort,
65+
+ prompt_cache_key: options.promptCacheKey,
66+
67+
// response format:
68+
response_format:
69+
diff --git a/src/mistral-chat-options.ts b/src/mistral-chat-options.ts
70+
index 80fff45fba2c378fa06962f071946bcd2b882a0b..b4fdfa51f3bf11a4220e010c8aca92482cb0c3db 100644
71+
--- a/src/mistral-chat-options.ts
72+
+++ b/src/mistral-chat-options.ts
73+
@@ -62,6 +62,11 @@ export const mistralLanguageModelOptions = z.object({
74+
* - `'none'`: Disable reasoning
75+
*/
76+
reasoningEffort: z.enum(['high', 'none']).optional(),
77+
+
78+
+ /**
79+
+ * A stable identifier used to route requests with shared prompt prefixes.
80+
+ */
81+
+ promptCacheKey: z.string().optional(),
82+
});
83+
84+
export type MistralLanguageModelOptions = z.infer<

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.