Conversation
- Improve error messages to recommend installing instructor[xai] - Guard xAI provider code paths when xai-sdk is missing - Document xAI extra in getting started and integrations index - Add unit tests for missing xai-sdk behavior Co-authored-by: jason <[email protected]>
|
Cursor Agent can help with this pull request. Just |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
instructor | 0bf0937 | Commit Preview URL Branch Preview URL |
Jan 29 2026, 04:15 PM |
|
@cursor can you fix tests and ruff. Update agents Md to make sure you run ruff before pushing. |
Fixes for tests + Ruff (and agent guidance)
I’ve committed and pushed these updates to the same PR branch ( |
| msg = str(excinfo.value) | ||
| assert "instructor[xai]" in msg | ||
| assert "xai-sdk" in msg | ||
|
|
There was a problem hiding this comment.
Tests fail when xai-sdk is installed
Medium Severity
The tests assume xai-sdk is not installed but lack a skip condition for when it is. If xai-sdk is present, test_direct_from_xai_has_clear_error_when_sdk_missing will raise ClientError (from the isinstance check) instead of ConfigurationError, causing the test to fail. Similar issue affects test_from_provider_xai_requires_optional_extra. Tests need to skip when xai-sdk is installed, similar to patterns used elsewhere (e.g., pytest.skip("xai-sdk is installed") in an import try/except block).
|
Bugbot Autofix resolved the bug found in the latest run.
|
feat: make xai-sdk an optional dependency
Describe your changes
This PR makes
xai-sdkan optional dependency, addressing user feedback to reduce unnecessary installations for users not requiring xAI functionality.Key changes include:
xai-sdkis now installed via theinstructor[xai]extra.xai-sdkinstalled now raises aConfigurationErrorwith clear instructions on how to install the optional extra.docs/getting-started.mdanddocs/integrations/index.mdhave been updated to reflect the new optional installation method.tests/test_xai_optional_dependency.pyto verify the correct behavior of the optional dependency and error handling.Issue ticket number and link
567-316 (Make xai-sdk an optional dependency for instructor library)
Checklist before requesting a review
Linear Issue: 567-316
Note
Low Risk
Low risk: changes are limited to xAI provider dependency gating, error messaging, and docs/tests; no core request/response logic is altered.
Overview
Makes the xAI integration truly optional by standardizing the missing-
xai-sdkbehavior: xAI entrypoints (from_provider,from_xai, and_convert_messages) now raise aConfigurationErrorwith explicit install instructions forinstructor[xai](and note the Python 3.10+ requirement).Updates docs to advertise
pip install "instructor[xai]"and addstests/test_xai_optional_dependency.pyto ensure the new error messaging is raised when the SDK is not installed.Written by Cursor Bugbot for commit 0bf0937. Configure here.