Skip to content

Commit a59349c

Browse files
StuBehanybidois
andcommitted
test(ai-sdk): assert toAISDK output satisfies generateText tools
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
1 parent 0c278e2 commit a59349c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/tool.test-d.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import type { generateText } from 'ai';
12
import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions';
23
import { BaseTool, Tools } from './tool';
34
import type { AISDKToolResult } from './types';
45

6+
type GenerateTextTools = NonNullable<Parameters<typeof generateText>[0]['tools']>;
7+
58
const tool = new BaseTool(
69
'test_tool',
710
'Test tool',
@@ -51,3 +54,14 @@ test('Tools.toAISDK returns AISDKToolResult', async () => {
5154
const result = await tools.toAISDK();
5255
assertType<AISDKToolResult>(result);
5356
});
57+
58+
// The point of the widened `ai` peer range is that this assignment holds on
59+
// every supported major. v7 reshaped `Tool` into a union, so a regression here
60+
// would break the primary consumer path rather than just an internal type.
61+
test('toAISDK result is accepted as generateText tools', async () => {
62+
const fromTool = await tool.toAISDK();
63+
const fromTools = await tools.toAISDK();
64+
65+
assertType<GenerateTextTools>(fromTool);
66+
assertType<GenerateTextTools>(fromTools);
67+
});

0 commit comments

Comments
 (0)