Backend:
- New GET /api/agents/models/catalog endpoint with page/per_page/search
params, excludes deprecated models, returns pricing data via
model→version→pricing join
- ModelWithPricingResponse includes input_price, output_price, currency
- ModelListResponse with pagination metadata (total, page, per_page)
- Batch-fetches default versions + latest pricing to avoid N+1
Frontend:
- RoomSettingsPanel: replace Dialog with inline two-step panel
- Step 1: paginated model browser with search, shows context length,
max output tokens, pricing per 1K tokens, capability/modality badges
- Step 2: selected model info card + AI configuration form
- Removed Dialog import and related unused dependencies
72 lines
2.2 KiB
Rust
72 lines
2.2 KiB
Rust
//! Model management — delegates to agent crate.
|
|
|
|
use crate::AppService;
|
|
use crate::error::AppError;
|
|
use session::Session;
|
|
use uuid::Uuid;
|
|
|
|
pub use agent::model::model_entry::{CreateModelRequest, ModelListResponse, ModelResponse, UpdateModelRequest, ModelWithPricingResponse};
|
|
|
|
impl AppService {
|
|
pub async fn agent_model_list(
|
|
&self,
|
|
provider_id: Option<Uuid>,
|
|
_ctx: &Session,
|
|
) -> Result<Vec<agent::model::model_entry::ModelResponse>, AppError> {
|
|
Ok(agent::model::model_entry::list_models(&self.db, provider_id).await?)
|
|
}
|
|
|
|
pub async fn agent_model_list_with_pricing(
|
|
&self,
|
|
provider_id: Option<Uuid>,
|
|
search: Option<String>,
|
|
page: u64,
|
|
per_page: u64,
|
|
_ctx: &Session,
|
|
) -> Result<agent::model::model_entry::ModelListResponse, AppError> {
|
|
Ok(agent::model::model_entry::list_models_with_pricing(
|
|
&self.db,
|
|
provider_id,
|
|
search.as_deref(),
|
|
page,
|
|
per_page,
|
|
).await?)
|
|
}
|
|
|
|
pub async fn agent_model_get(
|
|
&self,
|
|
id: Uuid,
|
|
_ctx: &Session,
|
|
) -> Result<agent::model::model_entry::ModelResponse, AppError> {
|
|
Ok(agent::model::model_entry::get_model(&self.db, id).await?)
|
|
}
|
|
|
|
pub async fn agent_model_create(
|
|
&self,
|
|
request: agent::model::model_entry::CreateModelRequest,
|
|
ctx: &Session,
|
|
) -> Result<agent::model::model_entry::ModelResponse, AppError> {
|
|
super::provider::require_system_caller(ctx)?;
|
|
Ok(agent::model::model_entry::create_model(&self.db, request).await?)
|
|
}
|
|
|
|
pub async fn agent_model_update(
|
|
&self,
|
|
id: Uuid,
|
|
request: agent::model::model_entry::UpdateModelRequest,
|
|
ctx: &Session,
|
|
) -> Result<agent::model::model_entry::ModelResponse, AppError> {
|
|
super::provider::require_system_caller(ctx)?;
|
|
Ok(agent::model::model_entry::update_model(&self.db, id, request).await?)
|
|
}
|
|
|
|
pub async fn agent_model_delete(
|
|
&self,
|
|
id: Uuid,
|
|
ctx: &Session,
|
|
) -> Result<(), AppError> {
|
|
super::provider::require_system_caller(ctx)?;
|
|
Ok(agent::model::model_entry::delete_model(&self.db, id).await?)
|
|
}
|
|
}
|