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 pub max_requests_per_minute: i64,
14 pub max_tokens_per_minute: i64,
15 pub max_input_tokens_per_minute: i64,
16 pub max_output_tokens_per_minute: i64,
17 pub max_tokens_per_day: i64,
18 pub price_per_million_input_tokens: i32,
19 pub price_per_million_cache_creation_input_tokens: i32,
20 pub price_per_million_cache_read_input_tokens: i32,
21 pub price_per_million_output_tokens: i32,
22}
23
24#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
25pub enum Relation {
26 #[sea_orm(
27 belongs_to = "super::provider::Entity",
28 from = "Column::ProviderId",
29 to = "super::provider::Column::Id"
30 )]
31 Provider,
32 #[sea_orm(has_many = "super::usage::Entity")]
33 Usages,
34}
35
36impl Related<super::provider::Entity> for Entity {
37 fn to() -> RelationDef {
38 Relation::Provider.def()
39 }
40}
41
42impl Related<super::usage::Entity> for Entity {
43 fn to() -> RelationDef {
44 Relation::Usages.def()
45 }
46}
47
48impl ActiveModelBehavior for ActiveModel {}