Normalize LM Studio exceptions - #1900
Conversation
LM Studio was the remaining client-backed model wrapper that still let transport failures escape as raw runtime exceptions. Map common connection and timeout failures into the shared Outlines APIError hierarchy and wrap sync and async client calls so callers can catch the same exception types across providers. The wrapper still lets local validation and programmer errors pass through unchanged. Stream tests also cover early consumer cancellation so GeneratorExit is not mistaken for a provider failure.
|
This is a follow-up to #1823. #1823 added the shared exception hierarchy and provider error normalization across Outlines, resolving the broader #1658 work. After that merge, LM Studio still appears to be missing from the provider normalization path: runtime transport failures can escape as raw ConnectionError / TimeoutError from the LM Studio client. This PR does not replace #1823. It fills that LM Studio-specific gap by adding lmstudio to the existing provider exception map and wrapping LM Studio sync/async generation and streaming calls with normalize_provider_errors(" lmstudio). |
|
📚 Documentation preview: https://dottxt-ai.github.io/outlines/pr-preview/pr-1900/ Preview updates automatically with each commit. |
RobinPicard
left a comment
There was a problem hiding this comment.
That's an interesting idea, but we need actual sdk error mapping to make it work and be useful. Right now the lmstudio handling in src/outlines/models/lmstudio.py is too light as it only covers generic Python errors.
Thank you for opening a PR!
A few important guidelines and requirements before we can merge your PR:
maincommit;pre-commitis installed and configured on your machine, and you ran it before opening the PR;Description
Follow-up to #1823 / #1658.
#1823 added the shared exception hierarchy and provider error normalization for most client-backed model wrappers. After that merge, LM Studio still appears to be missing from the provider normalization path: runtime transport failures can escape as raw exceptions from the LM Studio client.
This PR adds LM Studio to the shared provider exception mapping and wraps LM Studio sync and async client calls with
normalize_provider_errors("lmstudio").Changes
ConnectionErrorfailures toAPIConnectionError.TimeoutErrorfailures toAPITimeoutError.original_exceptionand Python exception chaining.ValueError, passing through unchanged.Compatibility
This keeps the existing LM Studio public API unchanged. It only standardizes provider/runtime failures under the existing Outlines exception hierarchy, while preserving the underlying exception for debugging.
Streaming is covered for both provider failures and early consumer cancellation. Since
normalize_provider_errorscatchesException,GeneratorExitand otherBaseExceptionsubclasses are not wrapped when a caller stops consuming a stream early.Verification
pre-commit run --all-filespython -m pytest tests/test_exceptions.py -k lmstudiopython -m pytest tests/models/test_lmstudio.py