Skip to content

intrinsics examples: xgrammar import error #325

@HendrikStrobelt

Description

@HendrikStrobelt

When running examples from docs/examples/intrinsics/ .. an import error is thrown:

...
File "/Users/hen/Coding/2025_mellea/mellea/mellea/backends/huggingface.py", line 250, in generate_from_context
    mot = await self._generate_from_intrinsic(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hen/Coding/2025_mellea/mellea/mellea/backends/huggingface.py", line 368, in _generate_from_intrinsic
    granite_common.util.chat_completion_request_to_transformers_inputs(  # type: ignore
  File "/Users/hen/Coding/2025_mellea/mellea/.venv/lib/python3.12/site-packages/granite_common/util.py", line 200, in chat_completion_request_to_transformers_inputs
    import xgrammar as xgr
ModuleNotFoundError: No module named 'xgrammar'

I am unsure why this is not installed when installing granite-common. Might be in the granite-common ballpark.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions