catalog composite

This commit is contained in:
jaberjaber23
2026-03-05 20:31:49 +03:00
parent 9fc0fe71bf
commit c6b46ccbe1
3 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ members = [
]
[workspace.package]
version = "0.3.21"
version = "0.3.22"
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/RightNow-AI/openfang"
+2 -2
View File
@@ -2241,7 +2241,7 @@ pub async fn whatsapp_qr_start() -> impl IntoResponse {
return Json(serde_json::json!({
"available": false,
"message": "WhatsApp Web gateway not running. Start the gateway or use Business API mode.",
"help": "Run: npx openfang-whatsapp-gateway (or set WHATSAPP_WEB_GATEWAY_URL)"
"help": "The WhatsApp Web gateway auto-starts with the daemon when configured. Ensure Node.js >= 18 is installed and WhatsApp is configured in config.toml. Set WHATSAPP_WEB_GATEWAY_URL to use an external gateway."
}));
}
@@ -5360,7 +5360,7 @@ pub async fn add_custom_model(
if !catalog.add_custom_model(entry) {
return (
StatusCode::CONFLICT,
Json(serde_json::json!({"error": format!("Model '{}' already exists", id)})),
Json(serde_json::json!({"error": format!("Model '{}' already exists for provider '{}'", id, provider)})),
);
}
+9 -4
View File
@@ -253,11 +253,16 @@ impl ModelCatalog {
/// Add a custom model at runtime.
///
/// Returns `true` if the model was added, `false` if a model with that ID
/// already exists (case-insensitive).
/// Returns `true` if the model was added, `false` if a model with the same
/// ID **and** provider already exists (case-insensitive).
pub fn add_custom_model(&mut self, entry: ModelCatalogEntry) -> bool {
let lower = entry.id.to_lowercase();
if self.models.iter().any(|m| m.id.to_lowercase() == lower) {
let lower_id = entry.id.to_lowercase();
let lower_provider = entry.provider.to_lowercase();
if self
.models
.iter()
.any(|m| m.id.to_lowercase() == lower_id && m.provider.to_lowercase() == lower_provider)
{
return false;
}
let provider = entry.provider.clone();