Skip to content

Commit 61d3754

Browse files
committed
refactor(ai): remove maxSteps parameter from prepareStep function and update related calls
1 parent 97eb733 commit 61d3754

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

packages/ai/core/generate-text/generate-text.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ A function that attempts to repair a tool call that failed to parse.
331331
const prepareStepResult = await prepareStep?.({
332332
model,
333333
steps,
334-
maxSteps,
335334
stepNumber: stepCount,
336335
messages: promptMessages,
337336
});

packages/ai/core/generate-text/prepare-step.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export type PrepareStepFunction<
2121
> = (options: {
2222
steps: Array<StepResult<NoInfer<TOOLS>>>;
2323
stepNumber: number;
24-
maxSteps: number;
2524
model: LanguageModel;
2625
messages: Array<LanguageModelV1Message>;
2726
}) => PromiseLike<PrepareStepResult<TOOLS>> | PrepareStepResult<TOOLS>;

packages/ai/core/generate-text/stream-text.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,8 +2982,21 @@ describe('streamText', () => {
29822982
case 1: {
29832983
expect(mode).toStrictEqual({
29842984
type: 'regular',
2985-
toolChoice: { type: 'auto' },
2986-
tools: [],
2985+
toolChoice: { type: 'tool', toolName: 'tool1' },
2986+
tools: [
2987+
{
2988+
type: 'function',
2989+
name: 'tool1',
2990+
description: undefined,
2991+
parameters: {
2992+
$schema: 'http://json-schema.org/draft-07/schema#',
2993+
additionalProperties: false,
2994+
properties: { value: { type: 'string' } },
2995+
required: ['value'],
2996+
type: 'object',
2997+
},
2998+
},
2999+
],
29873000
});
29883001

29893002
expect(prompt).toStrictEqual([

packages/ai/core/generate-text/stream-text.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,7 @@ class DefaultStreamTextResult<TOOLS extends ToolSet, OUTPUT, PARTIAL_OUTPUT>
995995
const prepareStepResult = await prepareStep?.({
996996
model,
997997
steps: recordedSteps,
998-
stepNumber: currentStep,
999-
maxSteps,
998+
stepNumber: recordedSteps.length,
1000999
messages: stepInputMessages
10011000
});
10021001

0 commit comments

Comments
 (0)