Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for tool request/response elements and modernizes schema/tool definitions by replacing old <meta> element patterns with dedicated elements. The changes include adding new <tool-request> and <tool-response> tags, renaming <meta type="responseSchema"> to <output-schema>, and <meta type="tool"> to <tool-definition>.
- Support for
<tool-request>and<tool-response>elements for AI tool interactions - Migration from
<meta type="responseSchema">and<meta type="tool">to<output-schema>and<tool-definition> - Enhanced tool support in multimedia content rendering and message components
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/poml/_tags.py | Adds Python bindings for tool_request and tool_response tags |
| packages/poml/writer.ts | Implements tool request/response handling in writers and formatting improvements |
| packages/poml/tests/*.test.tsx | Comprehensive test coverage for new tool functionality and updated element names |
| packages/poml/file.tsx | Replaces meta element handling with dedicated schema/tool/runtime element handlers |
| packages/poml/essentials.tsx | Adds ToolRequest and ToolResponse components to essentials library |
| packages/poml/components/message.tsx | Updates message content handling to support tool request/response rendering |
| packages/poml/base.tsx | Extends type definitions for tool-related multimedia content |
| docs/ | Updates documentation to reflect new element names and tool functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/poml/file.tsx
Outdated
| const metaType = xmlAttribute(element, 'type')?.value; | ||
| if (metaType) { | ||
| this.reportError( | ||
| `Meta elements with type attribute has been removed. Use <${metaType === 'schema' ? 'output-schema' : metaType === 'tool' ? 'tool-definition' : metaType === 'runtime' ? 'runtime' : metaType}> instead of <meta type="${metaType}">`, |
There was a problem hiding this comment.
[nitpick] The ternary operator chain is complex and hard to read. Consider extracting this logic into a separate function or using a map/object lookup for better maintainability.
| `Meta elements with type attribute has been removed. Use <${metaType === 'schema' ? 'output-schema' : metaType === 'tool' ? 'tool-definition' : metaType === 'runtime' ? 'runtime' : metaType}> instead of <meta type="${metaType}">`, | |
| // Map old meta types to new tag names | |
| const metaTypeToTag: { [key: string]: string } = { | |
| schema: 'output-schema', | |
| tool: 'tool-definition', | |
| runtime: 'runtime' | |
| }; | |
| const replacementTag = metaTypeToTag[metaType] || metaType; | |
| this.reportError( | |
| `Meta elements with type attribute has been removed. Use <${replacementTag}> instead of <meta type="${metaType}">`, |
| speaker={speaker ?? 'ai'} | ||
| data={{ id, name, parameters }} | ||
| {...others} | ||
| /> |
There was a problem hiding this comment.
[nitpick] The fallback rendering in ToolRequest component renders the tool request as a generic Object. This could be confusing for users since it doesn't clearly indicate it's a tool request. Consider providing a more descriptive fallback or throwing an error with guidance.
| /> | |
| <div | |
| style={{ | |
| border: '1px solid #ccc', | |
| borderRadius: 4, | |
| padding: 12, | |
| background: '#f9f9f9', | |
| color: '#333', | |
| margin: '8px 0' | |
| }} | |
| {...others} | |
| > | |
| <strong>Tool Request</strong> | |
| <div><strong>ID:</strong> {id ?? <em>None</em>}</div> | |
| <div><strong>Name:</strong> {name ?? <em>None</em>}</div> | |
| <div> | |
| <strong>Parameters:</strong> | |
| <pre style={{ margin: 0, background: 'none', padding: 0 }}> | |
| {parameters ? JSON.stringify(parameters, null, 2) : <em>None</em>} | |
| </pre> | |
| </div> | |
| <div style={{ color: '#b00', marginTop: 8, fontSize: 12 }}> | |
| (Fallback rendering: ToolRequest could not be rendered in the current syntax context.) | |
| </div> | |
| </div> |
Co-authored-by: Copilot <[email protected]>
<tool-request>and<tool-response>.<meta type="responseSchema">and<meta type="tool">to<output-schema>and<tool>.