OpenAI-compatible provider (Kind::Custom, [openai_compat] config)
This commit is contained in:
1 parent
63baad33a8
commit
b00e5b503f
6 files changed
+617
-10
No files matched your search
@@ -35,6 +35,7 @@ pub fn fallback(k: Kind) -> Vec<ModelInfo> {
|
||||
m("gpt-5.6-terra", 1_050_000),
|
||||
m("gpt-5.6-luna", 1_050_000),
|
||||
],
|
||||
Kind::Custom => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,11 +44,12 @@ pub fn default_for(k: Kind, models: &[ModelInfo]) -> String {
|
||||
let mine: Vec<&ModelInfo> = models.iter().filter(|m| m.kind == k).collect();
|
||||
let pick = match k {
|
||||
Kind::Claude => mine.iter().find(|m| m.id.contains("sonnet")),
|
||||
Kind::Codex => None,
|
||||
Kind::Codex | Kind::Custom => None,
|
||||
};
|
||||
pick.or(mine.first())
|
||||
.map(|m| m.id.clone())
|
||||
.unwrap_or_else(|| fallback(k)[0].id.clone())
|
||||
.or_else(|| fallback(k).first().map(|m| m.id.clone()))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Cheapest known tier of a provider (Haiku / Luna), for read-only subagents.
|
||||
@@ -55,6 +57,7 @@ pub fn cheap_for(k: Kind, models: &[ModelInfo]) -> Option<String> {
|
||||
let tag = match k {
|
||||
Kind::Claude => "haiku",
|
||||
Kind::Codex => "luna",
|
||||
Kind::Custom => return None,
|
||||
};
|
||||
models
|
||||
.iter()
|
||||
@@ -151,6 +154,8 @@ pub async fn load_with(
|
||||
refresh: bool,
|
||||
) -> (Vec<ModelInfo>, Source) {
|
||||
let cached = read_cache(k);
|
||||
// custom endpoints are cheap to ask and their config changes by hand: never serve the cache first
|
||||
let refresh = refresh || k == Kind::Custom;
|
||||
if let Some(c) = cached
|
||||
.as_ref()
|
||||
.filter(|c| !refresh && now().saturating_sub(c.fetched) < CACHE_SECS)
|
||||
|
||||
Reference in new issue
Block a user