-
Notifications
You must be signed in to change notification settings - Fork 24
Update to AI SDK v7 #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to AI SDK v7 #358
Changes from all commits
bec0504
9f060e8
85fc8e5
b6571b1
1323218
37df312
cfc184c
f7fcbd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,7 @@ function searchCommands( | |
| */ | ||
| export function createDiscoverCommandsTool(commands: CommandRegistry): ITool { | ||
| return tool({ | ||
| title: 'Discover Commands', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we still provide the title with the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like But maybe
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| metadata: { title: 'Discover Commands' }, | ||
| description: | ||
| 'Discover all available JupyterLab commands with their metadata, arguments, and descriptions', | ||
| inputSchema: z.object({ | ||
|
|
@@ -143,15 +143,30 @@ export function createDiscoverCommandsTool(commands: CommandRegistry): ITool { | |
| } | ||
|
|
||
| /** | ||
| * Create a tool to execute a specific JupyterLab command. | ||
| * Create the approval policy for the execute command tool, to be used with the | ||
| * `toolApproval` option of a `generateText`/`streamText` call or agent. | ||
| * Commands in the settings' commandsRequiringApproval list will need approval. | ||
| */ | ||
| export function createExecuteCommandTool( | ||
| commands: CommandRegistry, | ||
| export function createExecuteCommandApprovalPolicy( | ||
| settingsModel: IAISettingsModel | ||
| ): ITool { | ||
| ): (input: { commandId: string; args?: any }) => 'user-approval' | undefined { | ||
| return input => { | ||
| const commandsRequiringApproval = | ||
| settingsModel.config.commandsRequiringApproval || []; | ||
| return commandsRequiringApproval.includes(input.commandId) | ||
| ? 'user-approval' | ||
| : undefined; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Create a tool to execute a specific JupyterLab command. | ||
| * Approval for commands in the settings' commandsRequiringApproval list is | ||
| * handled at the agent level via `createExecuteCommandApprovalPolicy`. | ||
| */ | ||
| export function createExecuteCommandTool(commands: CommandRegistry): ITool { | ||
| return tool({ | ||
| title: 'Execute Command', | ||
| metadata: { title: 'Execute Command' }, | ||
| description: | ||
| 'Execute a specific JupyterLab command with optional arguments', | ||
| inputSchema: z.object({ | ||
|
|
@@ -163,11 +178,6 @@ export function createExecuteCommandTool( | |
| 'Optional arguments object to pass to the command (must be an object, not a string)' | ||
| ) | ||
| }), | ||
| needsApproval: (input: { commandId: string; args?: any }) => { | ||
| const commandsRequiringApproval = | ||
| settingsModel.config.commandsRequiringApproval || []; | ||
| return commandsRequiringApproval.includes(input.commandId); | ||
| }, | ||
| execute: async (input: { commandId: string; args?: any }) => { | ||
| const { commandId, args } = input; | ||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there any type defined in
ai-sdkthat would natively handle the stream result ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The native type seems to be
StreamTextResult<ToolMap, Context, never>butContextis not exported. So we would need to copy that type here too which may make it drift over time.