Skip to content

Commit 11423bb

Browse files
committed
build: update AI SDK and providers
* Note that `generateObject` is deprecated and replaced with `generateText` and the `output` option.
1 parent 8fe0cd3 commit 11423bb

5 files changed

Lines changed: 71 additions & 83 deletions

File tree

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
"wcs": "./runner/bin/cli.js"
5252
},
5353
"dependencies": {
54-
"@ai-sdk/anthropic": "^2.0.50",
55-
"@ai-sdk/google": "^2.0.39",
56-
"@ai-sdk/openai": "^2.0.71",
57-
"@ai-sdk/provider": "^2.0.0",
54+
"@ai-sdk/anthropic": "3.0.12",
55+
"@ai-sdk/google": "3.0.7",
56+
"@ai-sdk/openai": "3.0.9",
57+
"@ai-sdk/provider": "3.0.2",
5858
"@anthropic-ai/sdk": "^0.68.0",
5959
"@axe-core/puppeteer": "^4.10.2",
6060
"@genkit-ai/compat-oai": "1.23.0",
@@ -67,7 +67,7 @@
6767
"@types/cli-progress": "^3.11.6",
6868
"@types/node": "^24.2.0",
6969
"@types/yargs": "^17.0.33",
70-
"ai": "^5.0.95",
70+
"ai": "6.0.31",
7171
"axe-core": "^4.10.3",
7272
"boxen": "^8.0.1",
7373
"chalk": "^5.4.1",

pnpm-lock.yaml

Lines changed: 54 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runner/codegen/ai-sdk/ai-sdk-model-options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {AnthropicProviderOptions} from '@ai-sdk/anthropic';
22
import {GoogleGenerativeAIProviderOptions} from '@ai-sdk/google';
33
import {OpenAIResponsesProviderOptions} from '@ai-sdk/openai';
4-
import {LanguageModel} from 'ai';
4+
import {LanguageModelV3} from '@ai-sdk/provider';
55

66
export type ModelOptions = {
7-
model: LanguageModel;
7+
model: LanguageModelV3;
88
providerOptions:
99
| {anthropic: AnthropicProviderOptions}
1010
| {google: GoogleGenerativeAIProviderOptions}

runner/codegen/ai-sdk/ai-sdk-runner.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import {GoogleGenerativeAIProviderOptions} from '@ai-sdk/google';
33
import {OpenAIResponsesProviderOptions} from '@ai-sdk/openai';
44
import {
55
FilePart,
6-
generateObject,
76
generateText,
87
LanguageModel,
98
ModelMessage,
9+
Output,
1010
SystemModelMessage,
1111
TextPart,
1212
} from 'ai';
@@ -68,18 +68,18 @@ export class AiSDKRunner implements LlmRunner {
6868
options: LocalLlmConstrainedOutputGenerateRequestOptions<T>,
6969
): Promise<LocalLlmConstrainedOutputGenerateResponse<T>> {
7070
const response = await this._wrapRequestWithTimeoutAndRateLimiting(options, async abortSignal =>
71-
generateObject({
71+
generateText({
7272
...(await this._getAiSdkModelOptions(options)),
7373
messages: this._convertRequestToMessagesList(options),
74-
schema: options.schema,
74+
output: Output.object<z.infer<T>>({schema: options.schema}),
7575
abortSignal: abortSignal,
7676
maxRetries: DEFAULT_MAX_RETRIES,
7777
}),
7878
);
7979

8080
return {
81-
reasoning: response.reasoning ?? '',
82-
output: response.object,
81+
reasoning: response.reasoning.map(r => r.text).join('\n') ?? '',
82+
output: response.output,
8383
usage: {
8484
inputTokens: response.usage.inputTokens ?? 0,
8585
outputTokens: response.usage.outputTokens ?? 0,

runner/codegen/ai-sdk/anthropic_thinking_patch.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import type {LanguageModelV2Middleware} from '@ai-sdk/provider';
1+
import type {LanguageModelV3Middleware} from '@ai-sdk/provider';
22

33
/**
44
* Middleware for Anthropic AI SDK models that is necessary for enabling
55
* thinking mode + structured responses.
66
*
77
* This is necessary because Anthropic would be used with enforced tool usage
8-
* by default with `generateObject()`. This is a workaround that makes the tool
9-
* optional: https://github.com/vercel/ai/issues/9351.
8+
* by default with `generateText()`. This is a workaround that makes the tool
9+
* optional: https://github.com/vercel/ai/issues/9351, https://github.com/vercel/ai/issues/11227.
1010
*/
11-
export const anthropicThinkingWithStructuredResponseMiddleware: LanguageModelV2Middleware = {
11+
export const anthropicThinkingWithStructuredResponseMiddleware: LanguageModelV3Middleware = {
12+
specificationVersion: 'v3',
1213
transformParams: ({params}) => {
1314
if (params.responseFormat?.type === 'json' && params.responseFormat.schema) {
1415
params.tools = [

0 commit comments

Comments
 (0)