Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors parts of the Rust SDK to reduce unnecessary cloning (notably around model IDs and model variants), improves error message ergonomics, and hardens streaming UTF-8 decoding behavior.
Changes:
- Switch
ChatClient::new/AudioClient::newto take&strand clone internally only once. - Store
Modelvariants asArc<ModelVariant>to avoid cloning fullModelVariantvalues, and adjust catalog construction accordingly. - Improve
ModelLoadManagerbranching for external service vs core commands, and make streaming callback decoding resilient to invalid UTF-8.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/rust/src/openai/chat_client.rs | Constructor now accepts &str and owns via to_owned() |
| sdk/rust/src/openai/audio_client.rs | Constructor now accepts &str and owns via to_owned() |
| sdk/rust/src/model_variant.rs | Client creation avoids cloning model id String |
| sdk/rust/src/model.rs | Variants stored as Vec<Arc<ModelVariant>>; selection and client creation updated |
| sdk/rust/src/detail/model_load_manager.rs | Fix control flow to avoid always calling core load/unload when external URL is set; simplify parsing |
| sdk/rust/src/detail/core_interop.rs | Streaming UTF-8 decode now skips invalid sequences to prevent buffer growth |
| sdk/rust/src/configuration.rs | Refactor optional param insertion logic (currently introduces a compile-time partial-move issue) |
| sdk/rust/src/catalog.rs | Avoid cloning ModelVariant; improve “available” lists in errors; adjust model build logic |
Comments suppressed due to low confidence (1)
sdk/rust/src/configuration.rs:207
Configuration::newmoves fields out ofconfigintooptional_fieldsand then later accessesconfig.additional_settings/config.logger. This is a partial-move and will not compile. Consider destructuringconfiginto local variables up front (includingadditional_settingsandlogger) or usingtake()on those fields before moving the others, then buildoptional_fieldsfrom the locals.
let optional_fields = [
("AppDataDir", config.app_data_dir),
("ModelCacheDir", config.model_cache_dir),
("LogsDir", config.logs_dir),
("LogLevel", config.log_level.map(|l| l.as_core_str().into())),
("WebServiceUrls", config.web_service_urls),
("WebServiceExternalUrl", config.service_endpoint),
("FoundryLocalCorePath", config.library_path),
];
for (key, value) in optional_fields {
if let Some(v) = value {
params.insert(key.into(), v);
}
}
if let Some(extra) = config.additional_settings {
params.extend(extra);
}
Ok((Self { params }, config.logger))
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of Rust changes (have part 2 but don't have time to test it now).
This is mostly improving perf by reducing cloning and fixing some bugs + making code more readable (avoiding early returns).