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, ModelWithPricingResponse,
|
|
UpdateModelRequest,
|
|
};
|
|
|
|
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?)
|
|
}
|
|
}
|