i18n: traduzioni it/fr per tutti gli agenti
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use axum::{Json, extract::State, response::IntoResponse};
|
||||
use axum::{Extension, Json, extract::State, response::IntoResponse};
|
||||
use serde::Serialize;
|
||||
|
||||
use skald_core::agents::AgentMeta;
|
||||
@@ -7,9 +7,31 @@ use std::sync::Arc;
|
||||
use skald_core::skald::Skald;
|
||||
|
||||
use super::ApiError;
|
||||
use super::guard::AuthUser;
|
||||
|
||||
pub async fn list(_: State<Arc<Skald>>) -> Result<Json<Vec<AgentMeta>>, ApiError> {
|
||||
let agents = skald_core::agents::discover()?;
|
||||
/// The caller's effective UI locale: their `users.locale` override, else the
|
||||
/// instance default, else English. Used to localize the user-facing agent
|
||||
/// fields before they leave the process.
|
||||
async fn caller_locale(skald: &Skald, user_id: &str) -> String {
|
||||
let user_locale = skald
|
||||
.users()
|
||||
.get(user_id)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.and_then(|u| u.locale);
|
||||
skald_core::i18n::resolve_locale(skald.db(), user_locale.as_deref()).await
|
||||
}
|
||||
|
||||
pub async fn list(
|
||||
State(skald): State<Arc<Skald>>,
|
||||
Extension(auth): Extension<AuthUser>,
|
||||
) -> Result<Json<Vec<AgentMeta>>, ApiError> {
|
||||
let locale = caller_locale(&skald, &auth.user_id).await;
|
||||
let mut agents = skald_core::agents::discover()?;
|
||||
for agent in &mut agents {
|
||||
agent.localize(&locale);
|
||||
}
|
||||
Ok(Json(agents))
|
||||
}
|
||||
|
||||
@@ -22,9 +44,12 @@ pub struct AgentDetail {
|
||||
|
||||
pub async fn get(
|
||||
State(skald): State<Arc<Skald>>,
|
||||
Extension(auth): Extension<AuthUser>,
|
||||
axum::extract::Path(id): axum::extract::Path<String>,
|
||||
) -> Result<Json<AgentDetail>, ApiError> {
|
||||
let meta = skald_core::agents::load_meta(&id)?;
|
||||
let locale = caller_locale(&skald, &auth.user_id).await;
|
||||
let mut meta = skald_core::agents::load_meta(&id)?;
|
||||
meta.localize(&locale);
|
||||
let prompt = skald_core::agents::load_prompt(&id)?;
|
||||
let all = skald.llm_manager().list_models_info().await;
|
||||
let models = sort_models_for_agent(all, meta.scope.as_deref(), meta.strength);
|
||||
|
||||
Reference in New Issue
Block a user