Skip to content

Conversation

@akaashrp
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds “structural tag” as a new response_format mode backed by @mlc-ai/web-xgrammar, including request validation, pipeline support, and a new browser example demonstrating MCP-style <tool_call> blocks.

Changes:

  • Extend ResponseFormat to support type: "structural_tag" and validate its required fields.
  • Update LLMChatPipeline to compile/apply structural-tag constraints via XGrammar.
  • Add a new examples/structural-tag-tool-use demo and bump @mlc-ai/web-xgrammar to 0.1.27.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/openai_api_protocols/chat_completion.ts Adds structural-tag type to ResponseFormat and enforces request invariants in postInitAndCheckFields.
src/llm_chat.ts Adds structural-tag handling for constrained decoding, plus caching refactor for matcher reuse.
src/error.ts Introduces InvalidResponseFormatStructuralTagError.
package.json Bumps @mlc-ai/web-xgrammar to 0.1.27.
package-lock.json Updates lockfile to reflect new xgrammar version (and refreshed transitive versions).
cleanup-index-js.sh Adds an additional post-build rewrite to make Parcel packaging work with scriptDirectory initialization.
examples/structural-tag-tool-use/src/mcp_structural_tag.ts New demo that requests structural-tag constrained tool calls and runs stub tools.
examples/structural-tag-tool-use/src/mcp_structural_tag.html Minimal demo page wiring up the example.
examples/structural-tag-tool-use/package.json Parcel-based build/run config for the new example.
examples/structural-tag-tool-use/README.md Usage instructions and explanation for the example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@CharlieFRuan CharlieFRuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants