luxe 0.1.4: remembered models, wheel-driven lists, and a steadier phone app
- luxe starts on the model you last chose in this project, then the last one anywhere. Signing in opens the model picker instead of choosing for you. - Every list in a modal takes the mouse wheel and a draggable scrollbar. - The phone app shows reasoning in full, stays put while you read back through a long session, and shows a question's answer on its card. - On Windows, luxe update replaces the running luxe, and a signed-in install no longer sees setup again. - The file tree no longer shows "engine busy" in a large project, loop output is easier to follow, and the name is written lowercase. The CHANGELOG has the full list.
This commit is contained in:
@@ -202,7 +202,7 @@ pub(crate) fn build_anthropic_request(
|
||||
(ThinkingLevel::Off, _) => {}
|
||||
(_, ThinkingMode::Adaptive) => {
|
||||
// `display: "summarized"` because the newest models omit thinking text by default and
|
||||
// Luxe shows reasoning in the transcript.
|
||||
// luxe shows reasoning in the transcript.
|
||||
body["thinking"] = serde_json::json!({"type": "adaptive", "display": "summarized"});
|
||||
body["output_config"] = serde_json::json!({"effort": effort});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::super::*;
|
||||
/// far) from cache instead of re-reading it every turn.
|
||||
///
|
||||
/// Anthropic caches the whole prompt prefix up to and including each marked block, in the canonical
|
||||
/// order tools → system → messages, and allows four markers. Luxe spends them on:
|
||||
/// order tools → system → messages, and allows four markers. luxe spends them on:
|
||||
///
|
||||
/// 1. the system prompt, at the end of its shared part,
|
||||
/// 2. the last listed tool definition — with (1), the ~static floor. A deferred one can't
|
||||
|
||||
@@ -237,7 +237,7 @@ pub(crate) fn serialize_tool_result_blocks(
|
||||
|
||||
/// Find a `System`-role message's text, for a caller that passes the prompt that way.
|
||||
///
|
||||
/// Luxe's engine does not — it uses [`CompletionRequest::system`] — so this is a fallback.
|
||||
/// luxe's engine does not — it uses [`CompletionRequest::system`] — so this is a fallback.
|
||||
pub(crate) fn find_system_message(messages: &[Message]) -> Option<String> {
|
||||
messages.iter().find(|m| m.role == luxe_core::message::Role::System).map(Message::text)
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ fn a_failed_activation_is_left_as_text() {
|
||||
assert_eq!(turn[0]["is_error"], true);
|
||||
}
|
||||
|
||||
/// Listing is the request Luxe always sent: the engine's list as is, and no reference anywhere.
|
||||
/// Listing is the request luxe always sent: the engine's list as is, and no reference anywhere.
|
||||
/// The same holds for a pass that withholds tools, where a reference would point at nothing.
|
||||
#[test]
|
||||
fn listing_and_a_toolless_pass_send_no_deferred_tools() {
|
||||
|
||||
@@ -27,7 +27,7 @@ fn stop(reason: &str) -> Vec<ProviderEvent> {
|
||||
))
|
||||
}
|
||||
|
||||
/// A refusal is the model declining, not finishing, and a stop reason Luxe does not know is
|
||||
/// A refusal is the model declining, not finishing, and a stop reason luxe does not know is
|
||||
/// said as itself.
|
||||
///
|
||||
/// The break this catches: every stop reason the decoder did not name became `EndTurn`, so a
|
||||
|
||||
@@ -47,7 +47,7 @@ fn an_effort_only_model_is_steered_with_adaptive_thinking_and_effort() {
|
||||
assert_eq!(xhigh["thinking"]["type"], "adaptive");
|
||||
assert_eq!(xhigh["output_config"]["effort"], "xhigh");
|
||||
assert!(xhigh["thinking"].get("budget_tokens").is_none(), "extended thinking would 400");
|
||||
// Luxe shows reasoning in the transcript, and these models omit the text by default.
|
||||
// luxe shows reasoning in the transcript, and these models omit the text by default.
|
||||
assert_eq!(xhigh["thinking"]["display"], "summarized");
|
||||
|
||||
// A level the model doesn't offer clamps to one it does rather than inventing an effort.
|
||||
|
||||
@@ -38,7 +38,7 @@ pub use store::{AuthStore, StoreError};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Luxe's config directory, where the credential store and `models.json` live. See
|
||||
/// luxe's config directory, where the credential store and `models.json` live. See
|
||||
/// [`luxe_core::user_dirs::luxe_config_dir`], the one owner.
|
||||
pub fn config_dir() -> PathBuf {
|
||||
luxe_core::user_dirs::luxe_config_dir()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Provider catalog — the curated set of providers a user can configure, and how each is reached.
|
||||
//!
|
||||
//! Curated rather than derived: models.dev knows every provider's models but not the wire quirks
|
||||
//! Luxe needs (which API a provider speaks, whether it takes `developer` roles, how it spells a
|
||||
//! luxe needs (which API a provider speaks, whether it takes `developer` roles, how it spells a
|
||||
//! thinking toggle), and a *wrong* default is worse than an absent one. Anything not listed here
|
||||
//! still works — `custom` covers any OpenAI-compatible endpoint, and a hand-written `models.json`
|
||||
//! provider block always wins over these defaults.
|
||||
@@ -151,12 +151,6 @@ pub struct ProviderDescriptor {
|
||||
/// Separate from having an OAuth method: OpenRouter's flow mints a key that bills real credits
|
||||
/// per token, so it is *not* subscription-metered.
|
||||
pub subscription_billed: bool,
|
||||
/// Models worth defaulting to, best first.
|
||||
///
|
||||
/// A capable workhorse rather than the flagship: nobody who never chose a model should be handed
|
||||
/// the most expensive one. Only ever used when the account can actually reach the id, so a stale
|
||||
/// entry costs nothing but a fallback.
|
||||
pub preferred_models: &'static [&'static str],
|
||||
}
|
||||
|
||||
impl ProviderDescriptor {
|
||||
@@ -267,7 +261,7 @@ impl ProviderDescriptor {
|
||||
|
||||
/// Alternate spellings accepted on the command line and in config.
|
||||
///
|
||||
/// `openai_compat` is Luxe's historical default provider name; the rest are the names people
|
||||
/// `openai_compat` is luxe's historical default provider name; the rest are the names people
|
||||
/// actually type.
|
||||
const ALIASES: &[(&str, &str)] = &[
|
||||
("openai_compat", "openai"),
|
||||
|
||||
@@ -42,7 +42,6 @@ pub(super) const BASE: ProviderDescriptor = ProviderDescriptor {
|
||||
compat_defaults: plain,
|
||||
served_models: ServedModels::Catalog,
|
||||
subscription_billed: false,
|
||||
preferred_models: &[],
|
||||
};
|
||||
|
||||
/// The curated catalog.
|
||||
@@ -59,7 +58,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
models_dev: Some("openai"),
|
||||
console_url: Some("https://platform.openai.com/api-keys"),
|
||||
key_hint: Some("sk-…"),
|
||||
preferred_models: &["gpt-5.6", "gpt-5.4", "gpt-5.2", "gpt-5"],
|
||||
compat_defaults: openai_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -84,7 +82,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
"gpt-5.3-codex-spark",
|
||||
]),
|
||||
subscription_billed: true,
|
||||
preferred_models: &["gpt-5.6-sol", "gpt-5.4", "gpt-5.3-codex-spark"],
|
||||
compat_defaults: codex_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -99,9 +96,8 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
key_hint: Some("sk-ant-…"),
|
||||
note: Some(
|
||||
"API key only. Anthropic's terms forbid using a Claude Pro/Max subscription from a \
|
||||
third-party harness, so Luxe does not offer that sign-in.",
|
||||
third-party harness, so luxe does not offer that sign-in.",
|
||||
),
|
||||
preferred_models: &["claude-sonnet-5-5", "claude-sonnet-5", "claude-sonnet-4-6"],
|
||||
compat_defaults: anthropic_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -119,7 +115,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
picker → Enable.",
|
||||
),
|
||||
subscription_billed: true,
|
||||
preferred_models: &["claude-sonnet-5", "gpt-5.6-sol", "gpt-5.4"],
|
||||
compat_defaults: copilot_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -133,7 +128,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
oauth: Some((OauthFlow::OpenRouter, "Sign in with OpenRouter")),
|
||||
console_url: Some("https://openrouter.ai/keys"),
|
||||
key_hint: Some("sk-or-…"),
|
||||
preferred_models: &["anthropic/claude-sonnet-5", "openai/gpt-5.6-sol"],
|
||||
compat_defaults: openrouter_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -148,9 +142,8 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
key_hint: Some("AIza…"),
|
||||
note: Some(
|
||||
"API key only. Google's terms forbid using Gemini CLI / Google AI subscription sign-in \
|
||||
from a third-party harness, so Luxe does not offer that sign-in.",
|
||||
from a third-party harness, so luxe does not offer that sign-in.",
|
||||
),
|
||||
preferred_models: &["gemini-3.1-pro-preview", "gemini-3.8-flash", "gemini-2.5-pro"],
|
||||
..BASE
|
||||
},
|
||||
ProviderDescriptor {
|
||||
@@ -162,7 +155,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
models_dev: Some("xai"),
|
||||
console_url: Some("https://console.x.ai"),
|
||||
key_hint: Some("xai-…"),
|
||||
preferred_models: &["grok-4.5", "grok-4.3"],
|
||||
..BASE
|
||||
},
|
||||
ProviderDescriptor {
|
||||
@@ -174,7 +166,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
models_dev: Some("deepseek"),
|
||||
console_url: Some("https://platform.deepseek.com/api_keys"),
|
||||
key_hint: Some("sk-…"),
|
||||
preferred_models: &["deepseek-v4-pro", "deepseek-flash", "deepseek-v4-flash"],
|
||||
compat_defaults: deepseek_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -230,7 +221,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
env: &["ZAI_API_KEY"],
|
||||
models_dev: Some("zai"),
|
||||
console_url: Some("https://z.ai/manage-apikey/apikey-list"),
|
||||
preferred_models: &["glm-4.6", "glm-4.5"],
|
||||
..BASE
|
||||
},
|
||||
ProviderDescriptor {
|
||||
@@ -304,7 +294,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
lists_deployments: true,
|
||||
paired_with: &["foundry-anthropic", "foundry-completions"],
|
||||
served_models: ServedModels::Unprefixed(FOUNDRY_NON_RESPONSES_PREFIXES),
|
||||
preferred_models: &["gpt-5.6-terra", "gpt-5.6-sol", "gpt-5.6-luna", "gpt-5.4"],
|
||||
compat_defaults: openai_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -330,7 +319,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
lists_deployments: true,
|
||||
paired_with: &["foundry-openai", "foundry-completions"],
|
||||
served_models: ServedModels::Prefixed(FOUNDRY_ANTHROPIC_PREFIXES),
|
||||
preferred_models: &["claude-sonnet-5-5", "claude-sonnet-5", "claude-sonnet-4-6"],
|
||||
compat_defaults: anthropic_flags,
|
||||
..BASE
|
||||
},
|
||||
@@ -350,7 +338,6 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
lists_deployments: true,
|
||||
paired_with: &["foundry-openai", "foundry-anthropic"],
|
||||
served_models: ServedModels::Prefixed(FOUNDRY_COMPLETIONS_PREFIXES),
|
||||
preferred_models: &["deepseek-v4-pro", "grok-4-20-reasoning", "llama-3.3-70b-instruct"],
|
||||
..BASE
|
||||
},
|
||||
ProviderDescriptor {
|
||||
@@ -362,7 +349,7 @@ pub(super) static CATALOG: &[ProviderDescriptor] = &[
|
||||
console_url: Some("https://portal.azure.com"),
|
||||
note: Some(
|
||||
"For an `openai.azure.com` resource. A `services.ai.azure.com` one is Microsoft \
|
||||
Foundry — pick that instead and Luxe derives both endpoints for you.",
|
||||
Foundry — pick that instead and luxe derives both endpoints for you.",
|
||||
),
|
||||
needs_base_url: true,
|
||||
lists_deployments: true,
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::auth::catalog::ResourceEndpoint;
|
||||
|
||||
/// Model-id prefixes that Microsoft Foundry reaches through its Anthropic passthrough.
|
||||
///
|
||||
/// The split between Luxe's two Foundry providers, stated once. Every Anthropic-published model in
|
||||
/// The split between luxe's two Foundry providers, stated once. Every Anthropic-published model in
|
||||
/// the models.dev `azure` catalog is named `claude-*`, and a test holds that true.
|
||||
pub(in crate::auth::catalog) const FOUNDRY_ANTHROPIC_PREFIXES: &[&str] = &["claude-"];
|
||||
|
||||
|
||||
@@ -75,46 +75,10 @@ fn models_dev_ids_exist_in_the_embedded_snapshot() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A preference list of ids nothing recognizes is worse than no list: it would hand a new user a
|
||||
/// model their account can't serve. At least one entry must still exist upstream.
|
||||
///
|
||||
/// The leading id is the one a new account actually gets, so it is held to the stricter bar: a
|
||||
/// dead first choice is a silent demotion to the runner-up on every fresh install.
|
||||
#[test]
|
||||
fn preferred_models_still_exist_in_the_embedded_snapshot() {
|
||||
let snapshot = crate::catalog::snapshot();
|
||||
for descriptor in CATALOG {
|
||||
if descriptor.preferred_models.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let models_dev = crate::catalog::alias::models_dev_provider(&descriptor.id, None);
|
||||
let known = |id: &str| {
|
||||
snapshot.model(models_dev, id).is_some()
|
||||
|| crate::catalog::alias::normalize_model_id(id)
|
||||
.is_some_and(|base| snapshot.model(models_dev, base).is_some())
|
||||
};
|
||||
let live = descriptor.preferred_models.iter().filter(|id| known(id)).count();
|
||||
assert!(
|
||||
live > 0,
|
||||
"{}: none of its preferred models {:?} exist under models.dev '{models_dev}' \
|
||||
— refresh the list or the snapshot",
|
||||
descriptor.id,
|
||||
descriptor.preferred_models
|
||||
);
|
||||
let first = descriptor.preferred_models[0];
|
||||
assert!(
|
||||
known(first),
|
||||
"{}: its first-choice model '{first}' is gone from models.dev '{models_dev}', so \
|
||||
every new account silently falls through to the next entry — promote a live id",
|
||||
descriptor.id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A served rule is a promise: an explicit id the metadata catalog doesn't know would show up
|
||||
/// as a model with no context window, and a prefix nothing matches would empty the picker.
|
||||
#[test]
|
||||
fn served_rules_match_real_models_and_cover_the_preferred_ones() {
|
||||
fn served_rules_match_real_models() {
|
||||
let snapshot = crate::catalog::snapshot();
|
||||
for descriptor in CATALOG {
|
||||
if descriptor.served_models == ServedModels::Catalog {
|
||||
@@ -148,14 +112,6 @@ fn served_rules_match_real_models_and_cover_the_preferred_ones() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Defaulting to a model the backend refuses is the bug this pairing prevents.
|
||||
for preferred in descriptor.preferred_models {
|
||||
assert!(
|
||||
descriptor.served_models.serves(preferred),
|
||||
"{}: prefers '{preferred}', which it does not serve",
|
||||
descriptor.id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +150,7 @@ fn the_three_foundry_surfaces_partition_the_azure_catalog() {
|
||||
assert!(count >= 5, "{} serves only {count} models", surface.id);
|
||||
}
|
||||
|
||||
// The split is the publisher, so a deployment name Luxe has never heard of still lands on
|
||||
// The split is the publisher, so a deployment name luxe has never heard of still lands on
|
||||
// the OpenAI-shaped surface rather than nowhere.
|
||||
let served_by = |id: &str| -> Vec<&str> {
|
||||
surfaces
|
||||
|
||||
@@ -39,16 +39,14 @@ impl ConfigFile {
|
||||
self.file.path()
|
||||
}
|
||||
|
||||
/// Point Luxe at a provider (and optionally a model) by default.
|
||||
/// Point luxe at a provider by default, leaving `default_model` as the user wrote it.
|
||||
///
|
||||
/// This is what makes a first login actually take effect for the *next* launch; the running
|
||||
/// session switches through `Action::SetModel`.
|
||||
pub fn set_defaults(&self, provider: &str, model: Option<&str>) -> Result<(), FileError> {
|
||||
/// This is what makes a first login take effect for the *next* launch. The model stays the
|
||||
/// reader's choice: the one they last picked is remembered apart from this file, and a login
|
||||
/// that wrote one would be luxe choosing for them.
|
||||
pub fn set_default_provider(&self, provider: &str) -> Result<(), FileError> {
|
||||
self.file.modify(|root| {
|
||||
root.insert("default_provider".into(), Value::String(provider.to_string()));
|
||||
if let Some(model) = model.filter(|model| !model.is_empty()) {
|
||||
root.insert("default_model".into(), Value::String(model.to_string()));
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
@@ -80,7 +78,7 @@ impl ConfigFile {
|
||||
// the compat flag below recorded an `anthropic-messages` endpoint as
|
||||
// chat/completions, and the choice made in the wizard was silently lost.
|
||||
block.insert("api".into(), Value::String(api.as_str().to_string()));
|
||||
// Kept beside it because a Luxe old enough to predate `api` reads this one, and a
|
||||
// Kept beside it because a luxe old enough to predate `api` reads this one, and a
|
||||
// config file outlives the release that wrote it.
|
||||
let compat = block
|
||||
.entry("compat".to_string())
|
||||
@@ -196,18 +194,18 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn defaults_are_written_without_disturbing_anything_else() {
|
||||
fn the_default_provider_is_written_without_disturbing_anything_else() {
|
||||
let (_dir, config) = config();
|
||||
std::fs::write(
|
||||
config.path(),
|
||||
r#"{"models": {"a/b": {"context_window": 1}}, "default_model": "old"}"#,
|
||||
)
|
||||
.unwrap();
|
||||
config.set_defaults("openai", Some("gpt-5.4")).unwrap();
|
||||
config.set_default_provider("openai").unwrap();
|
||||
let root = serde_json::from_str::<Value>(&std::fs::read_to_string(config.path()).unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(root["default_provider"], "openai");
|
||||
assert_eq!(root["default_model"], "gpt-5.4");
|
||||
assert_eq!(root["default_model"], "old", "the user's own default stays theirs");
|
||||
assert_eq!(root["models"]["a/b"]["context_window"], 1, "unrelated config survives");
|
||||
}
|
||||
|
||||
|
||||
@@ -105,11 +105,11 @@ impl CallbackServer {
|
||||
match &result {
|
||||
Ok(_) => {
|
||||
let message = "You can close this tab and return to the terminal.";
|
||||
arrival.answer(200, "Signed in to Luxe", message).await;
|
||||
arrival.answer(200, "Signed in to luxe", message).await;
|
||||
}
|
||||
Err(message) => {
|
||||
let message = format!("Authorization failed: {message}");
|
||||
arrival.answer(400, "Luxe couldn't finish the sign-in", &message).await;
|
||||
arrival.answer(400, "luxe couldn't finish the sign-in", &message).await;
|
||||
}
|
||||
}
|
||||
let _ = sender.send(result);
|
||||
@@ -381,7 +381,7 @@ fn truncate(text: &str, max: usize) -> String {
|
||||
/// Decode a JWT payload without verifying it.
|
||||
///
|
||||
/// Only ever used to read a claim the provider put there for us (the ChatGPT account id). The token
|
||||
/// is opaque to Luxe otherwise; we are not making a trust decision on it.
|
||||
/// is opaque to luxe otherwise; we are not making a trust decision on it.
|
||||
pub fn decode_jwt_payload(token: &str) -> Option<Value> {
|
||||
let payload = token.split('.').nth(1)?;
|
||||
let bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD
|
||||
|
||||
@@ -77,10 +77,10 @@ const SCOPE: &str = "openid profile email offline_access";
|
||||
/// Claim namespace OpenAI puts the account id under.
|
||||
const AUTH_CLAIM: &str = "https://api.openai.com/auth";
|
||||
|
||||
/// How Luxe identifies itself to the Codex backend, unless `LUXE_CODEX_ORIGINATOR` says otherwise.
|
||||
/// How luxe identifies itself to the Codex backend, unless `LUXE_CODEX_ORIGINATOR` says otherwise.
|
||||
///
|
||||
/// Sent on the authorize request and on every Codex call. Honest by default — Luxe says it is
|
||||
/// Luxe. The override exists because this is the one value in the flow taken from another client's
|
||||
/// Sent on the authorize request and on every Codex call. Honest by default — luxe says it is
|
||||
/// luxe. The override exists because this is the one value in the flow taken from another client's
|
||||
/// behavior rather than from documentation: if the backend ever refuses an unknown originator, a
|
||||
/// user can get working again without waiting for a release.
|
||||
const DEFAULT_ORIGINATOR: &str = "luxe";
|
||||
@@ -408,7 +408,7 @@ mod tests {
|
||||
let _guard = ENV_LOCK.lock().unwrap_or_else(|error| error.into_inner());
|
||||
let previous = std::env::var("LUXE_CODEX_ORIGINATOR").ok();
|
||||
std::env::remove_var("LUXE_CODEX_ORIGINATOR");
|
||||
assert_eq!(originator(), "luxe", "Luxe identifies itself honestly by default");
|
||||
assert_eq!(originator(), "luxe", "luxe identifies itself honestly by default");
|
||||
|
||||
std::env::set_var("LUXE_CODEX_ORIGINATOR", "codex_cli_rs");
|
||||
assert_eq!(originator(), "codex_cli_rs");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The login engine — [`ProviderAuth`], Luxe's [`AuthService`].
|
||||
//! The login engine — [`ProviderAuth`], luxe's [`AuthService`].
|
||||
//!
|
||||
//! One implementation drives every surface: `luxe auth login`, the TUI's `/login` wizard, and the
|
||||
//! credential-less first-run path all call the same three methods. The front-end only supplies an
|
||||
@@ -28,9 +28,7 @@ use super::deployments;
|
||||
use super::source::RequestAuth;
|
||||
use super::store::AuthStore;
|
||||
use crate::config::{resolve_key, ApiKey};
|
||||
use models::{
|
||||
describe_models, normalize_base_url, pick_model, verify_credential, warn_if_sent_in_the_clear,
|
||||
};
|
||||
use models::{describe_models, normalize_base_url, verify_credential, warn_if_sent_in_the_clear};
|
||||
use refresh::discover_with_key;
|
||||
|
||||
mod custom;
|
||||
@@ -45,16 +43,15 @@ struct Key {
|
||||
resolved: String,
|
||||
}
|
||||
|
||||
/// What verification learned: a default to suggest, what to tell the user, and what the resource
|
||||
/// has deployed when it said.
|
||||
/// What verification learned: what to tell the user, and what the resource has deployed when it
|
||||
/// said.
|
||||
#[derive(Default)]
|
||||
struct Checked<'a> {
|
||||
suggested_model: Option<String>,
|
||||
notes: Vec<String>,
|
||||
discovered: Option<Vec<(&'a str, deployments::Served)>>,
|
||||
}
|
||||
|
||||
/// Luxe's [`AuthService`]: catalog + credential store + the OAuth flows.
|
||||
/// luxe's [`AuthService`]: catalog + credential store + the OAuth flows.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProviderAuth {
|
||||
store: AuthStore,
|
||||
@@ -128,7 +125,6 @@ impl ProviderAuth {
|
||||
provider_name: descriptor.name.to_string(),
|
||||
kind: Some(CredentialKind::ApiKey),
|
||||
account: None,
|
||||
suggested_model: checked.suggested_model,
|
||||
notes: checked.notes,
|
||||
advice: descriptor.after_login.map(str::to_string).into_iter().collect(),
|
||||
})
|
||||
@@ -157,9 +153,6 @@ impl ProviderAuth {
|
||||
_ => None,
|
||||
};
|
||||
if let Some(split) = &discovered {
|
||||
let own = split.iter().find(|(id, _)| *id == &*descriptor.id);
|
||||
checked.suggested_model =
|
||||
own.and_then(|(_, served)| pick_model(descriptor, &served.models));
|
||||
checked.notes.extend(deployments::describe(split));
|
||||
}
|
||||
// A provider with no model list can't answer for itself; where it shares a resource with
|
||||
@@ -178,7 +171,6 @@ impl ProviderAuth {
|
||||
.map(|root| checker.endpoint_for(root))
|
||||
.or_else(|| checker.base_url.map(str::to_string));
|
||||
let models = verify_credential(checker, endpoint.as_deref(), &auth).await?;
|
||||
checked.suggested_model = pick_model(descriptor, &models);
|
||||
checked.notes.extend(describe_models(&models));
|
||||
}
|
||||
}
|
||||
@@ -205,7 +197,7 @@ impl ProviderAuth {
|
||||
notes.push(format!("{} is configured with the same key", sibling.name));
|
||||
}
|
||||
self.persist(&descriptor.id, credential)?;
|
||||
self.record_config(descriptor, resource_root, checked.suggested_model.as_deref())?;
|
||||
self.record_config(descriptor, resource_root)?;
|
||||
for (id, served) in checked.discovered.iter().flatten() {
|
||||
self.config
|
||||
.set_deployments(id, served)
|
||||
@@ -234,14 +226,13 @@ impl ProviderAuth {
|
||||
let mut notes = Vec::new();
|
||||
let available =
|
||||
credential.as_oauth().map(|oauth| oauth.available_models.clone()).unwrap_or_default();
|
||||
let mut suggested_model = pick_model(descriptor, &available);
|
||||
if let Some(note) = describe_models(&available) {
|
||||
notes.push(note);
|
||||
}
|
||||
|
||||
// OpenRouter's flow mints an API key; the others hand back a token pair. Either way the
|
||||
// provider is only really configured once we can list its models.
|
||||
if suggested_model.is_none() && self.verify {
|
||||
if available.is_empty() && self.verify {
|
||||
interaction.notify(AuthEvent::Progress { message: "Checking access…".to_string() });
|
||||
let auth = match &credential {
|
||||
Credential::OAuth(oauth) => {
|
||||
@@ -258,7 +249,6 @@ impl ProviderAuth {
|
||||
let endpoint =
|
||||
auth.base_url.clone().or_else(|| descriptor.base_url.map(str::to_string));
|
||||
if let Ok(models) = verify_credential(descriptor, endpoint.as_deref(), &auth).await {
|
||||
suggested_model = pick_model(descriptor, &models);
|
||||
if let Some(note) = describe_models(&models) {
|
||||
notes.push(note);
|
||||
}
|
||||
@@ -267,13 +257,12 @@ impl ProviderAuth {
|
||||
|
||||
let account = credential.as_oauth().and_then(|oauth| oauth.account.clone());
|
||||
self.persist(&descriptor.id, &credential)?;
|
||||
self.record_config(descriptor, None, suggested_model.as_deref())?;
|
||||
self.record_config(descriptor, None)?;
|
||||
Ok(LoginOutcome {
|
||||
provider_id: descriptor.id.to_string(),
|
||||
provider_name: descriptor.name.to_string(),
|
||||
kind: Some(credential.kind()),
|
||||
account,
|
||||
suggested_model,
|
||||
notes,
|
||||
// Advice that only makes sense now that the credential exists.
|
||||
advice: descriptor.after_login.map(str::to_string).into_iter().collect(),
|
||||
@@ -314,11 +303,10 @@ impl ProviderAuth {
|
||||
)));
|
||||
}
|
||||
|
||||
let suggested_model = models.first().cloned();
|
||||
// Recorded even when it is the default, because the block is the only durable record that
|
||||
// this server was connected at all — a keyless provider leaves nothing in `auth.json`, so
|
||||
// without it the machine reports itself unconfigured on the next launch.
|
||||
self.record_config(descriptor, Some(&base_url), suggested_model.as_deref())?;
|
||||
self.record_config(descriptor, Some(&base_url))?;
|
||||
// And what it serves, which the catalog cannot answer for a machine it has never seen.
|
||||
self.config
|
||||
.set_served_models(&descriptor.id, &models)
|
||||
@@ -328,22 +316,20 @@ impl ProviderAuth {
|
||||
provider_name: descriptor.name.to_string(),
|
||||
kind: None,
|
||||
account: None,
|
||||
suggested_model,
|
||||
notes: describe_models(&models).into_iter().collect(),
|
||||
advice: descriptor.after_login.map(str::to_string).into_iter().collect(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Persist what the runtime needs to reach this provider next launch, and point Luxe at it.
|
||||
/// Persist what the runtime needs to reach this provider next launch, and point luxe at it.
|
||||
fn record_config(
|
||||
&self,
|
||||
descriptor: &ProviderDescriptor,
|
||||
resource_root: Option<&str>,
|
||||
model: Option<&str>,
|
||||
) -> Result<(), AuthError> {
|
||||
self.record_provider(descriptor, resource_root)?;
|
||||
self.config
|
||||
.set_defaults(&descriptor.id, model)
|
||||
.set_default_provider(&descriptor.id)
|
||||
.map_err(|error| AuthError::Storage(error.to_string()))
|
||||
}
|
||||
|
||||
|
||||
@@ -94,22 +94,6 @@ pub(super) fn answers_nothing(id: &str) -> bool {
|
||||
["embed", "rerank"].iter().any(|kind| id.contains(kind))
|
||||
}
|
||||
|
||||
/// A default model worth pointing the user at.
|
||||
///
|
||||
/// Prefers the provider's own preference order (the catalog default, when the account can actually
|
||||
/// reach it), then the first model the endpoint reported. Never invents an id the account can't use.
|
||||
pub(super) fn pick_model(descriptor: &ProviderDescriptor, available: &[String]) -> Option<String> {
|
||||
if available.is_empty() {
|
||||
return None;
|
||||
}
|
||||
descriptor
|
||||
.preferred_models
|
||||
.iter()
|
||||
.find(|candidate| available.iter().any(|id| id == *candidate))
|
||||
.map(|candidate| (*candidate).to_string())
|
||||
.or_else(|| available.first().cloned())
|
||||
}
|
||||
|
||||
/// "17 models available" — the line that tells a user the login actually worked.
|
||||
pub(super) fn describe_models(models: &[String]) -> Option<String> {
|
||||
if models.is_empty() {
|
||||
|
||||
@@ -62,10 +62,10 @@ impl ProviderAuth {
|
||||
changed
|
||||
}
|
||||
|
||||
/// Ask every Azure resource Luxe is set up for what it has deployed, answering whether any
|
||||
/// Ask every Azure resource luxe is set up for what it has deployed, answering whether any
|
||||
/// recorded list moved.
|
||||
///
|
||||
/// Deployments change in a portal Luxe never sees, so the list is re-read rather than trusted
|
||||
/// Deployments change in a portal luxe never sees, so the list is re-read rather than trusted
|
||||
/// from login. One request per resource, not per provider: the three Foundry providers share
|
||||
/// one. A resource that does not answer in time, refuses the key, or no longer has the route
|
||||
/// leaves its recorded list standing, and `"discover_deployments": false` on any of its
|
||||
|
||||
@@ -160,8 +160,7 @@ async fn connecting_a_local_server_records_where_it_is() {
|
||||
.await
|
||||
.expect("the server answered");
|
||||
|
||||
// Whatever the server reported, in the order the list settles into.
|
||||
assert_eq!(outcome.suggested_model.as_deref(), Some("gemma-4-12b"));
|
||||
assert!(outcome.notes.iter().any(|note| note.contains("2 models available")));
|
||||
assert!(service.store().credential("lmstudio").is_none(), "nothing to store, so nothing is");
|
||||
|
||||
let config: serde_json::Value = serde_json::from_str(
|
||||
@@ -170,6 +169,8 @@ async fn connecting_a_local_server_records_where_it_is() {
|
||||
.unwrap();
|
||||
assert_eq!(config["providers"]["lmstudio"]["base_url"], server.endpoint);
|
||||
assert_eq!(config["default_provider"], "lmstudio");
|
||||
// The model is the reader's to choose: a login that wrote one would be luxe picking favorites
|
||||
assert!(config.get("default_model").is_none(), "no model chosen for them: {config}");
|
||||
// And what it is serving, which no catalog can answer for a machine it has never seen.
|
||||
assert_eq!(
|
||||
config["providers"]["lmstudio"]["served_models"],
|
||||
@@ -344,8 +345,7 @@ async fn a_resource_with_discovery_off_is_never_asked() {
|
||||
assert!(recorded(&models, "foundry-openai").0.is_empty(), "one switch covers the resource");
|
||||
}
|
||||
|
||||
/// Logging in reads the deployments with the key just typed, records them for every surface
|
||||
/// and suggests one that is actually deployed rather than one Azure merely offers.
|
||||
/// Logging in reads the deployments with the key just typed and records them for every surface.
|
||||
#[tokio::test]
|
||||
async fn a_foundry_login_records_the_deployments_it_found() {
|
||||
let server = LocalServer::start(FOUNDRY_LISTING);
|
||||
@@ -360,7 +360,6 @@ async fn a_foundry_login_records_the_deployments_it_found() {
|
||||
.await
|
||||
.expect("configured");
|
||||
|
||||
assert_eq!(outcome.suggested_model.as_deref(), Some("claude-opus-5"));
|
||||
assert!(
|
||||
outcome.notes.iter().any(|note| note.contains("3 chat deployments")),
|
||||
"{:?}",
|
||||
@@ -759,17 +758,6 @@ fn model_lists_are_parsed_from_both_shapes_and_summarized() {
|
||||
assert!(summary.starts_with("10 models available (m0, m1, m2, …"), "got {summary}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_suggested_model_is_one_the_account_can_actually_use() {
|
||||
let openai = provider_descriptor("openai").unwrap();
|
||||
// Preference order wins when it's available.
|
||||
let available = vec!["gpt-4o".to_string(), "gpt-5.4".to_string(), "gpt-5".to_string()];
|
||||
assert_eq!(pick_model(openai, &available).as_deref(), Some("gpt-5.4"));
|
||||
// Otherwise fall back to what the endpoint offered rather than inventing an id.
|
||||
assert_eq!(pick_model(openai, &["local-thing".to_string()]).as_deref(), Some("local-thing"));
|
||||
assert_eq!(pick_model(openai, &[]), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn base_urls_are_normalized_and_nonsense_is_rejected() {
|
||||
assert_eq!(normalize_base_url(" https://x.dev/v1/ ").unwrap(), "https://x.dev/v1");
|
||||
|
||||
@@ -83,7 +83,7 @@ impl RequestAuth {
|
||||
/// Both `x-api-key` and `api-key`, for Foundry's Anthropic passthrough.
|
||||
///
|
||||
/// The endpoint authenticates on `x-api-key` and its own portal samples show `api-key`, so
|
||||
/// Anthropic's `AnthropicFoundry` client sends the pair and so does Luxe. One header would
|
||||
/// Anthropic's `AnthropicFoundry` client sends the pair and so does luxe. One header would
|
||||
/// work today against a 401 that costs a user an evening.
|
||||
pub fn foundry_key(key: &ApiKey) -> Self {
|
||||
let key = remembered(key);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Credential store — `~/.config/luxe/auth.json`, `0600`, and never lossy.
|
||||
//!
|
||||
//! The file is a superset of the one Luxe already read: a few reserved keys keep their
|
||||
//! The file is a superset of the one luxe already read: a few reserved keys keep their
|
||||
//! [`crate::config::ModelsConfig`] meaning, and every *other* top-level key is one provider's
|
||||
//! [`Credential`]. An existing hand-written file keeps working, and a file written by another tool
|
||||
//! that uses the same convention can be dropped in.
|
||||
@@ -34,7 +34,7 @@ impl AuthStore {
|
||||
Self { file: JsonFile::new(path, FileMode::OwnerOnly) }
|
||||
}
|
||||
|
||||
/// The default store: `auth.json` in Luxe's config directory, or where an older build left it.
|
||||
/// The default store: `auth.json` in luxe's config directory, or where an older build left it.
|
||||
pub fn default_path() -> Self {
|
||||
Self::new(luxe_core::user_dirs::luxe_config_file("auth.json"))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Model catalog — what Luxe knows about a model, and where it learned it.
|
||||
//! Model catalog — what luxe knows about a model, and where it learned it.
|
||||
//!
|
||||
//! A model released after the binary was built still has to work properly: the right context
|
||||
//! window, output cap, reasoning levels, and pricing, not silent fallbacks. Metadata therefore
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
//! Id mapping between Luxe's names and models.dev's.
|
||||
//! Id mapping between luxe's names and models.dev's.
|
||||
//!
|
||||
//! Luxe provider names are user-chosen (`lmstudio`, `dashscope`, `openai_compat`) and model ids
|
||||
//! luxe provider names are user-chosen (`lmstudio`, `dashscope`, `openai_compat`) and model ids
|
||||
//! are whatever the endpoint expects, so neither is guaranteed to be a models.dev key. Both
|
||||
//! mappings here affect **metadata lookup only** — the wire id a provider receives is never
|
||||
//! rewritten.
|
||||
|
||||
use crate::config::ProviderConfig;
|
||||
|
||||
/// Luxe provider names that don't match their models.dev id.
|
||||
/// luxe provider names that don't match their models.dev id.
|
||||
///
|
||||
/// Deliberately tiny: almost every name maps verbatim, the provider catalog carries the rest, and a
|
||||
/// user whose provider needs a different id sets `"models_dev"` on it.
|
||||
const ALIASES: &[(&str, &str)] = &[
|
||||
// Luxe's default provider name; an OpenAI-compatible endpoint serving `gpt-*` really is
|
||||
// luxe's default provider name; an OpenAI-compatible endpoint serving `gpt-*` really is
|
||||
// serving OpenAI's models, and a local server's ids simply won't match anything.
|
||||
("openai_compat", "openai"),
|
||||
("dashscope", "alibaba"),
|
||||
];
|
||||
|
||||
/// The models.dev provider id to look a Luxe provider up under.
|
||||
/// The models.dev provider id to look a luxe provider up under.
|
||||
///
|
||||
/// Config wins, then the provider catalog, then the alias table, then the name verbatim. Never
|
||||
/// `None`: a name that matches nothing just finds no models, which is the right answer for a local
|
||||
/// server.
|
||||
///
|
||||
/// The catalog step is what makes a subscription provider work at all: `openai-codex` is a Luxe
|
||||
/// The catalog step is what makes a subscription provider work at all: `openai-codex` is a luxe
|
||||
/// provider, not a models.dev one, and without the mapping its models resolve to no metadata (a
|
||||
/// zero context window, no pricing) and never appear in the picker.
|
||||
pub fn models_dev_provider<'a>(provider: &'a str, config: Option<&'a ProviderConfig>) -> &'a str {
|
||||
|
||||
@@ -33,7 +33,7 @@ pub const DEFAULT_CONTEXT_WINDOW: u32 = 128_000;
|
||||
/// thinking on, it truncated nearly every substantial reply. An older model that refuses this much
|
||||
/// says what it does accept, and the adapter retries with that and remembers it. Everywhere else
|
||||
/// `0` means "omit the field": OpenAI-compatible endpoints treat it as optional, an omitted cap is
|
||||
/// the model's own maximum on every server Luxe targets, and a forced large value trips strict ones.
|
||||
/// the model's own maximum on every server luxe targets, and a forced large value trips strict ones.
|
||||
const ANTHROPIC_FALLBACK_MAX_TOKENS: u32 = 128_000;
|
||||
|
||||
/// Which layer supplied a resolved field.
|
||||
@@ -368,7 +368,7 @@ fn apply_config(info: &mut ModelInfo, from: &mut Provenance, config: &ModelConfi
|
||||
if let Some(values) = &config.input {
|
||||
// Replaces for the same reason the thinking map does: the list is a closed claim about
|
||||
// what this endpoint accepts, so dropping a modality here must not be undone by a catalog
|
||||
// entry that still advertises it. A list Luxe recognizes nothing in falls back to text
|
||||
// entry that still advertises it. A list luxe recognizes nothing in falls back to text
|
||||
// rather than to nothing — no model accepts zero kinds of input, and an empty list would
|
||||
// render as a blank row.
|
||||
info.input = parse_modalities(values.iter().map(String::as_str))
|
||||
@@ -392,7 +392,7 @@ fn apply_config(info: &mut ModelInfo, from: &mut Provenance, config: &ModelConfi
|
||||
}
|
||||
}
|
||||
|
||||
/// Derive Luxe thinking levels from models.dev `reasoning_options` effort values.
|
||||
/// Derive luxe thinking levels from models.dev `reasoning_options` effort values.
|
||||
///
|
||||
/// A declared effort list is a *closed* set when effort is the model's only dial: the levels it
|
||||
/// omits are marked unsupported so the picker grays them out and the wire request clamps to a value
|
||||
@@ -406,7 +406,7 @@ fn thinking_map(dev: &Model) -> HashMap<String, Option<String>> {
|
||||
for value in dev.reasoning_options.iter().flat_map(|option| &option.values) {
|
||||
let entry = match value.as_str() {
|
||||
level @ ("minimal" | "low" | "medium" | "high" | "xhigh") => (level, level),
|
||||
// models.dev's `max` is Luxe's `ultra`.
|
||||
// models.dev's `max` is luxe's `ultra`.
|
||||
"max" | "ultra" => ("ultra", "max"),
|
||||
_ => continue,
|
||||
};
|
||||
@@ -441,13 +441,13 @@ fn thinking_controls(dev: &Model) -> ThinkingControls {
|
||||
controls
|
||||
}
|
||||
|
||||
/// Input modalities Luxe understands, or `None` when the entry declares none it recognizes.
|
||||
/// Input modalities luxe understands, or `None` when the entry declares none it recognizes.
|
||||
fn modalities(dev: &Model) -> Option<Vec<Modality>> {
|
||||
let declared = dev.modalities.as_ref().map(|m| m.input.as_slice()).unwrap_or_default();
|
||||
parse_modalities(declared.iter().map(String::as_str))
|
||||
}
|
||||
|
||||
/// The modalities in `values` that Luxe models, in declared order and deduplicated.
|
||||
/// The modalities in `values` that luxe models, in declared order and deduplicated.
|
||||
///
|
||||
/// Anything else is dropped rather than rejected. A catalog that grows a `pdf` or `audio` input,
|
||||
/// or a hand-written entry with a typo in it, must not take the whole file down with it — the
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use crate::config::{CompatFlags, CostConfig};
|
||||
|
||||
/// The real models.dev entry for Claude Opus 5, trimmed to what Luxe reads.
|
||||
/// The real models.dev entry for Claude Opus 5, trimmed to what luxe reads.
|
||||
const OPUS_5: &str = r#"{"anthropic":{"models":{"claude-opus-5":{
|
||||
"name":"Claude Opus 5","reasoning":true,"tool_call":true,
|
||||
"reasoning_options":[{"type":"effort","values":["low","medium","high","xhigh","max"]}],
|
||||
@@ -525,7 +525,7 @@ fn provider_alias_routes_a_custom_name_to_its_models_dev_id() {
|
||||
|
||||
/// The catalog's own account of which dial a model exposes decides how the Anthropic adapter
|
||||
/// asks for thinking, so it has to survive resolution intact — and an effort-only list is a
|
||||
/// closed set, which is what stops Luxe asking for a level the endpoint never advertised.
|
||||
/// closed set, which is what stops luxe asking for a level the endpoint never advertised.
|
||||
#[test]
|
||||
fn declared_reasoning_dials_survive_resolution() {
|
||||
// Real 2026-07 shapes: Sonnet 5 (effort only), Sonnet 4.5 (a token budget), Opus 4.5 (both).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! models.dev `api.json` schema — the subset Luxe actually uses.
|
||||
//! models.dev `api.json` schema — the subset luxe actually uses.
|
||||
//!
|
||||
//! The wire shape is `{ providerId: { models: { modelId: {…} } } }`. Unknown fields are ignored
|
||||
//! on the way in and omitted on the way out, so the same types parse the live API, the on-disk
|
||||
@@ -33,7 +33,7 @@ pub struct Provider {
|
||||
/// Parse models one at a time, dropping any that don't fit the schema.
|
||||
///
|
||||
/// models.dev is community-maintained and occasionally ships an entry with, say, a `null` inside
|
||||
/// a string array. Strict parsing would turn that into "Luxe knows nothing about any model" —
|
||||
/// a string array. Strict parsing would turn that into "luxe knows nothing about any model" —
|
||||
/// the exact failure this whole module exists to prevent. Losing one entry is a far better trade.
|
||||
fn lenient_models<'de, D: Deserializer<'de>>(
|
||||
deserializer: D,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
use serde_json::{Map, Value};
|
||||
use tracing::warn;
|
||||
|
||||
/// The payload a template with nothing configured gets: Qwen's two flags, which is what Luxe sent
|
||||
/// The payload a template with nothing configured gets: Qwen's two flags, which is what luxe sent
|
||||
/// for every chat-template model before the map existed.
|
||||
fn default_kwargs(enabled: bool) -> Value {
|
||||
serde_json::json!({ "enable_thinking": enabled, "preserve_thinking": true })
|
||||
@@ -40,7 +40,7 @@ pub(crate) fn kwargs(template: &Map<String, Value>, enabled: bool, effort: &str)
|
||||
/// Resolve one configured value, or `None` to leave the key out.
|
||||
///
|
||||
/// Anything that isn't a `$var` reference is a literal and travels verbatim — a template argument
|
||||
/// can be any JSON the template understands, and Luxe has no business inspecting it.
|
||||
/// can be any JSON the template understands, and luxe has no business inspecting it.
|
||||
fn resolve(key: &str, value: &Value, enabled: bool, effort: &str) -> Option<Value> {
|
||||
let Some(reference) = value.as_object().filter(|object| object.contains_key("$var")) else {
|
||||
return Some(value.clone());
|
||||
|
||||
@@ -90,7 +90,7 @@ impl serde::Serialize for ApiKey {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parsed Luxe config — the shared shape of `auth.json` and `models.json`.
|
||||
/// Parsed luxe config — the shared shape of `auth.json` and `models.json`.
|
||||
///
|
||||
/// The documented `auth.json` nests keys under `providers.<name>` and can also set
|
||||
/// `default_provider` / `default_model`; `models.json` adds per-model overrides. Both
|
||||
@@ -152,8 +152,8 @@ pub struct ModelConfig {
|
||||
/// ago. A bump made in-session still holds until the model changes — this is where you start,
|
||||
/// not a ceiling. Say which levels the endpoint *cannot* do with `thinking_level_map` instead.
|
||||
pub thinking: Option<luxe_core::provider::ThinkingLevel>,
|
||||
/// Sampling parameters merged verbatim into the request body, after the fields Luxe sets
|
||||
/// itself — so these keys win. Lets a model carry the samplers Luxe doesn't model (llama.cpp
|
||||
/// Sampling parameters merged verbatim into the request body, after the fields luxe sets
|
||||
/// itself — so these keys win. Lets a model carry the samplers luxe doesn't model (llama.cpp
|
||||
/// `min_p`/`repeat_penalty`, vLLM `top_k`), which is how a published sampling recipe is
|
||||
/// expressed at all. Merges per key over the provider's map. OpenAI-shaped APIs only.
|
||||
#[serde(default)]
|
||||
@@ -208,14 +208,14 @@ pub struct ProviderConfig {
|
||||
/// `anthropic-messages`, or `openai-codex`.
|
||||
///
|
||||
/// The built-in provider catalog normally answers this. Set it for a proxy or private deployment
|
||||
/// Luxe doesn't recognize, or to pin a known provider to a different endpoint than its catalog
|
||||
/// luxe doesn't recognize, or to pin a known provider to a different endpoint than its catalog
|
||||
/// default.
|
||||
pub api: Option<String>,
|
||||
/// How this provider's API key goes on the wire: `bearer`, `x-api-key`, `api-key`, or
|
||||
/// `foundry` (both key headers).
|
||||
///
|
||||
/// Named for the header rather than the vendor, because that is what a 401 shows you. The
|
||||
/// catalog answers it for every provider Luxe knows; set it for a gateway that wants a
|
||||
/// catalog answers it for every provider luxe knows; set it for a gateway that wants a
|
||||
/// different one, or to send a Microsoft Entra ID token as `bearer` against a Foundry endpoint
|
||||
/// that would otherwise get a key header.
|
||||
pub auth: Option<String>,
|
||||
@@ -227,7 +227,7 @@ pub struct ProviderConfig {
|
||||
/// authority, and because it has to survive a launch with the server switched off.
|
||||
///
|
||||
/// An Azure resource is the same story told by a cloud: the catalog lists what Azure offers,
|
||||
/// not what anybody deployed, so Luxe records the resource's deployments here too.
|
||||
/// not what anybody deployed, so luxe records the resource's deployments here too.
|
||||
pub served_models: Option<Vec<String>>,
|
||||
/// Deployment name → the model it runs, for a deployment named something other than its
|
||||
/// model (`"sonnet-prod": "claude-sonnet-5"`).
|
||||
|
||||
@@ -273,7 +273,7 @@ fn an_entry_without_modalities_still_parses() {
|
||||
assert_eq!(config.models["lmstudio/local"].thinking, None, "and no starting level");
|
||||
}
|
||||
|
||||
/// A model's starting reasoning level parses by its Luxe name, and an unknown one fails the
|
||||
/// A model's starting reasoning level parses by its luxe name, and an unknown one fails the
|
||||
/// entry rather than being read as some neighboring level.
|
||||
#[test]
|
||||
fn a_model_can_declare_the_level_a_session_starts_at() {
|
||||
@@ -326,7 +326,7 @@ fn a_model_compat_block_parses_as_the_keys_that_were_written() {
|
||||
}
|
||||
|
||||
/// A published sampling recipe is written as JSON and carried as JSON — no key is modelled,
|
||||
/// because the servers Luxe doesn't model are exactly the reason the field exists.
|
||||
/// because the servers luxe doesn't model are exactly the reason the field exists.
|
||||
#[test]
|
||||
fn sampling_params_parse_as_free_form_json_at_both_layers() {
|
||||
let json = r#"{
|
||||
@@ -363,7 +363,7 @@ fn create_openai_compat_provider() {
|
||||
assert_eq!(provider.name(), "openai_compat");
|
||||
}
|
||||
|
||||
/// A config written for an older Luxe keeps loading: retired flags are simply ignored, and the
|
||||
/// A config written for an older luxe keeps loading: retired flags are simply ignored, and the
|
||||
/// ones that are still real are honored.
|
||||
#[test]
|
||||
fn compat_flags_anthropic() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! the /chat/completions endpoint". Its own `/models` lists each model's `supported_endpoints`, so
|
||||
//! the routing comes from there rather than from a table that rots or a guess at the id: each model
|
||||
//! goes to the richest protocol it takes (Messages, then Responses, then chat completions), and one
|
||||
//! Luxe knows nothing about stays on chat completions. The same list says which `reasoning_effort`
|
||||
//! luxe knows nothing about stays on chat completions. The same list says which `reasoning_effort`
|
||||
//! values each model accepts, which Copilot enforces.
|
||||
//!
|
||||
//! Claude takes chat completions too, but that door costs it two things: Copilot hands its thinking
|
||||
@@ -32,7 +32,7 @@ use crate::auth::{AuthSource, RequestAuth};
|
||||
|
||||
/// How long a fetched list is trusted before it is fetched again.
|
||||
const FRESH_FOR: Duration = Duration::from_secs(60 * 60);
|
||||
/// How soon a model the list does not name may send Luxe back to ask, as it may be new.
|
||||
/// How soon a model the list does not name may send luxe back to ask, as it may be new.
|
||||
const RECHECK_UNKNOWN_AFTER: Duration = Duration::from_secs(5 * 60);
|
||||
/// How long the list may take before a request goes ahead without it.
|
||||
const FETCH_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
@@ -59,7 +59,7 @@ pub enum Route {
|
||||
/// The account's models and the route each takes, as last fetched.
|
||||
#[derive(Debug)]
|
||||
struct Catalog {
|
||||
/// When Luxe last asked, whether or not the answer arrived
|
||||
/// When luxe last asked, whether or not the answer arrived
|
||||
asked: Instant,
|
||||
routes: HashMap<String, Route>,
|
||||
/// The `reasoning_effort` values each model takes, for the models that list any
|
||||
|
||||
@@ -143,7 +143,7 @@ async fn requests_reach_the_endpoint_their_model_takes() {
|
||||
assert_eq!(*chat.asked.lock().unwrap(), ["gemini-3.8-flash"]);
|
||||
assert_eq!(hits.load(Ordering::SeqCst), 1, "the list is fetched once, not per request");
|
||||
|
||||
// a model the list does not name stays on chat, and does not send Luxe straight back to ask
|
||||
// a model the list does not name stays on chat, and does not send luxe straight back to ask
|
||||
send(&copilot, "gpt-4o").await;
|
||||
assert_eq!(chat.asked.lock().unwrap().last().map(String::as_str), Some("gpt-4o"));
|
||||
assert_eq!(hits.load(Ordering::SeqCst), 1);
|
||||
@@ -165,7 +165,7 @@ async fn without_the_list_everything_stays_on_chat() {
|
||||
assert!(recorders.messages.asked.lock().unwrap().is_empty());
|
||||
}
|
||||
|
||||
/// The list is trusted for an hour, and a model it does not name sends Luxe back to ask once it is
|
||||
/// The list is trusted for an hour, and a model it does not name sends luxe back to ask once it is
|
||||
/// five minutes old, since that model may be new.
|
||||
#[test]
|
||||
fn the_list_is_asked_again_when_old_or_silent() {
|
||||
@@ -181,7 +181,7 @@ fn the_list_is_asked_again_when_old_or_silent() {
|
||||
assert!(stale(Some(&known), "new-model", at(5)));
|
||||
}
|
||||
|
||||
/// A list that cannot be had when it is due again leaves the routes Luxe knew in place; an error
|
||||
/// A list that cannot be had when it is due again leaves the routes luxe knew in place; an error
|
||||
/// Copilot answers in JSON is not a list with nothing in it.
|
||||
#[tokio::test]
|
||||
async fn a_failed_refresh_keeps_the_routes_it_had() {
|
||||
@@ -299,7 +299,7 @@ impl AuthSource for Copilot {
|
||||
}
|
||||
}
|
||||
|
||||
/// The effort values a model lists are the only ones Luxe sends it: Copilot refuses any other with
|
||||
/// The effort values a model lists are the only ones luxe sends it: Copilot refuses any other with
|
||||
/// a 400. Values copied from the live list.
|
||||
#[test]
|
||||
fn a_models_reasoning_levels_are_the_ones_copilot_lists() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! One HTTP client for the whole process.
|
||||
//!
|
||||
//! `reqwest::Client` owns a connection pool and a TLS configuration, so building one per request
|
||||
//! throws away keep-alive and pays a fresh handshake every turn. It also stops being free once Luxe
|
||||
//! throws away keep-alive and pays a fresh handshake every turn. It also stops being free once luxe
|
||||
//! registers an adapter per known provider: twenty pools for one active conversation.
|
||||
//!
|
||||
//! Cloning the handle is cheap and shares the pool, which is the intended usage.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! luxe-providers — LLM provider adapters.
|
||||
//!
|
||||
//! Hand-rolled thin adapters for OpenAI-compatible APIs, Anthropic, and Gemini.
|
||||
//! Depends on `luxe-core` for the `Provider` trait. [`catalog`] resolves what Luxe knows
|
||||
//! Depends on `luxe-core` for the `Provider` trait. [`catalog`] resolves what luxe knows
|
||||
//! about a model — layering the embedded models.dev snapshot, the refreshed cache, and the
|
||||
//! user's config — so every entry point runs on the same metadata. [`auth`] owns credentials:
|
||||
//! the curated provider catalog, the `0600` store, the OAuth flows, and the per-request auth the
|
||||
|
||||
@@ -29,7 +29,7 @@ impl OpenaiCompatProvider {
|
||||
let mut messages: Vec<serde_json::Value> = Vec::with_capacity(req.messages.len());
|
||||
// A `tool` message has nowhere to put an image — this schema allows content parts only on
|
||||
// a `user` message — and a `user` message may not be interleaved between two `tool`
|
||||
// messages. Luxe emits consecutive tool messages routinely (refusals, then results, plus a
|
||||
// messages. luxe emits consecutive tool messages routinely (refusals, then results, plus a
|
||||
// synthesized repair), so the pixels are collected across the whole *run* and handed over
|
||||
// once, after every tool message in it.
|
||||
let accepts_images = req.model.input.contains(&luxe_core::provider::Modality::Image);
|
||||
@@ -251,7 +251,7 @@ pub(super) fn request_headers(
|
||||
) -> Vec<(&'static str, &'static str)> {
|
||||
let mut headers = copilot_request_headers(compat, req);
|
||||
if compat.openrouter_headers {
|
||||
headers.extend([("HTTP-Referer", LUXE_HOME), ("X-Title", "Luxe")]);
|
||||
headers.extend([("HTTP-Referer", LUXE_HOME), ("X-Title", "luxe")]);
|
||||
}
|
||||
headers
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ fn attribution_headers_go_only_where_they_were_asked_for() {
|
||||
let req = thinking_request(ModelInfo::default(), ThinkingLevel::Off);
|
||||
let named =
|
||||
request_headers(&CompatFlags { openrouter_headers: true, ..Default::default() }, &req);
|
||||
assert_eq!(named, vec![("HTTP-Referer", LUXE_HOME), ("X-Title", "Luxe")]);
|
||||
assert_eq!(named, vec![("HTTP-Referer", LUXE_HOME), ("X-Title", "luxe")]);
|
||||
assert!(request_headers(&CompatFlags::default(), &req).is_empty());
|
||||
assert!(
|
||||
!request_headers(&CompatFlags { copilot_headers: true, ..Default::default() }, &req)
|
||||
@@ -290,7 +290,7 @@ fn qwen_formats_use_boolean_thinking_after_level_clamping() {
|
||||
assert_eq!(local_high["chat_template_kwargs"]["preserve_thinking"], true);
|
||||
}
|
||||
|
||||
/// A template's thinking vocabulary is the template's, not Luxe's: Qwen3.8 takes a
|
||||
/// A template's thinking vocabulary is the template's, not luxe's: Qwen3.8 takes a
|
||||
/// `reasoning_effort` argument and can be told *not* to preserve thinking, neither of which
|
||||
/// the fixed two-key object could express.
|
||||
#[test]
|
||||
|
||||
@@ -282,7 +282,7 @@ fn a_text_only_model_is_never_sent_the_bytes() {
|
||||
assert_eq!(roles, ["user", "tool"]);
|
||||
}
|
||||
|
||||
/// Luxe commits refusals and results as separate `Role::Tool` messages, and `tool_pairing` can
|
||||
/// luxe commits refusals and results as separate `Role::Tool` messages, and `tool_pairing` can
|
||||
/// synthesize a third. One carrier for the whole run, after all of them — a carrier per message
|
||||
/// would interleave a `user` turn between two `tool` turns and 400 the request.
|
||||
#[test]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! three of the keys a typical one names (`top_k`, `min_p`, `repeat_penalty`) have no field in the
|
||||
//! OpenAI wire schema. Worse, the defaults are not neutral: llama.cpp's `min_p` is `0.05`, so a
|
||||
//! request that simply omits it runs the model off-spec on every turn. So the map is passthrough,
|
||||
//! not a modelled set of options — Luxe carries whatever the server understands and validates none
|
||||
//! not a modelled set of options — luxe carries whatever the server understands and validates none
|
||||
//! of it.
|
||||
//!
|
||||
//! OpenAI-shaped bodies only. Anthropic has no equivalent surface and ignores it.
|
||||
@@ -21,7 +21,7 @@ const RESERVED: [&str; 5] = ["model", "messages", "input", "stream", "tools"];
|
||||
///
|
||||
/// Called after every field the adapter sets itself — `temperature`, the output cap, the thinking
|
||||
/// payload — which is the whole point: a model card's recipe is the final word on how that model
|
||||
/// is sampled, and a key here beats whatever Luxe would otherwise have sent.
|
||||
/// is sampled, and a key here beats whatever luxe would otherwise have sent.
|
||||
pub(crate) fn apply(body: &mut Value, params: &Map<String, Value>) {
|
||||
if params.is_empty() {
|
||||
return;
|
||||
@@ -60,7 +60,7 @@ mod tests {
|
||||
})),
|
||||
);
|
||||
|
||||
assert_eq!(body["temperature"], 1.0, "the recipe outranks what Luxe set");
|
||||
assert_eq!(body["temperature"], 1.0, "the recipe outranks what luxe set");
|
||||
assert_eq!(body["top_k"], 20);
|
||||
assert_eq!(body["min_p"], 0.0);
|
||||
assert_eq!(body["repeat_penalty"], 1.0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Wire log — an opt-in, on-disk record of everything Luxe sends to a model and gets back.
|
||||
//! Wire log — an opt-in, on-disk record of everything luxe sends to a model and gets back.
|
||||
//!
|
||||
//! Set `LUXE_WIRE_LOG=<path>` and every provider call appends JSONL: the exact request body as it
|
||||
//! goes on the wire (after provider-specific shaping — `cache_control` markers, tool schemas,
|
||||
|
||||
Reference in New Issue
Block a user