43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use crate::{DateTimeUtc, ModelId, ModelProviderId};
|
|
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use super::{ModelCapability, ModelModality, ModelStatus};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "ai_model")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: ModelId,
|
|
pub provider_id: ModelProviderId,
|
|
pub name: String,
|
|
pub modality: String,
|
|
pub capability: String,
|
|
pub context_length: i64,
|
|
pub max_output_tokens: Option<i64>,
|
|
pub training_cutoff: Option<DateTimeUtc>,
|
|
pub is_open_source: bool,
|
|
pub status: String,
|
|
pub created_at: DateTimeUtc,
|
|
pub updated_at: DateTimeUtc,
|
|
}
|
|
|
|
impl Model {
|
|
pub fn modality_enum(&self) -> Result<ModelModality, &'static str> {
|
|
self.modality.parse()
|
|
}
|
|
|
|
pub fn capability_enum(&self) -> Result<ModelCapability, &'static str> {
|
|
self.capability.parse()
|
|
}
|
|
|
|
pub fn status_enum(&self) -> Result<ModelStatus, &'static str> {
|
|
self.status.parse()
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|