Skip to content

fix(types): default Choice/Message/StreamChunk for litellm-fixture-compat (v0.4.6)#12

Merged
vitalii-dynamiq merged 1 commit into
mainfrom
fix/test-format
May 6, 2026
Merged

fix(types): default Choice/Message/StreamChunk for litellm-fixture-compat (v0.4.6)#12
vitalii-dynamiq merged 1 commit into
mainfrom
fix/test-format

Conversation

@vitalii-dynamiq

@vitalii-dynamiq vitalii-dynamiq commented May 6, 2026

Copy link
Copy Markdown
Contributor

Continued litellm-fixture-compat work uncovered by dynamiq integration mocks. Defaults Message.role='assistant', Choice.index=0/Choice.message=Message(), ModelResponse.choices=[Choice()], StreamChunk.choices=[ChunkChoice()]. Real provider responses always overwrite these — defaults exist purely so ModelResponse() is constructible-and-usable in fixtures. Also picks up ruff-format whitespace fix from 0.4.5.


Note

Low Risk
Low risk: changes are limited to default field values/constructors for response type structs to improve test/fixture ergonomics, with real provider responses expected to override them.

Overview
Improves LiteLLM fixture compatibility by making ModelResponse()/StreamChunk() constructible with a usable default shape: Message.role now defaults to "assistant", Choice/ChunkChoice default index=0 and default-construct their message/delta, and ModelResponse.choices/StreamChunk.choices default to a single empty choice via default_factory.

Bumps package version to 0.4.6 in arcllm/__init__.py and pyproject.toml, with a minor test formatting tweak.

Reviewed by Cursor Bugbot for commit 2dd55d6. Bugbot is set up for automated code reviews on this repo. Configure here.

…res work

Continued litellm-fixture-compat work uncovered by dynamiq's integration
mock. The mock fixture does:

    model_r = ModelResponse()
    model_r["choices"][0]["message"]["content"] = mock_text

Litellm's ``ModelResponse()`` constructs with one default Choice
containing an empty assistant Message; arcllm's ``choices: list[Choice]
= []`` left choices empty, so ``[0]`` raised IndexError.

Defaults realigned with litellm:

- ``Message.role`` defaults to ``"assistant"`` (was required)
- ``Choice.index`` defaults to 0 (was required)
- ``Choice.message`` defaults via ``msgspec.field(default_factory=Message)``
- ``ChunkChoice.index`` / ``.delta`` get the same treatment
- ``ModelResponse.choices`` and ``StreamChunk.choices`` default to a
  list with one empty Choice/ChunkChoice (via ``default_factory``)

Real provider responses always overwrite these — adapters set every
field on parse. The defaults exist purely to make ``ModelResponse()``
constructible-and-usable in test fixtures.

Also picks up the ruff-format whitespace fix in tests/test_exceptions.py
that landed broken in 0.4.5.

Bumps to 0.4.6.
@vitalii-dynamiq vitalii-dynamiq merged commit 9edb809 into main May 6, 2026
14 of 15 checks passed
@vitalii-dynamiq vitalii-dynamiq deleted the fix/test-format branch May 6, 2026 17:55
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.

1 participant