feat: 支持配置渠道被禁用后是否清空渠道粘性 (#5306)
* fix: evict stale channel affinity * feat: configure disabled channel affinity retention --------- Co-authored-by: Seefs <i@seefs.me>
This commit is contained in:
@@ -196,6 +196,7 @@ export function ModelMutateDrawer({
|
||||
'grok.violation_deduction_amount': 0,
|
||||
'channel_affinity_setting.enabled': false,
|
||||
'channel_affinity_setting.switch_on_success': true,
|
||||
'channel_affinity_setting.keep_on_channel_disabled': false,
|
||||
'channel_affinity_setting.max_entries': 100000,
|
||||
'channel_affinity_setting.default_ttl_seconds': 3600,
|
||||
'channel_affinity_setting.rules': '[]',
|
||||
|
||||
@@ -100,6 +100,9 @@ export function ChannelAffinitySection(props: Props) {
|
||||
const [switchOnSuccess, setSwitchOnSuccess] = useState(
|
||||
props.defaultValues['channel_affinity_setting.switch_on_success']
|
||||
)
|
||||
const [keepOnChannelDisabled, setKeepOnChannelDisabled] = useState(
|
||||
props.defaultValues['channel_affinity_setting.keep_on_channel_disabled']
|
||||
)
|
||||
const [maxEntries, setMaxEntries] = useState(
|
||||
props.defaultValues['channel_affinity_setting.max_entries']
|
||||
)
|
||||
@@ -136,6 +139,9 @@ export function ChannelAffinitySection(props: Props) {
|
||||
setSwitchOnSuccess(
|
||||
props.defaultValues['channel_affinity_setting.switch_on_success']
|
||||
)
|
||||
setKeepOnChannelDisabled(
|
||||
props.defaultValues['channel_affinity_setting.keep_on_channel_disabled']
|
||||
)
|
||||
setMaxEntries(props.defaultValues['channel_affinity_setting.max_entries'])
|
||||
setDefaultTtl(
|
||||
props.defaultValues['channel_affinity_setting.default_ttl_seconds']
|
||||
@@ -231,6 +237,14 @@ export function ChannelAffinitySection(props: Props) {
|
||||
key: 'channel_affinity_setting.switch_on_success',
|
||||
value: String(switchOnSuccess),
|
||||
})
|
||||
if (
|
||||
keepOnChannelDisabled !==
|
||||
props.defaultValues['channel_affinity_setting.keep_on_channel_disabled']
|
||||
)
|
||||
updates.push({
|
||||
key: 'channel_affinity_setting.keep_on_channel_disabled',
|
||||
value: String(keepOnChannelDisabled),
|
||||
})
|
||||
if (
|
||||
maxEntries !==
|
||||
props.defaultValues['channel_affinity_setting.max_entries']
|
||||
@@ -397,6 +411,14 @@ export function ChannelAffinitySection(props: Props) {
|
||||
'If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.'
|
||||
)}
|
||||
/>
|
||||
<SettingsSwitchField
|
||||
checked={keepOnChannelDisabled}
|
||||
onCheckedChange={setKeepOnChannelDisabled}
|
||||
label={t('Keep affinity when channel is disabled')}
|
||||
description={t(
|
||||
'When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.'
|
||||
)}
|
||||
/>
|
||||
|
||||
<Separator />
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ export interface CacheStats {
|
||||
export interface ChannelAffinitySettings {
|
||||
'channel_affinity_setting.enabled': boolean
|
||||
'channel_affinity_setting.switch_on_success': boolean
|
||||
'channel_affinity_setting.keep_on_channel_disabled': boolean
|
||||
'channel_affinity_setting.max_entries': number
|
||||
'channel_affinity_setting.default_ttl_seconds': number
|
||||
'channel_affinity_setting.rules': string
|
||||
|
||||
@@ -64,6 +64,7 @@ const defaultModelSettings: ModelSettings = {
|
||||
'group_ratio_setting.group_special_usable_group': '{}',
|
||||
'channel_affinity_setting.enabled': false,
|
||||
'channel_affinity_setting.switch_on_success': true,
|
||||
'channel_affinity_setting.keep_on_channel_disabled': false,
|
||||
'channel_affinity_setting.max_entries': 100000,
|
||||
'channel_affinity_setting.default_ttl_seconds': 3600,
|
||||
'channel_affinity_setting.rules': '[]',
|
||||
|
||||
@@ -130,6 +130,8 @@ const MODELS_SECTIONS = [
|
||||
settings['channel_affinity_setting.enabled'],
|
||||
'channel_affinity_setting.switch_on_success':
|
||||
settings['channel_affinity_setting.switch_on_success'],
|
||||
'channel_affinity_setting.keep_on_channel_disabled':
|
||||
settings['channel_affinity_setting.keep_on_channel_disabled'],
|
||||
'channel_affinity_setting.max_entries':
|
||||
settings['channel_affinity_setting.max_entries'],
|
||||
'channel_affinity_setting.default_ttl_seconds':
|
||||
|
||||
@@ -176,6 +176,7 @@ export type ModelSettings = {
|
||||
'group_ratio_setting.group_special_usable_group': string
|
||||
'channel_affinity_setting.enabled': boolean
|
||||
'channel_affinity_setting.switch_on_success': boolean
|
||||
'channel_affinity_setting.keep_on_channel_disabled': boolean
|
||||
'channel_affinity_setting.max_entries': number
|
||||
'channel_affinity_setting.default_ttl_seconds': number
|
||||
'channel_affinity_setting.rules': string
|
||||
|
||||
Vendored
+2
@@ -644,6 +644,7 @@
|
||||
"Channel Affinity": "Channel Affinity",
|
||||
"Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.": "Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.",
|
||||
"Channel Affinity: Upstream Cache Hit": "Channel Affinity: Upstream Cache Hit",
|
||||
"Keep affinity when channel is disabled": "Keep affinity when channel is disabled",
|
||||
"Channel copied successfully": "Channel copied successfully",
|
||||
"Channel created successfully": "Channel created successfully",
|
||||
"Channel deleted successfully": "Channel deleted successfully",
|
||||
@@ -1994,6 +1995,7 @@
|
||||
"If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing": "If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing",
|
||||
"If default auto group is enabled, newly created tokens start with auto instead of an empty group.": "If default auto group is enabled, newly created tokens start with auto instead of an empty group.",
|
||||
"If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.": "If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.",
|
||||
"When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.": "When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.",
|
||||
"If this keeps happening, please report it on GitHub Issues.": "If this keeps happening, please report it on GitHub Issues.",
|
||||
"If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.": "If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.",
|
||||
"Ignored upstream models": "Ignored upstream models",
|
||||
|
||||
Vendored
+2
@@ -644,6 +644,7 @@
|
||||
"Channel Affinity": "Affinité de canal",
|
||||
"Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.": "L'affinité de canal réutilise le dernier canal ayant réussi, en se basant sur les clés extraites du contexte de la requête ou du corps JSON.",
|
||||
"Channel Affinity: Upstream Cache Hit": "Affinité de canal : hit de cache en amont",
|
||||
"Keep affinity when channel is disabled": "Conserver l'affinité lorsque le canal est désactivé",
|
||||
"Channel copied successfully": "Canal copié avec succès",
|
||||
"Channel created successfully": "Canal créé avec succès",
|
||||
"Channel deleted successfully": "Canal supprimé avec succès",
|
||||
@@ -1994,6 +1995,7 @@
|
||||
"If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing": "Si vous vous connectez à des projets de relais One API ou New API en amont, utilisez le type OpenAI à la place sauf si vous savez ce que vous faites",
|
||||
"If default auto group is enabled, newly created tokens start with auto instead of an empty group.": "Si le groupe auto par défaut est activé, les nouveaux jetons commencent avec auto au lieu d’un groupe vide.",
|
||||
"If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.": "Si le canal affinitaire échoue et qu'une nouvelle tentative réussit sur un autre canal, mettre à jour l'affinité vers le canal ayant réussi.",
|
||||
"When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.": "Lorsque cette option est activée, conserver l'entrée d'affinité même si le canal affinitaire est désactivé ou n'est plus utilisable pour le groupe/modèle actuel. Laissez-la désactivée pour supprimer l'entrée et sélectionner un autre canal.",
|
||||
"If this keeps happening, please report it on GitHub Issues.": "Si cela continue, veuillez le signaler sur GitHub Issues.",
|
||||
"If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.": "Si vous fournissez des services d’IA générative au public en Chine continentale, vous remplirez les obligations légales applicables, notamment le dépôt, l’évaluation de sécurité, la sécurité du contenu, le traitement des plaintes, l’étiquetage du contenu généré, la conservation des journaux et la protection des informations personnelles.",
|
||||
"Ignored upstream models": "Modèles amont ignorés",
|
||||
|
||||
Vendored
+2
@@ -644,6 +644,7 @@
|
||||
"Channel Affinity": "チャネルアフィニティ",
|
||||
"Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.": "チャネルアフィニティは、リクエストコンテキストまたは JSON Body から抽出したキーに基づいて、前回成功したチャネルを優先的に再利用します。",
|
||||
"Channel Affinity: Upstream Cache Hit": "チャネルアフィニティ:上流キャッシュヒット",
|
||||
"Keep affinity when channel is disabled": "チャネル無効時にアフィニティを保持",
|
||||
"Channel copied successfully": "チャンネルが正常にコピーされました",
|
||||
"Channel created successfully": "チャンネルが正常に作成されました",
|
||||
"Channel deleted successfully": "チャンネルが正常に削除されました",
|
||||
@@ -1994,6 +1995,7 @@
|
||||
"If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing": "上流の One API または New API リレープロジェクトに接続する場合、知っている場合を除き OpenAI タイプを使用してください",
|
||||
"If default auto group is enabled, newly created tokens start with auto instead of an empty group.": "デフォルト auto グループを有効にすると、新規トークンは空グループではなく auto で開始します。",
|
||||
"If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.": "アフィニティチャネルが失敗し、別のチャネルでリトライが成功した場合、アフィニティを成功したチャネルに更新します。",
|
||||
"When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.": "有効にすると、アフィニティチャネルが無効化された、または現在のグループ/モデルで利用できなくなった場合でも、そのアフィニティエントリを保持します。無効のままにすると、エントリを削除して別のチャネルを選択します。",
|
||||
"If this keeps happening, please report it on GitHub Issues.": "この問題が続く場合は、GitHub Issues で報告してください。",
|
||||
"If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.": "中国本土で一般向けに生成 AI サービスを提供する場合、届出、セキュリティ評価、コンテンツ安全、苦情対応、生成コンテンツのラベル表示、ログ保存、個人情報保護などの法的義務を履行します。",
|
||||
"Ignored upstream models": "無視する上流モデル",
|
||||
|
||||
Vendored
+2
@@ -644,6 +644,7 @@
|
||||
"Channel Affinity": "Привязка к каналу",
|
||||
"Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.": "Привязка к каналу повторно использует последний успешный канал на основе ключей, извлечённых из контекста запроса или тела JSON.",
|
||||
"Channel Affinity: Upstream Cache Hit": "Привязка к каналу: попадание в кэш upstream",
|
||||
"Keep affinity when channel is disabled": "Сохранять привязку при отключении канала",
|
||||
"Channel copied successfully": "Канал успешно скопирован",
|
||||
"Channel created successfully": "Канал успешно создан",
|
||||
"Channel deleted successfully": "Канал успешно удалён",
|
||||
@@ -1994,6 +1995,7 @@
|
||||
"If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing": "При подключении к upstream One API или проектам-ретрансляторам New API используйте тип OpenAI, если только вы точно знаете, что делаете",
|
||||
"If default auto group is enabled, newly created tokens start with auto instead of an empty group.": "Если группа auto включена по умолчанию, новые токены создаются с auto вместо пустой группы.",
|
||||
"If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.": "Если привязанный канал не работает и повторная попытка удалась через другой канал, привязка обновляется на успешный канал.",
|
||||
"When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.": "Если включено, запись привязки сохраняется, даже когда привязанный канал отключён или больше не подходит для текущей группы/модели. Оставьте выключенным, чтобы удалять запись и выбирать другой канал.",
|
||||
"If this keeps happening, please report it on GitHub Issues.": "Если проблема повторяется, сообщите о ней в GitHub Issues.",
|
||||
"If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.": "Если вы предоставляете услуги генеративного ИИ населению материкового Китая, вы будете выполнять юридические обязанности, включая регистрацию, оценку безопасности, безопасность контента, обработку жалоб, маркировку сгенерированного контента, хранение журналов и защиту персональных данных.",
|
||||
"Ignored upstream models": "Игнорируемые upstream-модели",
|
||||
|
||||
Vendored
+2
@@ -644,6 +644,7 @@
|
||||
"Channel Affinity": "Ưu tiên kênh",
|
||||
"Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.": "Ưu tiên kênh sẽ sử dụng lại kênh thành công gần nhất dựa trên các khóa được trích xuất từ ngữ cảnh yêu cầu hoặc JSON body.",
|
||||
"Channel Affinity: Upstream Cache Hit": "Ưu tiên kênh: Cache hit từ upstream",
|
||||
"Keep affinity when channel is disabled": "Giữ ưu tiên khi kênh bị tắt",
|
||||
"Channel copied successfully": "Sao chép kênh thành công",
|
||||
"Channel created successfully": "Tạo kênh thành công",
|
||||
"Channel deleted successfully": "Xóa kênh thành công",
|
||||
@@ -1994,6 +1995,7 @@
|
||||
"If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing": "Nếu kết nối với dự án relay One API hoặc New API upstream, hãy sử dụng loại OpenAI thay thế trừ khi bạn biết mình đang làm gì",
|
||||
"If default auto group is enabled, newly created tokens start with auto instead of an empty group.": "Nếu bật nhóm auto mặc định, token mới sẽ bắt đầu với auto thay vì nhóm trống.",
|
||||
"If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.": "Nếu kênh ưu tiên thất bại và thử lại thành công trên kênh khác, cập nhật ưu tiên sang kênh thành công.",
|
||||
"When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.": "Khi bật, giữ mục ưu tiên ngay cả khi kênh ưu tiên bị tắt hoặc không còn dùng được cho nhóm/mô hình hiện tại. Để tắt để xóa mục đó và chọn kênh khác.",
|
||||
"If this keeps happening, please report it on GitHub Issues.": "Nếu sự cố tiếp tục xảy ra, vui lòng báo cáo trên GitHub Issues.",
|
||||
"If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.": "Nếu bạn cung cấp dịch vụ AI tạo sinh cho công chúng tại Trung Quốc đại lục, bạn sẽ thực hiện các nghĩa vụ pháp lý bao gồm đăng ký, đánh giá an toàn, an toàn nội dung, xử lý khiếu nại, gắn nhãn nội dung được tạo, lưu giữ nhật ký và bảo vệ thông tin cá nhân.",
|
||||
"Ignored upstream models": "Mô hình upstream bị bỏ qua",
|
||||
|
||||
Vendored
+2
@@ -644,6 +644,7 @@
|
||||
"Channel Affinity": "渠道亲和性",
|
||||
"Channel affinity reuses the last successful channel based on keys extracted from the request context or JSON body.": "渠道亲和性会基于从请求上下文或 JSON Body 提取的 Key,优先复用上一次成功的渠道。",
|
||||
"Channel Affinity: Upstream Cache Hit": "渠道亲和性:上游缓存命中",
|
||||
"Keep affinity when channel is disabled": "渠道禁用后保留亲和",
|
||||
"Channel copied successfully": "渠道复制成功",
|
||||
"Channel created successfully": "渠道创建成功",
|
||||
"Channel deleted successfully": "渠道删除成功",
|
||||
@@ -1994,6 +1995,7 @@
|
||||
"If connecting to upstream One API or New API relay projects, use OpenAI type instead unless you know what you are doing": "如果连接上游 One API 或 New API 中继项目,除非您知道自己在做什么,否则请使用 OpenAI 类型",
|
||||
"If default auto group is enabled, newly created tokens start with auto instead of an empty group.": "如果启用默认 auto 分组,新建令牌会默认使用 auto,而不是空分组。",
|
||||
"If the affinity channel fails and retry succeeds on another channel, update affinity to the successful channel.": "如果亲和到的渠道失败,重试到其他渠道成功后,将亲和更新到成功的渠道。",
|
||||
"When enabled, keep the affinity entry even if the affinity channel is disabled or no longer usable for the current group/model. Leave it off to delete the entry and select another channel.": "开启后,亲和到的渠道被禁用,或不再适用于当前分组/模型时,仍保留这条亲和;关闭时会删除并重新选择渠道。",
|
||||
"If this keeps happening, please report it on GitHub Issues.": "如果问题持续出现,请到 GitHub Issues 反馈。",
|
||||
"If you provide generative AI services to the public in mainland China, you will fulfill legal obligations including filing, security assessment, content safety, complaint handling, generated content labeling, log retention, and personal information protection.": "如果你在中国大陆向公众提供生成式人工智能服务,你将履行备案、安全评估、内容安全、投诉处理、生成内容标识、日志留存和个人信息保护等法律义务。",
|
||||
"Ignored upstream models": "已忽略上游模型",
|
||||
|
||||
Reference in New Issue
Block a user