model.rs

 1use sea_orm::entity::prelude::*;
 2
 3use crate::llm::db::{ModelId, ProviderId};
 4
 5/// An LLM model.
 6#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
 7#[sea_orm(table_name = "models")]
 8pub struct Model {
 9    #[sea_orm(primary_key)]
10    pub id: ModelId,
11    pub provider_id: ProviderId,
12    pub name: String,
13}
14
15#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
16pub enum Relation {
17    #[sea_orm(
18        belongs_to = "super::provider::Entity",
19        from = "Column::ProviderId",
20        to = "super::provider::Column::Id"
21    )]
22    Provider,
23    #[sea_orm(has_many = "super::usage::Entity")]
24    Usages,
25}
26
27impl Related<super::provider::Entity> for Entity {
28    fn to() -> RelationDef {
29        Relation::Provider.def()
30    }
31}
32
33impl Related<super::usage::Entity> for Entity {
34    fn to() -> RelationDef {
35        Relation::Usages.def()
36    }
37}
38
39impl ActiveModelBehavior for ActiveModel {}