feat(settings): add model provider management with full CRUD support
Add a new settings page for managing API model providers (name, API URL, API key, applicable agent types). Includes database migration, SeaORM entity, backend CRUD commands/handlers, frontend settings UI with agent type filter, add/edit/delete dialogs, and i18n support for all 10 locales. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(ModelProvider::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(ModelProvider::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(ModelProvider::Name).string().not_null())
|
||||
.col(ColumnDef::new(ModelProvider::ApiUrl).text().not_null())
|
||||
.col(ColumnDef::new(ModelProvider::ApiKey).text().not_null())
|
||||
.col(
|
||||
ColumnDef::new(ModelProvider::AgentTypesJson)
|
||||
.text()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(ModelProvider::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(ModelProvider::UpdatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(ModelProvider::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum ModelProvider {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
ApiUrl,
|
||||
ApiKey,
|
||||
AgentTypesJson,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
@@ -7,6 +7,7 @@ mod m20260226_000001_agent_setting;
|
||||
mod m20260227_000001_folder_parent_branch;
|
||||
mod m20260330_000001_chat_channel;
|
||||
mod m20260401_000001_chat_channel_sender_context;
|
||||
mod m20260404_000001_model_provider;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -20,6 +21,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260227_000001_folder_parent_branch::Migration),
|
||||
Box::new(m20260330_000001_chat_channel::Migration),
|
||||
Box::new(m20260401_000001_chat_channel_sender_context::Migration),
|
||||
Box::new(m20260404_000001_model_provider::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user