Propagate IModel API changes across Python, JS, Rust SDKs and update C# docs#565
Propagate IModel API changes across Python, JS, Rust SDKs and update C# docs#565
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
9b6ff02 to
1895c97
Compare
There was a problem hiding this comment.
Pull request overview
This PR propagates the “public API returns IModel” design across the SDKs, making model variants an implementation detail and aligning model/variant selection capabilities with the interface-based API approach introduced in #556.
Changes:
- Introduces/extends
IModelacross Rust/Python/JS and updates model/variant selection APIs to operate onIModel. - Updates Rust/Python/JS Catalog methods to return interface types (
IModel/Arc<dyn IModel>) rather than concreteModel/ModelVariant. - Updates READMEs, examples, and tests to use the new interface-based APIs (including boxed callbacks in Rust).
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/rust/tests/integration/model_test.rs | Updates integration assertions to avoid direct selected-variant access patterns. |
| sdk/rust/src/model_variant.rs | Removes the previously-public ModelVariant module (variant becomes internal). |
| sdk/rust/src/lib.rs | Exposes IModel publicly and rewires exports to internal detail implementations. |
| sdk/rust/src/imodel.rs | Adds the public Rust IModel trait surface. |
| sdk/rust/src/detail/model.rs | Makes Model implement IModel and forwards operations to the selected variant. |
| sdk/rust/src/detail/model_variant.rs | Reintroduces ModelVariant as a crate-internal implementation of IModel. |
| sdk/rust/src/detail/mod.rs | Registers model and model_variant as internal detail modules. |
| sdk/rust/src/catalog.rs | Changes Catalog query methods to return Arc<dyn IModel> instead of concrete model types. |
| sdk/rust/README.md | Updates Rust documentation/examples to the IModel-based API and boxed progress callbacks. |
| sdk/rust/examples/tool_calling.rs | Updates example to use IModel accessors and boxed progress callbacks. |
| sdk/rust/examples/interactive_chat.rs | Updates example to box download progress callback. |
| sdk/rust/examples/chat_completion.rs | Updates example to box download progress callback. |
| sdk/python/src/imodel.py | Extends Python IModel with info, variants, and select_variant. |
| sdk/python/src/detail/model.py | Updates Model to implement new IModel surface and accept IModel variant selection. |
| sdk/python/src/detail/model_variant.py | Updates ModelVariant to implement variants/select_variant behavior as a single-variant IModel. |
| sdk/python/src/catalog.py | Changes Catalog return types to IModel for model/variant/cached/loaded queries. |
| sdk/python/README.md | Updates Python docs to describe IModel as the primary public abstraction. |
| sdk/js/test/openai/responsesClient.test.ts | Adjusts test import to reference internal detail/model. |
| sdk/js/test/model.test.ts | Updates test to select a variant via model.variants (IModel-based selection). |
| sdk/js/src/index.ts | Marks Model/ModelVariant exports as internal and exposes IModel type. |
| sdk/js/src/imodel.ts | Extends JS IModel with info, variants, and selectVariant. |
| sdk/js/src/detail/modelVariant.ts | Aligns ModelVariant with IModel (renames info accessor and adds single-variant behaviors). |
| sdk/js/src/detail/model.ts | Updates Model to implement IModel.info and accept IModel in selectVariant. |
| sdk/js/src/catalog.ts | Changes Catalog method return types to IModel and adds getLatestVersion. |
| sdk/js/README.md | Updates JS README language to IModel-first API reference. |
| sdk/cs/README.md | Updates C# README snippets and key-types list to reflect IModel usage. |
| samples/rust/tutorial-voice-to-text/src/main.rs | Updates sample to box download progress callbacks. |
| samples/rust/tutorial-tool-calling/src/main.rs | Updates sample to box download progress callbacks. |
| samples/rust/tutorial-document-summarizer/src/main.rs | Updates sample to box download progress callbacks. |
| samples/rust/tutorial-chat-assistant/src/main.rs | Updates sample to box download progress callbacks. |
| samples/rust/tool-calling-foundry-local/src/main.rs | Updates sample to box download progress callbacks. |
| samples/rust/native-chat-completions/src/main.rs | Updates sample to box download progress callbacks. |
| samples/rust/foundry-local-webserver/src/main.rs | Updates sample to box download progress callbacks (including move closure). |
| samples/rust/audio-transcription-example/src/main.rs | Updates sample to box download progress callbacks. |
Comments suppressed due to low confidence (3)
sdk/rust/src/detail/model.rs:172
Arc::clone(v) as Arc<dyn IModel>is likely to be rejected as a non-primitive cast. ReturnArc::clone(v)and let it coerce toArc<dyn IModel>(or explicitly bind/annotate the trait-object type) instead.
sdk/python/src/detail/model.py:58- The new error message when a variant can’t be selected is too generic (it loses the alias, requested variant id, and available ids), which makes debugging harder. Consider including the model alias, the requested
variant.id, and the set of available variant ids (similar to the previous behavior).
sdk/js/src/detail/model.ts:52 - The new error message for an invalid
selectVariantinput is too generic (it omits the model alias, requested variant id, and what variant ids are valid). Including that context will make it much easier for callers to diagnose why selection failed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…o copilot/update-language-bindings-documentation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
sdk/js/src/detail/model.ts:52
selectVariantno longer validatesvariantfor null/undefined/non-object inputs. Because this method is reachable via the publicIModelreturned byCatalog.getModel(), passing an invalid value will now throw an unhelpful runtimeTypeErrorwhen accessingvariant.id. Add an explicit guard (and a clear error) before dereferencingvariant.idto preserve runtime-safety for JS callers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Mirrors the C# changes from #556 across all language bindings: public APIs use the
IModelinterface instead of concreteModel/ModelVarianttypes,GetLatestVersionmoves fromModeltoCatalog, andModelVariantbecomes an implementation detail.IModel interface extended (Python, JS)
info,variants,selected_variant/selectedVariant,select_variant/selectVariantto the abstract interfaceModelVariantimplements these as self-referential (variants=[self],selected_variant=self,select_variantthrows)Catalog return types changed (Python, JS)
list_models()→List[IModel](wasList[Model])get_model()→Optional[IModel](wasOptional[Model])get_model_variant()→Optional[IModel](wasOptional[ModelVariant])get_cached_models()/get_loaded_models()→List[IModel](wasList[ModelVariant])get_latest_versionadded to Catalog (Python, JS, Rust)Moved from
ModeltoCatalogsinceModelVariantlacks sufficient context to implement it. Takes anyIModeland resolves the latest version by name matching against the variant list.Rust SDK
Model::info()(delegates to selected variant)Catalog::get_latest_version(&self, model: &Arc<Model>) -> Result<Arc<ModelVariant>>C# docs and samples updated
ICatalog,IModel,Model,ModelVariant) updated to reflectIModelreturn typesModelVariantdocs marked as internalModelVarianttype referencesGetLatestVersionAsyncadded toICatalogdocs