Skip to content

Commit 6fea419

Browse files
fix(groq): pass through reasoning effort (anomalyco#42166)
Co-authored-by: Aiden Cline <[email protected]>
1 parent beeabe2 commit 6fea419

4 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎bun.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
"@modelcontextprotocol/[email protected]": "patches/@modelcontextprotocol%[email protected]",
160160
161161
"@tanstack/[email protected]": "patches/@tanstack%[email protected]",
162-
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]"
162+
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]",
163+
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]"
163164
}
164165
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createGroq } from "@ai-sdk/groq"
2+
import { expect, test } from "bun:test"
3+
4+
test("Groq passes through unknown reasoning effort", 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: "openai/gpt-oss-120b",
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 = createGroq({ apiKey: "test", fetch: mockFetch })("openai/gpt-oss-120b")
21+
22+
await model.doGenerate({
23+
prompt: [{ role: "user", content: [{ type: "text", text: "Hello" }] }],
24+
providerOptions: { groq: { reasoningEffort: "custom" } },
25+
})
26+
27+
expect(body?.reasoning_effort).toBe("custom")
28+
})

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

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
diff --git a/dist/index.d.mts b/dist/index.d.mts
2+
index 8b23996dcce6c1ad5b17ef59f92196fb97312d79..80be2e52a347042b89da8e502834afd92120877a 100644
3+
--- a/dist/index.d.mts
4+
+++ b/dist/index.d.mts
5+
@@ -10,13 +10,7 @@ declare const groqLanguageModelOptions: z.ZodObject<{
6+
raw: "raw";
7+
hidden: "hidden";
8+
}>>;
9+
- reasoningEffort: z.ZodOptional<z.ZodEnum<{
10+
- none: "none";
11+
- default: "default";
12+
- low: "low";
13+
- medium: "medium";
14+
- high: "high";
15+
- }>>;
16+
+ reasoningEffort: z.ZodOptional<z.ZodString>;
17+
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
18+
user: z.ZodOptional<z.ZodString>;
19+
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
20+
diff --git a/dist/index.d.ts b/dist/index.d.ts
21+
index 8b23996dcce6c1ad5b17ef59f92196fb97312d79..80be2e52a347042b89da8e502834afd92120877a 100644
22+
--- a/dist/index.d.ts
23+
+++ b/dist/index.d.ts
24+
@@ -10,13 +10,7 @@ declare const groqLanguageModelOptions: z.ZodObject<{
25+
raw: "raw";
26+
hidden: "hidden";
27+
}>>;
28+
- reasoningEffort: z.ZodOptional<z.ZodEnum<{
29+
- none: "none";
30+
- default: "default";
31+
- low: "low";
32+
- medium: "medium";
33+
- high: "high";
34+
- }>>;
35+
+ reasoningEffort: z.ZodOptional<z.ZodString>;
36+
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
37+
user: z.ZodOptional<z.ZodString>;
38+
structuredOutputs: z.ZodOptional<z.ZodBoolean>;
39+
diff --git a/dist/index.js b/dist/index.js
40+
index 45a104f2e0775761858eac2a82ced64bceba1f5e..f60ac36f4a064d527e8f8881b1d6c58ff69286a3 100644
41+
--- a/dist/index.js
42+
+++ b/dist/index.js
43+
@@ -214,7 +214,7 @@ var groqLanguageModelOptions = import_v4.z.object({
44+
* Specifies the reasoning effort level for model inference.
45+
* @see https://console.groq.com/docs/reasoning#reasoning-effort
46+
*/
47+
- reasoningEffort: import_v4.z.enum(["none", "default", "low", "medium", "high"]).optional(),
48+
+ reasoningEffort: import_v4.z.string().optional(),
49+
/**
50+
* Whether to enable parallel function calling during tool use. Default to true.
51+
*/
52+
diff --git a/dist/index.mjs b/dist/index.mjs
53+
index c644c32235d8fa88c51c0fc6958feb1da4877c96..2c2f81869673eb4633e843d93ff5376abf1e67d0 100644
54+
--- a/dist/index.mjs
55+
+++ b/dist/index.mjs
56+
@@ -203,7 +203,7 @@ var groqLanguageModelOptions = z.object({
57+
* Specifies the reasoning effort level for model inference.
58+
* @see https://console.groq.com/docs/reasoning#reasoning-effort
59+
*/
60+
- reasoningEffort: z.enum(["none", "default", "low", "medium", "high"]).optional(),
61+
+ reasoningEffort: z.string().optional(),
62+
/**
63+
* Whether to enable parallel function calling during tool use. Default to true.
64+
*/
65+
diff --git a/src/groq-chat-options.ts b/src/groq-chat-options.ts
66+
index 3812cdf53308709f166f05c58c5d46a5d8189c8b..af520c5459bd752b3cce03c3b4afbeed31157d90 100644
67+
--- a/src/groq-chat-options.ts
68+
+++ b/src/groq-chat-options.ts
69+
@@ -33,9 +33,7 @@ export const groqLanguageModelOptions = z.object({
70+
* Specifies the reasoning effort level for model inference.
71+
* @see https://console.groq.com/docs/reasoning#reasoning-effort
72+
*/
73+
- reasoningEffort: z
74+
- .enum(['none', 'default', 'low', 'medium', 'high'])
75+
- .optional(),
76+
+ reasoningEffort: z.string().optional(),
77+
78+
/**
79+
* Whether to enable parallel function calling during tool use. Default to true.

0 commit comments

Comments
 (0)