mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-21 16:01:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba8745a714 | ||
|
|
84bcd0e1c0 | ||
|
|
7459c16a3a | ||
|
|
3b4fb390c7 | ||
|
|
bb440a3cbb | ||
|
|
89b6d2256f |
@@ -158,7 +158,7 @@ impl OtherRequestOutcome {
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
|
||||
pub struct UsageFilter {
|
||||
pub client_api_key_name: Option<String>,
|
||||
pub provider_account_name: Option<String>,
|
||||
pub provider_account_search: Option<String>,
|
||||
pub client_api_key_ref: Option<String>,
|
||||
pub request_id: Option<String>,
|
||||
pub provider_account_ref: Option<String>,
|
||||
|
||||
@@ -32,7 +32,7 @@ impl DashboardQuery {
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct UsageQuery {
|
||||
pub client_api_key_name: Option<String>,
|
||||
pub account_name: Option<String>,
|
||||
pub account_search: Option<String>,
|
||||
pub status: Option<String>,
|
||||
pub current_page: Option<u32>,
|
||||
pub page_size: Option<u16>,
|
||||
@@ -339,7 +339,7 @@ pub(crate) fn dashboard_today_range(
|
||||
pub(crate) fn usage_filter(query: &UsageQuery) -> domain::UsageFilter {
|
||||
domain::UsageFilter {
|
||||
client_api_key_name: non_empty(query.client_api_key_name.clone()),
|
||||
provider_account_name: non_empty(query.account_name.clone()),
|
||||
provider_account_search: non_empty(query.account_search.clone()),
|
||||
provider_kind: non_empty(query.provider.clone()),
|
||||
model_contains: non_empty(query.model.clone()),
|
||||
..Default::default()
|
||||
|
||||
@@ -917,7 +917,7 @@ pub(super) fn usage_record_with_account(
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn usage_route_should_forward_name_and_model_contains_filters() {
|
||||
async fn usage_route_should_forward_record_text_filters() {
|
||||
use axum::{
|
||||
body::Body,
|
||||
http::{Request, StatusCode, header},
|
||||
@@ -933,7 +933,7 @@ async fn usage_route_should_forward_name_and_model_contains_filters() {
|
||||
.with_state(fixture.state())
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.uri("/api/admin/usage/records?model=%20coding%20&clientApiKeyName=%20Key%20%25%20&accountName=%20Account%20Name%20")
|
||||
.uri("/api/admin/usage/records?model=%20coding%20&clientApiKeyName=%20Key%20%25%20&accountSearch=%20alice%40%20")
|
||||
.header(header::COOKIE, "cpr_session=valid-session")
|
||||
.header("x-request-id", "req_usage_other_outcome")
|
||||
.body(Body::empty())
|
||||
@@ -947,10 +947,7 @@ async fn usage_route_should_forward_name_and_model_contains_filters() {
|
||||
let filter = &observations.records.last().expect("usage query").filter;
|
||||
assert_eq!(filter.client_api_key_name.as_deref(), Some("Key %"));
|
||||
assert_eq!(filter.model_contains.as_deref(), Some("coding"));
|
||||
assert_eq!(
|
||||
filter.provider_account_name.as_deref(),
|
||||
Some("Account Name")
|
||||
);
|
||||
assert_eq!(filter.provider_account_search.as_deref(), Some("alice@"));
|
||||
assert!(filter.client_api_key_ref.is_none());
|
||||
assert!(filter.provider_account_ref.is_none());
|
||||
}
|
||||
|
||||
@@ -36,10 +36,8 @@ impl AnalyticsSnapshot<'_> {
|
||||
|| filter.attempt_index.is_some()
|
||||
|| filter.status_code.is_some()
|
||||
|| filter.outcome.is_some()
|
||||
|| filter.search.is_some()
|
||||
|| filter.model_contains.is_some()
|
||||
|| filter.client_api_key_name.is_some()
|
||||
|| filter.provider_account_name.is_some()
|
||||
|| filter.needs_observation_text()
|
||||
|| matches!(
|
||||
dimension,
|
||||
Some(DiagnosticDimension::Failure | DiagnosticDimension::Status)
|
||||
|
||||
@@ -1232,10 +1232,8 @@ pub(super) fn collection_for(
|
||||
|| filter.attempt_index.is_some()
|
||||
|| filter.response_id.is_some()
|
||||
|| filter.upstream_request_id.is_some()
|
||||
|| filter.search.is_some()
|
||||
|| filter.model_contains.is_some()
|
||||
|| filter.client_api_key_name.is_some()
|
||||
|| filter.provider_account_name.is_some()
|
||||
|| filter.needs_observation_text()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
@@ -1286,21 +1284,15 @@ pub(crate) fn push_analytics_filter(
|
||||
alias: &str,
|
||||
) {
|
||||
let mut typed = filter.clone();
|
||||
typed.search = None;
|
||||
typed.client_api_key_name = None;
|
||||
typed.provider_account_name = None;
|
||||
let text = UsageRecordFilter {
|
||||
client_api_key_name: typed.client_api_key_name.take(),
|
||||
provider_account_search: typed.provider_account_search.take(),
|
||||
search: typed.search.take(),
|
||||
..Default::default()
|
||||
};
|
||||
push_usage_filter(query, &typed, alias);
|
||||
if filter.search.is_some()
|
||||
|| filter.client_api_key_name.is_some()
|
||||
|| filter.provider_account_name.is_some()
|
||||
{
|
||||
if text.needs_observation_text() {
|
||||
query.push(format!(" and exists(select 1 from model_request_observations searched where searched.id={alias}.id"));
|
||||
let text = UsageRecordFilter {
|
||||
client_api_key_name: filter.client_api_key_name.clone(),
|
||||
provider_account_name: filter.provider_account_name.clone(),
|
||||
search: filter.search.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
push_usage_filter(query, &text, "searched");
|
||||
query.push(")");
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub(crate) fn store_usage_filter(filter: admin_observability::UsageFilter) -> Us
|
||||
UsageRecordFilter {
|
||||
model_contains: filter.model_contains,
|
||||
client_api_key_name: filter.client_api_key_name,
|
||||
provider_account_name: filter.provider_account_name,
|
||||
provider_account_search: filter.provider_account_search,
|
||||
client_api_key_ref: filter.client_api_key_ref,
|
||||
request_id: filter.request_id,
|
||||
provider_account_ref: filter.provider_account_ref,
|
||||
|
||||
@@ -40,7 +40,7 @@ pub(crate) fn observability_page_offset(
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct UsageRecordFilter {
|
||||
pub client_api_key_name: Option<String>,
|
||||
pub provider_account_name: Option<String>,
|
||||
pub provider_account_search: Option<String>,
|
||||
pub client_api_key_ref: Option<String>,
|
||||
pub request_id: Option<String>,
|
||||
pub provider_account_ref: Option<String>,
|
||||
@@ -58,6 +58,12 @@ pub struct UsageRecordFilter {
|
||||
}
|
||||
|
||||
impl UsageRecordFilter {
|
||||
pub(super) fn needs_observation_text(&self) -> bool {
|
||||
self.search.is_some()
|
||||
|| self.client_api_key_name.is_some()
|
||||
|| self.provider_account_search.is_some()
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> StoreResult<()> {
|
||||
for (value, field) in [
|
||||
(
|
||||
@@ -65,8 +71,8 @@ impl UsageRecordFilter {
|
||||
"client API key name filter",
|
||||
),
|
||||
(
|
||||
self.provider_account_name.as_deref(),
|
||||
"provider account name filter",
|
||||
self.provider_account_search.as_deref(),
|
||||
"provider account search filter",
|
||||
),
|
||||
(self.client_api_key_ref.as_deref(), "client API key filter"),
|
||||
(self.request_id.as_deref(), "request ID filter"),
|
||||
|
||||
@@ -11,18 +11,10 @@ pub(crate) fn push_usage_filter(
|
||||
filter: &UsageRecordFilter,
|
||||
alias: &str,
|
||||
) {
|
||||
for (column, value) in [
|
||||
("client_api_key_name_snapshot", &filter.client_api_key_name),
|
||||
(
|
||||
"provider_account_name_snapshot",
|
||||
&filter.provider_account_name,
|
||||
),
|
||||
] {
|
||||
if let Some(value) = value {
|
||||
query.push(format!(" and {alias}.{column} like "));
|
||||
query.push_bind(literal_contains_pattern(value));
|
||||
query.push(" escape '\\'");
|
||||
}
|
||||
if let Some(value) = &filter.client_api_key_name {
|
||||
query.push(format!(" and {alias}.client_api_key_name_snapshot like "));
|
||||
query.push_bind(literal_contains_pattern(value));
|
||||
query.push(" escape '\\'");
|
||||
}
|
||||
if let Some(value) = &filter.client_api_key_ref {
|
||||
query.push(format!(" and {alias}.client_api_key_ref = "));
|
||||
@@ -51,11 +43,23 @@ pub(crate) fn push_usage_filter(
|
||||
query.push_bind(value.clone());
|
||||
query.push(")");
|
||||
}
|
||||
if let Some(value) = &filter.model_contains {
|
||||
for (value, first, second) in [
|
||||
(
|
||||
&filter.provider_account_search,
|
||||
"provider_account_name_snapshot",
|
||||
"provider_account_email_snapshot",
|
||||
),
|
||||
(
|
||||
&filter.model_contains,
|
||||
"requested_model_id",
|
||||
"upstream_model_id",
|
||||
),
|
||||
] {
|
||||
let Some(value) = value else { continue };
|
||||
let pattern = literal_contains_pattern(value);
|
||||
query.push(format!(" and ({alias}.requested_model_id like "));
|
||||
query.push(format!(" and ({alias}.{first} like "));
|
||||
query.push_bind(pattern.clone());
|
||||
query.push(format!(" escape '\\' or {alias}.upstream_model_id like "));
|
||||
query.push(format!(" escape '\\' or {alias}.{second} like "));
|
||||
query.push_bind(pattern);
|
||||
query.push(" escape '\\')");
|
||||
}
|
||||
|
||||
@@ -961,6 +961,69 @@ async fn usage_search_should_ignore_request_ids_and_preserve_exact_filters() {
|
||||
database.close().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn usage_account_filter_matches_only_historical_names_and_emails() {
|
||||
use admin_observability::UsageRecordStatus::{All, Error, Success};
|
||||
|
||||
let Some(database) = TestDatabase::create("usage_account_filter").await else {
|
||||
return;
|
||||
};
|
||||
let now = Utc::now();
|
||||
seed_observability_facts(&database.pool, now)
|
||||
.await
|
||||
.expect("seed observability facts");
|
||||
seed_calculated_billing_facts(&database.pool, now)
|
||||
.await
|
||||
.expect("seed unrelated request");
|
||||
sqlx::query(
|
||||
"update model_requests set request_observation_json = jsonb_set(
|
||||
request_observation_json, '{account}', case when id = 'req_observe_success'
|
||||
then jsonb_build_object('email', $1::text)
|
||||
else jsonb_build_object('name', $2::text) end)
|
||||
where id in ('req_observe_success', 'req_observe_failed')",
|
||||
)
|
||||
.bind(r"alice_%\ops@example.invalid")
|
||||
.bind("alice team")
|
||||
.execute(&database.pool)
|
||||
.await
|
||||
.expect("set email-only and name-only snapshots");
|
||||
super::drain_analytics(&database.pool).await;
|
||||
|
||||
let range = ObservabilityRange::new(now - TimeDelta::hours(1), now).expect("range");
|
||||
let repo = observability_repository(&database.pool);
|
||||
for (status, search, page, total, expected_id) in [
|
||||
(Success, r"_%\", 1, 1, Some("req_observe_success")),
|
||||
(Error, "team", 1, 1, Some("req_observe_failed")),
|
||||
(All, "alice", 1, 2, Some("req_observe_failed")),
|
||||
(All, "alice", 2, 2, Some("req_observe_success")),
|
||||
(Error, "@example", 1, 0, None),
|
||||
(All, "ALICE", 1, 0, None),
|
||||
(All, "alice%ops", 1, 0, None),
|
||||
(All, "public-model", 1, 0, None),
|
||||
] {
|
||||
let result = repo
|
||||
.list_usage_records(UsageRecordQuery {
|
||||
status,
|
||||
range,
|
||||
filter: UsageRecordFilter {
|
||||
provider_account_search: Some(search.to_owned()),
|
||||
..Default::default()
|
||||
},
|
||||
current_page: page,
|
||||
page_size: ObservabilityPageSize::new(1).expect("page size"),
|
||||
})
|
||||
.await
|
||||
.expect("filter usage by account snapshot");
|
||||
assert_eq!(result.total, total, "{status:?} {search} page {page}");
|
||||
assert_eq!(
|
||||
result.items.first().map(|item| item.id.as_str()),
|
||||
expected_id,
|
||||
"{status:?} {search} page {page}"
|
||||
);
|
||||
}
|
||||
database.close().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn usage_search_should_match_account_email_and_name_substrings() {
|
||||
let Some(database) = TestDatabase::create("usage_account_contains").await else {
|
||||
@@ -2207,7 +2270,7 @@ async fn admin_observability_adapter_preserves_utc_queries_metrics_costs_and_det
|
||||
filter: admin_observability::UsageFilter {
|
||||
model_contains: None,
|
||||
client_api_key_name: None,
|
||||
provider_account_name: None,
|
||||
provider_account_search: Some("@example.invalid".to_owned()),
|
||||
client_api_key_ref: Some("key_observe".to_owned()),
|
||||
request_id: Some("req_observe_success".to_owned()),
|
||||
provider_account_ref: Some("acct_observe".to_owned()),
|
||||
|
||||
@@ -1452,13 +1452,14 @@ async fn queued_history_keeps_frozen_identity_after_configuration_deletion() {
|
||||
if published {
|
||||
super::drain_analytics(&database.pool).await;
|
||||
}
|
||||
for (key_name, account_name, expected) in [
|
||||
for (key_name, account_search, expected) in [
|
||||
(Some("Original Key"), None, 1),
|
||||
(None, Some("Original Account"), 1),
|
||||
(Some("Original Key"), Some("Original Account"), 1),
|
||||
(Some("Original"), None, 1),
|
||||
(Some("ginal K"), None, 1),
|
||||
(None, Some("ginal Acc"), 1),
|
||||
(None, Some("old@"), 1),
|
||||
(Some("queued_key"), None, 0),
|
||||
(None, Some("queued_account"), 0),
|
||||
(Some("Original Account"), None, 0),
|
||||
@@ -1473,7 +1474,7 @@ async fn queued_history_keeps_frozen_identity_after_configuration_deletion() {
|
||||
started_at,
|
||||
UsageRecordFilter {
|
||||
client_api_key_name: key_name.map(str::to_owned),
|
||||
provider_account_name: account_name.map(str::to_owned),
|
||||
provider_account_search: account_search.map(str::to_owned),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
@@ -1481,7 +1482,7 @@ async fn queued_history_keeps_frozen_identity_after_configuration_deletion() {
|
||||
let page = repository.list_usage_records(query).await.unwrap();
|
||||
assert_eq!(
|
||||
page.total, expected,
|
||||
"published={published}, key={key_name:?}, account={account_name:?}, status={status:?}"
|
||||
"published={published}, key={key_name:?}, account={account_search:?}, status={status:?}"
|
||||
);
|
||||
assert_eq!(page.items.len() as u64, expected);
|
||||
if expected == 1 {
|
||||
|
||||
@@ -251,6 +251,27 @@ struct PricingRule {
|
||||
// 已按 https://developers.openai.com/api/docs/deprecations 核验至 2026-09-13,
|
||||
// 移除已关闭的型号;仅宣布弃用但尚未到关闭日期的型号继续保留
|
||||
const PRICING_RULES: &[PricingRule] = &[
|
||||
// GPT-6.2 的 Ultrafast 使用官方价目表中的 6 倍常规价,核验日期 2026-11-18
|
||||
PricingRule {
|
||||
model: "gpt-6.2-astra",
|
||||
pricing: ModelPricing::new(80_000, 400_000, 4_000)
|
||||
.with_cache_write(125)
|
||||
.with_fast(160_000, 800_000, 8_000)
|
||||
.with_ultrafast(480_000, 2_400_000, 24_000)
|
||||
.with_long(160_000, 600_000, 8_000)
|
||||
.with_long_fast(320_000, 1_200_000, 16_000)
|
||||
.with_long_ultrafast(960_000, 3_600_000, 48_000),
|
||||
},
|
||||
PricingRule {
|
||||
model: "gpt-6.2-sol",
|
||||
pricing: ModelPricing::new(20_000, 100_000, 1_000)
|
||||
.with_cache_write(125)
|
||||
.with_fast(40_000, 200_000, 2_000)
|
||||
.with_ultrafast(120_000, 600_000, 6_000)
|
||||
.with_long(40_000, 150_000, 2_000)
|
||||
.with_long_fast(80_000, 300_000, 4_000)
|
||||
.with_long_ultrafast(240_000, 900_000, 12_000),
|
||||
},
|
||||
// Astra:https://developers.openai.com/api/docs/models/gpt-6-astra
|
||||
// 已于 2026-09-09 对照官方价目表核验
|
||||
PricingRule {
|
||||
@@ -924,7 +945,13 @@ fn reasoning_model(model: &str) -> bool {
|
||||
model.starts_with("gpt-5")
|
||||
|| matches!(
|
||||
model,
|
||||
"gpt-6-astra" | "gpt-6.1-sol" | "gpt-6.1-terra" | "gpt-6-sol" | "gpt-6-luna"
|
||||
"gpt-6.2-astra"
|
||||
| "gpt-6.2-sol"
|
||||
| "gpt-6-astra"
|
||||
| "gpt-6.1-sol"
|
||||
| "gpt-6.1-terra"
|
||||
| "gpt-6-sol"
|
||||
| "gpt-6-luna"
|
||||
)
|
||||
|| model.starts_with("o1")
|
||||
|| model.starts_with("o3")
|
||||
|
||||
@@ -523,13 +523,18 @@ async fn copying_builtin_prices_keeps_cache_read_and_write_fallback_costs() {
|
||||
for model in [
|
||||
"gpt-4",
|
||||
"gpt-4o",
|
||||
"gpt-6.2-astra",
|
||||
"gpt-6.2-sol",
|
||||
"gpt-6-astra",
|
||||
"gpt-6.1-sol",
|
||||
"gpt-6.1-terra",
|
||||
"gpt-6-sol",
|
||||
"gpt-6-luna",
|
||||
] {
|
||||
let ultrafast_supported = matches!(model, "gpt-6-astra" | "gpt-6.1-sol");
|
||||
let ultrafast_supported = matches!(
|
||||
model,
|
||||
"gpt-6.2-astra" | "gpt-6.2-sol" | "gpt-6-astra" | "gpt-6.1-sol"
|
||||
);
|
||||
for band in ["ultrafast", "long_ultrafast"] {
|
||||
assert_eq!(prices[model].bands.contains_key(band), ultrafast_supported);
|
||||
}
|
||||
|
||||
@@ -546,6 +546,8 @@ fn decoder_should_use_non_reasoning_preview_web_search_price() {
|
||||
fn gpt_6_decoders_should_use_reasoning_preview_web_search_price() {
|
||||
let tools = vec![json!({ "type": "web_search_preview" })];
|
||||
for model in [
|
||||
"gpt-6.2-astra",
|
||||
"gpt-6.2-sol",
|
||||
"gpt-6-astra",
|
||||
"gpt-6.1-sol",
|
||||
"gpt-6.1-terra",
|
||||
|
||||
@@ -82,6 +82,28 @@ fn astra_billing_should_preserve_components_across_tiers_and_context_boundary()
|
||||
fn gpt_6_models_should_use_published_prices_across_tiers_and_context_boundary() {
|
||||
// 每档依次核对每百万 Token 的输入、缓存读取、缓存写入和输出价格
|
||||
for (model, cases) in [
|
||||
(
|
||||
"gpt-6.2-astra",
|
||||
[
|
||||
(None, 272_000, ["8", "0.4", "10", "40"]),
|
||||
(None, 272_001, ["16", "0.8", "20", "60"]),
|
||||
(Some("fast"), 272_000, ["16", "0.8", "20", "80"]),
|
||||
(Some("priority"), 272_001, ["32", "1.6", "40", "120"]),
|
||||
(Some("ultrafast"), 272_000, ["48", "2.4", "60", "240"]),
|
||||
(Some("ultrafast"), 272_001, ["96", "4.8", "120", "360"]),
|
||||
],
|
||||
),
|
||||
(
|
||||
"gpt-6.2-sol",
|
||||
[
|
||||
(None, 272_000, ["2", "0.1", "2.5", "10"]),
|
||||
(None, 272_001, ["4", "0.2", "5", "15"]),
|
||||
(Some("fast"), 272_000, ["4", "0.2", "5", "20"]),
|
||||
(Some("priority"), 272_001, ["8", "0.4", "10", "30"]),
|
||||
(Some("ultrafast"), 272_000, ["12", "0.6", "15", "60"]),
|
||||
(Some("ultrafast"), 272_001, ["24", "1.2", "30", "90"]),
|
||||
],
|
||||
),
|
||||
(
|
||||
"gpt-6.1-sol",
|
||||
[
|
||||
@@ -457,6 +479,10 @@ fn billing_should_not_inherit_prices_for_unknown_models_or_tiers() {
|
||||
("gpt-5.5-cyber", 272_001, None),
|
||||
("gpt-5.6-cyber", 1, Some("fast")),
|
||||
("gpt-5.3-codex", 1, Some("flex")),
|
||||
("gpt-6.2-astra", 1, Some("flex")),
|
||||
("gpt-6.2-astra", 272_001, Some("flex")),
|
||||
("gpt-6.2-sol", 1, Some("flex")),
|
||||
("gpt-6.2-sol", 272_001, Some("flex")),
|
||||
("gpt-6-astra", 1, Some("auto")),
|
||||
("gpt-6-astra", 1, Some("future")),
|
||||
("gpt-6.1-terra", 1, Some("ultrafast")),
|
||||
|
||||
+4
-2
@@ -223,6 +223,8 @@ docker compose -f deploy/compose.yaml stats --no-stream
|
||||
|
||||
## 部署结构
|
||||
|
||||
PostgreSQL 最低版本为 16,默认 Compose 使用 PostgreSQL 18
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
Client[客户端 / 管理浏览器] -->|HTTPS| Proxy[反向代理]
|
||||
@@ -320,7 +322,7 @@ store:
|
||||
## Windows 二进制部署
|
||||
|
||||
发行包提供 Windows x64(`windows_amd64`)和 ARM64(`windows_arm64`)版本,按运行机器的 CPU 架构选择。
|
||||
需先准备可访问的 PostgreSQL 和 Redis,创建数据库及用户;使用数据库备份功能时,还需将匹配服务端版本的 `pg_dump` 加入 `PATH`
|
||||
需先按[数据库版本要求](#部署结构)准备 PostgreSQL,创建数据库及用户,并确保 Redis 可访问。使用数据库备份功能时,还需将匹配服务端版本的 `pg_dump` 加入 `PATH`
|
||||
|
||||
从 [Release 附件](https://github.com/zyycn/codex-proxy-rs/releases) 下载对应的
|
||||
`codex-proxy-rs_<version>_windows_<arch>.tar.gz`,解压后保留 `codex-proxy-rs.exe`、`web/dist`、`deploy` 和 `plugins/official` 的目录关系。
|
||||
@@ -964,7 +966,7 @@ exp 不进入正式版、alpha、beta 或 rc,普通实例也不能选择 Exp
|
||||
其他通道的版本及发布说明,手动检查显示“当前没有可用更新”。检查失败单独报告,不能当作没有更新
|
||||
|
||||
alpha、beta、rc、exp 在 GitHub 标记为 Pre-release,不覆盖 GitHub Latest 或镜像 `latest`。
|
||||
升级前核对目标版本的数据库要求;可连续升级的发行线与约束见[迁移冻结规则](../backend/migrations/README.md#冻结规则)
|
||||
升级前确认 PostgreSQL 满足目标版本的[部署要求](#部署结构)。可连续升级的发行线与约束见[迁移冻结规则](../backend/migrations/README.md#冻结规则)
|
||||
|
||||
### 管理端在线更新
|
||||
|
||||
|
||||
+5
-4
@@ -2420,7 +2420,8 @@ Token,范围 0~1000000、最多四位小数。`"0"` 表示免费,缺少整
|
||||
|
||||
`bands` 可用键为 `standard`、`fast`、`ultrafast`、`flex`、`long_standard`、`long_fast`、`long_ultrafast`、`long_flex`、`image`。
|
||||
OpenAI 长上下文为输入超过 272000 Token,xAI 为输入达到 200000 Token;仍按 Provider 支持的
|
||||
模型与服务档位判断是否能估算。OpenAI 内置 Ultrafast 价目覆盖 `gpt-6-astra` 与 `gpt-6.1-sol`。
|
||||
模型与服务档位判断是否能估算。OpenAI 内置 Ultrafast 价目覆盖 `gpt-6-astra`、`gpt-6.1-sol`、
|
||||
`gpt-6.2-astra` 和 `gpt-6.2-sol`,均按对应上下文标准价的 6 倍估算。
|
||||
xAI 不接受 `flex`、`long_flex`、`ultrafast`、`long_ultrafast`、`image`。图像端点的 `standard`
|
||||
用于文本输入,`image` 用于图像 Token;不能用文本输出单价替代图像输出单价。用量无法完整拆分时不估算
|
||||
|
||||
@@ -2789,7 +2790,7 @@ Dashboard 的 `accountUsage[]` 返回稳定指标 `metric=requests|tokens`、可
|
||||
Dashboard 默认 `period=today`,用量、诊断和错误查询默认 `period=7d`,范围参数遵循[页面时间合同](#页面时间合同)。
|
||||
Dashboard 返回原始 `asOf` 及 `asOfDisplay`,作为当前数据的查询锚点
|
||||
|
||||
请求明细列表接受 `currentPage`、`pageSize`、时间范围、`provider`、`clientApiKeyName`、`accountName`、`model` 和 `status`。
|
||||
请求明细列表接受 `currentPage`、`pageSize`、时间范围、`provider`、`clientApiKeyName`、`accountSearch`、`model` 和 `status`。
|
||||
汇总和洞察接受时间范围与 `provider`;性能和成本另要求 `metric`,诊断另接受 `dimension`、`model` 和 `statusCode`。
|
||||
各接口拒绝未知参数,明细筛选不改变顶部统计范围
|
||||
|
||||
@@ -2859,8 +2860,8 @@ HTTP SSE 请求可能在返回 HTTP 200 后流内失败;WebSocket 已升级时
|
||||
|
||||
管理端请求列表与详情保留 `requestedModel`(客户端请求)与 `upstreamModel`(网关发送)
|
||||
|
||||
请求明细的 `clientApiKeyName`、`accountName` 按字面量包含匹配请求保存的历史名称快照,区分大小写,
|
||||
不解析为 ID,也不依赖当前配置是否存在。`model` 按字面量包含匹配请求模型或上游模型,`%`、`_` 和 `\` 按普通字符处理
|
||||
请求明细的 `clientApiKeyName` 匹配 Key 名称,`accountSearch` 匹配账号名称或邮箱。
|
||||
这些筛选仅使用历史快照,可与时间、状态等条件组合。`model` 匹配请求模型或上游模型。以上文本筛选均按区分大小写的字面量包含匹配,`%`、`_` 和 `\` 按普通字符处理
|
||||
|
||||
运维错误列表的 `search` 使用字面量包含匹配,`%`、`_` 和 `\` 按普通字符处理,不支持密钥值或可见前缀搜索。
|
||||
请求详情通过 `/api/admin/usage/records/detail?id=...` 查询
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
autoInstallPeers: false
|
||||
|
||||
# picomatch 只在构建工具链中使用,未进入发布产物。上游发布修复后升级并移除此例外
|
||||
audit:
|
||||
ignore:
|
||||
- GHSA-fc5q-39xc-vjpf
|
||||
|
||||
# Git 依赖通过 prepack 生成产物;信任自有 UI 仓库,实际提交仍由锁文件固定。
|
||||
allowBuilds:
|
||||
'@codex-proxy/ui@git+https://github.com/zyycn/codex-proxy-ui.git': true
|
||||
|
||||
@@ -425,7 +425,7 @@ interface PageQuery {
|
||||
|
||||
type UsagePageQuery = UsageRangeQuery & PageQuery & {
|
||||
clientApiKeyName?: string
|
||||
accountName?: string
|
||||
accountSearch?: string
|
||||
model?: string
|
||||
status?: UsageRecordStatus
|
||||
}
|
||||
|
||||
@@ -9,12 +9,22 @@ import UsageDetailPopover from '@/components/usage/UsageDetailPopover.vue'
|
||||
import { usageBillingText } from './shared/presenter'
|
||||
|
||||
const props = defineProps<{
|
||||
record: Pick<UsageListRecord, 'billing'>
|
||||
record: Pick<UsageListRecord, 'billing'> & Partial<Pick<UsageListRecord, 'serviceTier'>>
|
||||
}>()
|
||||
|
||||
const { t } = useI18n({ useScope: 'global' })
|
||||
|
||||
const billing = computed(() => props.record.billing)
|
||||
const speedMode = computed(() => {
|
||||
const tier = props.record.serviceTier ?? billing.value?.serviceTierDisplay.toLowerCase()
|
||||
if (tier === 'fast' || tier === 'priority')
|
||||
return 'Fast'
|
||||
if (tier === 'ultrafast')
|
||||
return 'Ultrafast'
|
||||
return null
|
||||
})
|
||||
const speedModeLabel = computed(() => t('usage.billing.speedMode', { mode: speedMode.value }))
|
||||
|
||||
const billingItems = computed(() => {
|
||||
const value = billing.value
|
||||
if (!value)
|
||||
@@ -137,17 +147,19 @@ function itemValueClass(tone?: string, accent?: boolean) {
|
||||
{{ usageBillingText(record) }}
|
||||
</span>
|
||||
|
||||
<div v-if="billing" class="flex items-center gap-1">
|
||||
<div v-if="billing || speedMode" class="flex shrink-0 items-center gap-1">
|
||||
<span
|
||||
v-if="billing.serviceTierDisplay === 'Fast'"
|
||||
class="inline-flex size-4 items-center justify-center rounded-full bg-z-warning-container text-z-warning-on-container"
|
||||
:title="t('usage.billing.fastMode')"
|
||||
v-if="speedMode"
|
||||
class="inline-flex h-4 items-center rounded-full bg-z-warning-container px-0.5 text-z-warning-on-container"
|
||||
:title="speedModeLabel"
|
||||
role="img"
|
||||
:aria-label="t('usage.billing.fastMode')"
|
||||
:aria-label="speedModeLabel"
|
||||
>
|
||||
<Zap class="size-3" stroke-width="2.2" aria-hidden="true" />
|
||||
<Zap v-if="speedMode === 'Ultrafast'" class="size-3" stroke-width="2.2" aria-hidden="true" />
|
||||
</span>
|
||||
<UsageDetailPopover
|
||||
v-if="billing"
|
||||
:title="billing.longContextBillingApplied ? t('usage.billing.longContextBillingDetails') : t('usage.billing.billingDetails')"
|
||||
:trigger-label="billing.longContextBillingApplied ? t('usage.billing.viewLongContextBillingDetails') : t('usage.billing.viewCostDetails')"
|
||||
:tone="billing.longContextBillingApplied ? 'warning' : 'primary'"
|
||||
|
||||
@@ -26,7 +26,7 @@ const outcome = computed(() => usageErrorTitle(props.record))
|
||||
<div class="min-w-0 py-0.5">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<span
|
||||
class="inline-flex size-5 shrink-0 items-center justify-center rounded-z-sm"
|
||||
class="inline-flex size-5 shrink-0 items-center justify-center"
|
||||
:class="origin.className"
|
||||
role="img"
|
||||
:aria-label="origin.label"
|
||||
|
||||
@@ -24,22 +24,22 @@ export function usageErrorOrigin(record: Pick<UsageErrorFacts, 'errorOrigin'>) {
|
||||
const origins = {
|
||||
proxy: {
|
||||
label: t('usage.error.origin.proxy'),
|
||||
className: 'bg-z-blue-container text-z-blue-on-container',
|
||||
className: 'text-z-blue-text',
|
||||
hint: null,
|
||||
},
|
||||
upstream: {
|
||||
label: t('usage.error.origin.upstream'),
|
||||
className: 'bg-z-error-container text-z-error-on-container',
|
||||
className: 'text-z-error-text',
|
||||
hint: null,
|
||||
},
|
||||
connection: {
|
||||
label: t('usage.error.origin.connection'),
|
||||
className: 'bg-z-warning-container text-z-warning-on-container',
|
||||
className: 'text-z-warning-text',
|
||||
hint: t('usage.error.origin.connectionHint'),
|
||||
},
|
||||
unknown: {
|
||||
label: t('usage.error.origin.unknown'),
|
||||
className: 'bg-z-fill-tertiary text-z-text-secondary',
|
||||
className: 'text-z-text-secondary',
|
||||
hint: t('usage.error.origin.unknownHint'),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"cacheReadCost": "Cache read cost",
|
||||
"cacheWriteCost": "Cache write cost",
|
||||
"cacheWriteUnitPrice": "Cache write unit price",
|
||||
"fastMode": "Fast mode",
|
||||
"speedMode": "{mode} mode",
|
||||
"longContextBillingDetails": "Long-context cost details",
|
||||
"billingDetails": "Cost details",
|
||||
"viewLongContextBillingDetails": "View long-context cost details",
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"cacheReadCost": "缓存读取费用",
|
||||
"cacheWriteCost": "缓存写入费用",
|
||||
"cacheWriteUnitPrice": "缓存写入单价",
|
||||
"fastMode": "Fast 模式",
|
||||
"speedMode": "{mode} 模式",
|
||||
"longContextBillingDetails": "长上下文计费明细",
|
||||
"billingDetails": "计费明细",
|
||||
"viewLongContextBillingDetails": "查看长上下文计费明细",
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"cacheReadCost": "緩存讀取費用",
|
||||
"cacheWriteCost": "緩存寫入費用",
|
||||
"cacheWriteUnitPrice": "緩存寫入單價",
|
||||
"fastMode": "Fast 模式",
|
||||
"speedMode": "{mode} 模式",
|
||||
"longContextBillingDetails": "長上下文計費明細",
|
||||
"billingDetails": "計費明細",
|
||||
"viewLongContextBillingDetails": "查看長上下文計費明細",
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useUsageRecordsTable(options: UseUsageRecordsTableOptions) {
|
||||
clientApiKeyName: filterField.value === 'key'
|
||||
? value
|
||||
: undefined,
|
||||
accountName: filterField.value === 'account'
|
||||
accountSearch: filterField.value === 'account'
|
||||
? value
|
||||
: undefined,
|
||||
model: filterField.value === 'model'
|
||||
@@ -74,7 +74,7 @@ export function useUsageRecordsTable(options: UseUsageRecordsTableOptions) {
|
||||
function filterChanged() {
|
||||
const filter = filterParams.value
|
||||
return tableParams.clientApiKeyName !== filter.clientApiKeyName
|
||||
|| tableParams.accountName !== filter.accountName
|
||||
|| tableParams.accountSearch !== filter.accountSearch
|
||||
|| tableParams.model !== filter.model
|
||||
}
|
||||
|
||||
|
||||
+7
-12
@@ -1,21 +1,16 @@
|
||||
# v3.51.0
|
||||
# v3.52.0
|
||||
|
||||
## 新增功能
|
||||
|
||||
- 插件可按账号、额度桶和时间范围分页读取已保留的 OpenAI 请求额度观测及区间起点基线,单次查询区间最长 366 天
|
||||
- 调度插件可区分候选账号的会话绑定、优先选择、跟随绑定和固定选号关系
|
||||
- 请求记录可按历史账号名称或邮箱筛选
|
||||
- 内置 GPT-6.2 Astra 和 Sol 价目,Ultrafast 按常规价估算
|
||||
|
||||
## 优化改进
|
||||
|
||||
- 账号、Key 和代理的更多操作菜单支持统一的键盘交互
|
||||
- 额度设置在提交时校验并定位错误,预热开关与额度桶标题同行显示
|
||||
- Key 用量页缩窄桌面端模型筛选框
|
||||
|
||||
## 问题修复
|
||||
|
||||
- OpenAI 严格亲和下,子线程因绑定账号的模型权限受限而等待换号时,超时提示明确说明模型限制
|
||||
- 请求记录用双闪电标识 Ultrafast,用单闪电标识 Fast
|
||||
- 请求错误来源图标改为无底色显示
|
||||
|
||||
## 升级须知
|
||||
|
||||
- 调度插件的 `scheduler` 能力升级至 v4,使用 v3 的插件需更新能力声明并适配新增候选字段后使用
|
||||
- 历史额度查询受请求记录保留范围限制,使用观测差值时需处理重置、套餐变化和缺样
|
||||
- 调用 `GET /api/admin/usage/records` 的客户端需将查询参数 `accountName` 改为 `accountSearch`,旧参数会返回 HTTP 400
|
||||
- 自行部署时请确认 PostgreSQL 版本为 16 或更高,默认 Compose 使用 PostgreSQL 18
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: 3.51.0
|
||||
version: 3.52.0
|
||||
published:
|
||||
'3':
|
||||
stable: 3.50.0
|
||||
rc: 3.50.0
|
||||
beta: 3.50.0
|
||||
alpha: 3.50.0
|
||||
stable: 3.51.0
|
||||
rc: 3.51.0
|
||||
beta: 3.51.0
|
||||
alpha: 3.51.0
|
||||
|
||||
Reference in New Issue
Block a user