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 #[sea_orm(has_many = "super::billing_event::Entity")]
35 BillingEvents,
36}
37
38impl Related<super::provider::Entity> for Entity {
39 fn to() -> RelationDef {
40 Relation::Provider.def()
41 }
42}
43
44impl Related<super::usage::Entity> for Entity {
45 fn to() -> RelationDef {
46 Relation::Usages.def()
47 }
48}
49
50impl Related<super::billing_event::Entity> for Entity {
51 fn to() -> RelationDef {
52 Relation::BillingEvents.def()
53 }
54}
55
56impl ActiveModelBehavior for ActiveModel {}