mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
refactor: 大规模模块拆分与代码精简,新增 ai-pipeline/data-contracts 独立 crate
- 新增 aether-ai-pipeline 和 aether-data-contracts crate,将 pipeline 逻辑与数据契约从 gateway 中解耦 - 重构 admin handlers:拆分单体模块为 auth/billing/endpoint/features/model/observability/provider/system 等独立子模块 - 合并 chat/cli 重复代码路径:精简 conversion、finalize、planner 中的 sync/chat/cli 分支 - 重构 scheduler/executor/data 层,引入 facade 模式降低模块间耦合 - 移除冗余的 intent 模块,将 plan_fallback/policy/stream_path/sync_path 迁移至 executor - 前端适配:调整 admin API 调用和 provider 模型测试对话框
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use aether_data_contracts::repository::candidates::RequestCandidateRepository;
|
||||
use aether_data_contracts::repository::quota::ProviderQuotaRepository;
|
||||
use aether_data_contracts::repository::usage::UsageRepository;
|
||||
|
||||
use super::{
|
||||
AnnouncementReadRepository, AnnouncementWriteRepository, AuthApiKeyReadRepository,
|
||||
AuthApiKeyWriteRepository, AuthModuleReadRepository, AuthModuleWriteRepository,
|
||||
@@ -85,7 +89,7 @@ impl GatewayDataState {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_request_candidate_repository_for_tests<T>(repository: Arc<T>) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
{
|
||||
let request_candidate_reader: Arc<dyn RequestCandidateReadRepository> = repository.clone();
|
||||
let request_candidate_writer: Arc<dyn RequestCandidateWriteRepository> = repository;
|
||||
@@ -385,7 +389,7 @@ impl GatewayDataState {
|
||||
provider_quota_repository: Arc<T>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
{
|
||||
let provider_quota_reader: Arc<dyn ProviderQuotaReadRepository> =
|
||||
provider_quota_repository.clone();
|
||||
@@ -441,7 +445,7 @@ impl GatewayDataState {
|
||||
provider_quota_repository: Arc<T>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
U: ProviderCatalogReadRepository + ProviderCatalogWriteRepository + 'static,
|
||||
V: GlobalModelReadRepository + GlobalModelWriteRepository + 'static,
|
||||
{
|
||||
@@ -600,8 +604,8 @@ impl GatewayDataState {
|
||||
usage_repository: Arc<U>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
U: aether_data::repository::usage::UsageRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
U: UsageRepository + 'static,
|
||||
{
|
||||
let request_candidate_reader: Arc<dyn RequestCandidateReadRepository> =
|
||||
request_candidate_repository.clone();
|
||||
@@ -659,7 +663,7 @@ impl GatewayDataState {
|
||||
gemini_file_mapping_repository: Arc<U>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
U: aether_data::repository::gemini_file_mappings::GeminiFileMappingRepository + 'static,
|
||||
{
|
||||
let request_candidate_reader: Arc<dyn RequestCandidateReadRepository> =
|
||||
@@ -879,7 +883,7 @@ impl GatewayDataState {
|
||||
usage_repository: Arc<TUsage>,
|
||||
) -> Self
|
||||
where
|
||||
TUsage: aether_data::repository::usage::UsageRepository + 'static,
|
||||
TUsage: UsageRepository + 'static,
|
||||
TWallet: aether_data::repository::wallet::WalletRepository + 'static,
|
||||
{
|
||||
let wallet_reader: Arc<dyn WalletReadRepository> = wallet_repository.clone();
|
||||
@@ -1842,7 +1846,7 @@ impl GatewayDataState {
|
||||
provider_quota_repository: Arc<T>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
{
|
||||
let provider_quota_reader: Arc<dyn ProviderQuotaReadRepository> =
|
||||
provider_quota_repository.clone();
|
||||
@@ -1899,7 +1903,7 @@ impl GatewayDataState {
|
||||
request_candidate_repository: Arc<dyn RequestCandidateReadRepository>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
{
|
||||
let provider_quota_reader: Arc<dyn ProviderQuotaReadRepository> =
|
||||
provider_quota_repository.clone();
|
||||
@@ -1959,7 +1963,7 @@ impl GatewayDataState {
|
||||
request_candidate_repository: Arc<dyn RequestCandidateReadRepository>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
{
|
||||
let provider_quota_reader: Arc<dyn ProviderQuotaReadRepository> =
|
||||
provider_quota_repository.clone();
|
||||
@@ -2021,7 +2025,7 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
U: ProviderCatalogReadRepository + ProviderCatalogWriteRepository + 'static,
|
||||
{
|
||||
let request_candidate_reader: Arc<dyn RequestCandidateReadRepository> =
|
||||
@@ -2089,7 +2093,7 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
U: ProviderCatalogReadRepository + ProviderCatalogWriteRepository + 'static,
|
||||
V: aether_data::repository::shadow_results::ShadowResultRepository + 'static,
|
||||
{
|
||||
@@ -2162,9 +2166,9 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
U: ProviderCatalogReadRepository + ProviderCatalogWriteRepository + 'static,
|
||||
V: aether_data::repository::usage::UsageRepository + 'static,
|
||||
V: UsageRepository + 'static,
|
||||
{
|
||||
let request_candidate_reader: Arc<dyn RequestCandidateReadRepository> =
|
||||
request_candidate_repository.clone();
|
||||
@@ -2236,9 +2240,9 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: RequestCandidateRepository + 'static,
|
||||
U: ProviderCatalogReadRepository + ProviderCatalogWriteRepository + 'static,
|
||||
V: aether_data::repository::usage::UsageRepository + 'static,
|
||||
V: UsageRepository + 'static,
|
||||
W: aether_data::repository::wallet::WalletRepository + 'static,
|
||||
{
|
||||
let request_candidate_reader: Arc<dyn RequestCandidateReadRepository> =
|
||||
@@ -2307,7 +2311,7 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
{
|
||||
let provider_quota_reader: Arc<dyn ProviderQuotaReadRepository> =
|
||||
provider_quota_repository.clone();
|
||||
@@ -2360,7 +2364,7 @@ impl GatewayDataState {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_usage_repository_for_tests<T>(repository: Arc<T>) -> Self
|
||||
where
|
||||
T: aether_data::repository::usage::UsageRepository + 'static,
|
||||
T: UsageRepository + 'static,
|
||||
{
|
||||
let usage_reader: Arc<dyn UsageReadRepository> = repository.clone();
|
||||
let usage_writer: Arc<dyn UsageWriteRepository> = repository;
|
||||
@@ -2516,7 +2520,7 @@ impl GatewayDataState {
|
||||
) -> Self
|
||||
where
|
||||
TWallet: aether_data::repository::wallet::WalletRepository + 'static,
|
||||
TUsage: aether_data::repository::usage::UsageRepository + 'static,
|
||||
TUsage: UsageRepository + 'static,
|
||||
{
|
||||
let wallet_reader: Arc<dyn WalletReadRepository> = wallet_repository.clone();
|
||||
let wallet_writer: Arc<dyn WalletWriteRepository> = wallet_repository;
|
||||
@@ -2572,7 +2576,7 @@ impl GatewayDataState {
|
||||
wallet_repository: Arc<TWallet>,
|
||||
) -> Self
|
||||
where
|
||||
TUsage: aether_data::repository::usage::UsageRepository + 'static,
|
||||
TUsage: UsageRepository + 'static,
|
||||
TWallet: aether_data::repository::wallet::WalletRepository + 'static,
|
||||
{
|
||||
let usage_reader: Arc<dyn UsageReadRepository> = usage_repository.clone();
|
||||
@@ -2626,7 +2630,7 @@ impl GatewayDataState {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_provider_quota_repository_for_tests<T>(repository: Arc<T>) -> Self
|
||||
where
|
||||
T: aether_data::repository::quota::ProviderQuotaRepository + 'static,
|
||||
T: ProviderQuotaRepository + 'static,
|
||||
{
|
||||
let provider_quota_reader: Arc<dyn ProviderQuotaReadRepository> = repository.clone();
|
||||
let provider_quota_writer: Arc<dyn ProviderQuotaWriteRepository> = repository;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use aether_data_contracts::repository::candidates::RequestCandidateRepository;
|
||||
use aether_data_contracts::repository::video_tasks::VideoTaskRepository;
|
||||
|
||||
use super::{
|
||||
AuthApiKeyReadRepository, GatewayDataConfig, GatewayDataState, ProviderCatalogReadRepository,
|
||||
RequestCandidateReadRepository, RequestCandidateWriteRepository, VideoTaskReadRepository,
|
||||
@@ -59,7 +62,7 @@ impl GatewayDataState {
|
||||
repository: Arc<T>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::video_tasks::VideoTaskRepository + 'static,
|
||||
T: VideoTaskRepository + 'static,
|
||||
{
|
||||
let video_task_reader: Arc<dyn VideoTaskReadRepository> = repository.clone();
|
||||
let video_task_writer: Arc<dyn VideoTaskWriteRepository> = repository;
|
||||
@@ -110,7 +113,7 @@ impl GatewayDataState {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_video_task_repository_for_tests<T>(repository: Arc<T>) -> Self
|
||||
where
|
||||
T: aether_data::repository::video_tasks::VideoTaskRepository + 'static,
|
||||
T: VideoTaskRepository + 'static,
|
||||
{
|
||||
let video_task_reader: Arc<dyn VideoTaskReadRepository> = repository.clone();
|
||||
let video_task_writer: Arc<dyn VideoTaskWriteRepository> = repository;
|
||||
@@ -165,7 +168,7 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::video_tasks::VideoTaskRepository + 'static,
|
||||
T: VideoTaskRepository + 'static,
|
||||
{
|
||||
let video_task_reader: Arc<dyn VideoTaskReadRepository> = repository.clone();
|
||||
let video_task_writer: Arc<dyn VideoTaskWriteRepository> = repository;
|
||||
@@ -219,8 +222,8 @@ impl GatewayDataState {
|
||||
request_candidate_repository: Arc<U>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::video_tasks::VideoTaskRepository + 'static,
|
||||
U: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
T: VideoTaskRepository + 'static,
|
||||
U: RequestCandidateRepository + 'static,
|
||||
{
|
||||
let video_task_reader: Arc<dyn VideoTaskReadRepository> = repository.clone();
|
||||
let video_task_writer: Arc<dyn VideoTaskWriteRepository> = repository;
|
||||
@@ -284,9 +287,9 @@ impl GatewayDataState {
|
||||
encryption_key: impl Into<String>,
|
||||
) -> Self
|
||||
where
|
||||
T: aether_data::repository::video_tasks::VideoTaskRepository + 'static,
|
||||
T: VideoTaskRepository + 'static,
|
||||
U: ProviderCatalogReadRepository + 'static,
|
||||
V: aether_data::repository::candidates::RequestCandidateRepository + 'static,
|
||||
V: RequestCandidateRepository + 'static,
|
||||
{
|
||||
let video_task_reader: Arc<dyn VideoTaskReadRepository> = repository.clone();
|
||||
let video_task_writer: Arc<dyn VideoTaskWriteRepository> = repository;
|
||||
|
||||
Reference in New Issue
Block a user