Repository navigation
Feat(worker): xai model alias canonicalization pr #1114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,11 +36,33 @@ use crate::{ | |
| /// | ||
| /// Checks (in order): worker's per-model provider, model name heuristic, | ||
| /// then falls back to the default provider. | ||
| pub(super) fn request_provider(model: &str) -> ProviderType { | ||
| ProviderType::from_model_name(model).unwrap_or(ProviderType::OpenAI) | ||
| } | ||
|
|
||
| /// Resolve the canonical upstream model ID from the worker's live model view. | ||
| pub(super) fn resolve_effective_model(worker: &dyn Worker, model: &str) -> String { | ||
| worker | ||
| .models() | ||
| .into_iter() | ||
| .find(|candidate| candidate.matches(model)) | ||
| .map(|candidate| candidate.id) | ||
|
Comment on lines
+45
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling References
|
||
| .unwrap_or_else(|| worker.canonical_model_id(model).to_string()) | ||
|
Comment on lines
+43
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Canonicalize realtime model IDs before proxying. This helper only fixes the call sites that use it. In this file, the realtime REST/WS paths still pass the raw 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| pub(super) fn resolve_provider( | ||
| registry: &ProviderRegistry, | ||
| worker: &dyn Worker, | ||
| model: &str, | ||
| ) -> Arc<dyn super::provider::Provider> { | ||
| if let Some(pt) = worker | ||
| .models() | ||
| .into_iter() | ||
| .find(|candidate| candidate.matches(model)) | ||
| .and_then(|candidate| candidate.provider) | ||
| { | ||
|
Comment on lines
+58
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to References
|
||
| return registry.get_arc(&pt); | ||
| } | ||
| if let Some(pt) = worker.provider_for_model(model) { | ||
| return registry.get_arc(pt); | ||
| } | ||
|
|
@@ -117,7 +139,7 @@ impl OpenAIRouter { | |
| .select_worker(&SelectWorkerRequest { | ||
| model_id, | ||
| headers, | ||
| provider: Some(ProviderType::OpenAI), | ||
| provider: Some(request_provider(model_id)), | ||
| ..Default::default() | ||
| }) | ||
| .await | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This provider hint is being applied too early.
Like the chat path, this filters on
request_provider(model)before alias resolution. If the client sends an alias that only exists in discovered model metadata, the selector can exclude the real worker beforeresolve_effective_model(...)ever runs.🤖 Prompt for AI Agents