feat(ai): curated OpenRouter model picker for hybrid backend
Add OPENROUTER_ALLOWED_MODELS env var and GET /insights/openrouter/models endpoint returning the curated list verbatim. Drop the live capability precheck in hybrid mode — trust the operator's allowlist; bad ids surface as a chat-call error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -445,6 +445,34 @@ pub async fn get_available_models_handler(
|
||||
HttpResponse::Ok().json(response)
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct OpenRouterModelsResponse {
|
||||
pub models: Vec<String>,
|
||||
pub default_model: Option<String>,
|
||||
pub configured: bool,
|
||||
}
|
||||
|
||||
/// GET /insights/openrouter/models - Curated OpenRouter model ids exposed
|
||||
/// to clients for the hybrid backend. Returned verbatim from
|
||||
/// `OPENROUTER_ALLOWED_MODELS`; no live call to OpenRouter.
|
||||
#[get("/insights/openrouter/models")]
|
||||
pub async fn get_openrouter_models_handler(
|
||||
_claims: Claims,
|
||||
app_state: web::Data<crate::state::AppState>,
|
||||
) -> impl Responder {
|
||||
let configured = app_state.openrouter.is_some();
|
||||
let default_model = app_state
|
||||
.openrouter
|
||||
.as_ref()
|
||||
.map(|c| c.primary_model.clone());
|
||||
let response = OpenRouterModelsResponse {
|
||||
models: app_state.openrouter_allowed_models.clone(),
|
||||
default_model,
|
||||
configured,
|
||||
};
|
||||
HttpResponse::Ok().json(response)
|
||||
}
|
||||
|
||||
/// POST /insights/rate - Rate an insight (thumbs up/down for training data)
|
||||
#[post("/insights/rate")]
|
||||
pub async fn rate_insight_handler(
|
||||
|
||||
Reference in New Issue
Block a user