Allow schemas with tools and support overriding providers#126
Allow schemas with tools and support overriding providers#126
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enables the simultaneous use of response schemas and tools in VS Code test commands, which were previously mutually exclusive. The change consolidates the two separate streaming methods into a unified approach.
- Removes the restriction preventing tools and response schemas from being used together
- Consolidates
handleResponseSchemaStreamandhandleRegularTextStreaminto a singlehandleTextStreammethod - Updates documentation to reflect that tools can coexist with response schemas
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/poml-vscode/command/testCommand.ts | Removes mutual exclusion logic, consolidates streaming methods, and implements unified handling of tools and response schemas |
| docs/language/standalone.md | Updates documentation to remove the mutual exclusion statement and clarifies tools can work with response schemas |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import { createGoogleGenerativeAI } from '@ai-sdk/google'; | ||
| import { createAzure } from '@ai-sdk/azure'; | ||
| import { ModelMessage, streamText, tool, jsonSchema, Tool, streamObject, TextStreamPart, TextPart, ImagePart, ToolCallPart, ToolResultPart } from 'ai'; | ||
| import { ModelMessage, streamText, tool, jsonSchema, Tool, TextStreamPart, TextPart, ImagePart, ToolCallPart, ToolResultPart } from 'ai'; |
There was a problem hiding this comment.
The streamObject import was removed but may still be needed elsewhere in the codebase. Consider verifying all usage has been migrated to the new unified approach.
| @@ -281,6 +244,20 @@ export class TestCommand implements Command { | |||
| throw error; | |||
| }, | |||
| tools: prompt.tools ? this.toVercelTools(prompt.tools) : undefined, | |||
There was a problem hiding this comment.
[nitpick] Using experimental_output suggests this is an unstable API. Consider adding a comment explaining this is experimental and may change in future versions.
| tools: prompt.tools ? this.toVercelTools(prompt.tools) : undefined, | |
| tools: prompt.tools ? this.toVercelTools(prompt.tools) : undefined, | |
| // NOTE: The `experimental_output` property is an experimental/unstable API and may change or be removed in future versions of the library. |
| parsePartial: async ({ text }) => { | ||
| try { | ||
| return { partial: JSON.parse(text) }; | ||
| } catch { |
There was a problem hiding this comment.
The empty catch block silently ignores parsing errors. Consider logging the error or adding a comment explaining why the error is intentionally ignored.
| } catch { | |
| } catch (err) { | |
| console.warn('Failed to parse partial JSON output:', err, 'Input text:', text); |
…emove-schema-and-tool-use-restriction
Uh oh!
There was an error while loading. Please reload this page.