mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 18:37:46 +08:00
refactor: 移除 Python upstream 依赖,清理全部 legacy/Python 兼容层
- 移除 upstream_base_url 参数及 AETHER_GATEWAY_UPSTREAM 环境变量,gateway 不再需要指向 Python 宿主 - 删除所有 LEGACY_*/PYTHON_* 常量、路由组、header 定义及 sunset/phaseout 机制 - 将 legacy_gateway_bridge 重命名为 internal_gateway,executor 相关命名统一为 execution_runtime - dev.sh 新增 Postgres/Redis 预检查,移除 upstream 相关启动参数和提示 - 新增 ai_public 路由处理器 - 全量适配 handler、test、state、control 等模块的命名和接口变更
This commit is contained in:
@@ -1,4 +1,22 @@
|
||||
use super::*;
|
||||
use super::{
|
||||
admin_billing_optional_bool_filter, admin_billing_optional_epoch_value,
|
||||
admin_billing_optional_filter, admin_billing_pages, admin_billing_parse_page,
|
||||
admin_billing_parse_page_size, admin_billing_validate_safe_expression,
|
||||
build_admin_billing_bad_request_response, build_admin_billing_not_found_response,
|
||||
build_admin_billing_read_only_response, default_admin_billing_true,
|
||||
normalize_admin_billing_optional_text, normalize_admin_billing_required_text,
|
||||
};
|
||||
use crate::gateway::handlers::unix_secs_to_rfc3339;
|
||||
use crate::gateway::{AppState, GatewayError, GatewayPublicRequestContext};
|
||||
use axum::{
|
||||
body::{Body, Bytes},
|
||||
http,
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use sqlx::Row;
|
||||
|
||||
fn default_admin_billing_collector_value_type() -> String {
|
||||
"float".to_string()
|
||||
@@ -258,7 +276,7 @@ WHERE id = $1
|
||||
|
||||
async fn parse_admin_billing_collector_request(
|
||||
state: &AppState,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
existing_id: Option<&str>,
|
||||
) -> Result<crate::gateway::AdminBillingCollectorWriteInput, Response<Body>> {
|
||||
let Some(request_body) = request_body else {
|
||||
@@ -389,7 +407,7 @@ async fn parse_admin_billing_collector_request(
|
||||
|
||||
async fn build_admin_create_dimension_collector_response(
|
||||
state: &AppState,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Response<Body>, GatewayError> {
|
||||
let input = match parse_admin_billing_collector_request(state, request_body, None).await {
|
||||
Ok(value) => value,
|
||||
@@ -414,7 +432,7 @@ async fn build_admin_create_dimension_collector_response(
|
||||
async fn build_admin_update_dimension_collector_response(
|
||||
state: &AppState,
|
||||
request_context: &GatewayPublicRequestContext,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Response<Body>, GatewayError> {
|
||||
let Some(collector_id) = admin_billing_collector_id_from_path(&request_context.request_path)
|
||||
else {
|
||||
@@ -450,7 +468,7 @@ async fn build_admin_update_dimension_collector_response(
|
||||
pub(super) async fn maybe_build_local_admin_billing_collectors_response(
|
||||
state: &AppState,
|
||||
request_context: &GatewayPublicRequestContext,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Option<Response<Body>>, GatewayError> {
|
||||
let Some(decision) = request_context.control_decision.as_ref() else {
|
||||
return Ok(None);
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
use super::*;
|
||||
use super::{
|
||||
build_admin_billing_bad_request_response, build_admin_billing_not_found_response,
|
||||
build_admin_billing_read_only_response, normalize_admin_billing_required_text,
|
||||
};
|
||||
use crate::gateway::{AppState, GatewayError, GatewayPublicRequestContext};
|
||||
use axum::{
|
||||
body::{Body, Bytes},
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
|
||||
fn default_admin_billing_preset_mode() -> String {
|
||||
"merge".to_string()
|
||||
@@ -238,7 +249,7 @@ fn resolve_admin_billing_preset_collectors(
|
||||
}
|
||||
|
||||
fn parse_admin_billing_preset_apply_request(
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<(String, String), Response<Body>> {
|
||||
let Some(request_body) = request_body else {
|
||||
return Err(build_admin_billing_bad_request_response("请求体不能为空"));
|
||||
@@ -266,7 +277,7 @@ fn parse_admin_billing_preset_apply_request(
|
||||
|
||||
async fn build_admin_apply_billing_preset_response(
|
||||
state: &AppState,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Response<Body>, GatewayError> {
|
||||
let (preset, mode) = match parse_admin_billing_preset_apply_request(request_body) {
|
||||
Ok(value) => value,
|
||||
@@ -315,7 +326,7 @@ async fn build_admin_apply_billing_preset_response(
|
||||
pub(super) async fn maybe_build_local_admin_billing_presets_response(
|
||||
state: &AppState,
|
||||
request_context: &GatewayPublicRequestContext,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Option<Response<Body>>, GatewayError> {
|
||||
let Some(decision) = request_context.control_decision.as_ref() else {
|
||||
return Ok(None);
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
use super::*;
|
||||
use super::{
|
||||
admin_billing_optional_bool_filter, admin_billing_optional_epoch_value,
|
||||
admin_billing_optional_filter, admin_billing_pages, admin_billing_parse_page,
|
||||
admin_billing_parse_page_size, admin_billing_validate_safe_expression,
|
||||
build_admin_billing_bad_request_response, build_admin_billing_not_found_response,
|
||||
build_admin_billing_read_only_response, default_admin_billing_json_object,
|
||||
default_admin_billing_true, normalize_admin_billing_optional_text,
|
||||
normalize_admin_billing_required_text,
|
||||
};
|
||||
use crate::gateway::handlers::unix_secs_to_rfc3339;
|
||||
use crate::gateway::{AppState, GatewayError, GatewayPublicRequestContext};
|
||||
use axum::{
|
||||
body::{Body, Bytes},
|
||||
http,
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use sqlx::Row;
|
||||
|
||||
fn default_admin_billing_rule_task_type() -> String {
|
||||
"chat".to_string()
|
||||
@@ -54,7 +73,7 @@ fn admin_billing_rule_id_from_path(request_path: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
fn parse_admin_billing_rule_request(
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<crate::gateway::AdminBillingRuleWriteInput, Response<Body>> {
|
||||
let Some(request_body) = request_body else {
|
||||
return Err(build_admin_billing_bad_request_response("请求体不能为空"));
|
||||
@@ -314,7 +333,7 @@ WHERE id = $1
|
||||
|
||||
async fn build_admin_create_billing_rule_response(
|
||||
state: &AppState,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Response<Body>, GatewayError> {
|
||||
let input = match parse_admin_billing_rule_request(request_body) {
|
||||
Ok(value) => value,
|
||||
@@ -339,7 +358,7 @@ async fn build_admin_create_billing_rule_response(
|
||||
async fn build_admin_update_billing_rule_response(
|
||||
state: &AppState,
|
||||
request_context: &GatewayPublicRequestContext,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Response<Body>, GatewayError> {
|
||||
let Some(rule_id) = admin_billing_rule_id_from_path(&request_context.request_path) else {
|
||||
return Ok(build_admin_billing_bad_request_response("缺少 rule_id"));
|
||||
@@ -367,7 +386,7 @@ async fn build_admin_update_billing_rule_response(
|
||||
pub(super) async fn maybe_build_local_admin_billing_rules_response(
|
||||
state: &AppState,
|
||||
request_context: &GatewayPublicRequestContext,
|
||||
request_body: Option<&axum::body::Bytes>,
|
||||
request_body: Option<&Bytes>,
|
||||
) -> Result<Option<Response<Body>>, GatewayError> {
|
||||
let Some(decision) = request_context.control_decision.as_ref() else {
|
||||
return Ok(None);
|
||||
|
||||
Reference in New Issue
Block a user