
Tokens per day may exceed the range of Postgres's 32-bit `integer` data type. Release Notes: - N/A Co-authored-by: Marshall <marshall@zed.dev>
42 lines
1,005 B
Rust
42 lines
1,005 B
Rust
use sea_orm::entity::prelude::*;
|
|
|
|
use crate::llm::db::{ModelId, ProviderId};
|
|
|
|
/// An LLM model.
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "models")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: ModelId,
|
|
pub provider_id: ProviderId,
|
|
pub name: String,
|
|
pub max_requests_per_minute: i64,
|
|
pub max_tokens_per_minute: i64,
|
|
pub max_tokens_per_day: i64,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::provider::Entity",
|
|
from = "Column::ProviderId",
|
|
to = "super::provider::Column::Id"
|
|
)]
|
|
Provider,
|
|
#[sea_orm(has_many = "super::usage::Entity")]
|
|
Usages,
|
|
}
|
|
|
|
impl Related<super::provider::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Provider.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::usage::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Usages.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|