fix(features): 功能开放 - 兼容历史系统代理任务并修正前端格式
This commit is contained in:
@@ -89,6 +89,13 @@ func TestCustomChannelTaskInputRequiresFeature(t *testing.T) {
|
||||
if err := svc.requireCustomChannelsForTaskInput(systemInput); err != nil {
|
||||
t.Fatalf("system channel task error = %v", err)
|
||||
}
|
||||
legacySystemInput, err := normalizeTaskInput(map[string]any{"config": providerConfig{BaseURL: "/api/ai/system/system-1", APIKey: "system", Model: "text-model"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := svc.requireCustomChannelsForTaskInput(legacySystemInput); err != nil {
|
||||
t.Fatalf("legacy system proxy task error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskBillingOrderSkipsPricingWhenCreditsDisabled(t *testing.T) {
|
||||
|
||||
@@ -416,7 +416,10 @@ func taskInputUsesCustomChannel(input map[string]any) bool {
|
||||
channelID, _ := config["channelId"].(string)
|
||||
baseURL, _ := config["baseUrl"].(string)
|
||||
apiKey, _ := config["apiKey"].(string)
|
||||
return strings.TrimSpace(channelID) == "" && strings.TrimSpace(baseURL) != "" && strings.TrimSpace(apiKey) != ""
|
||||
if strings.TrimSpace(channelID) != "" || systemChannelIDFromBaseURL(baseURL) != "" {
|
||||
return false
|
||||
}
|
||||
return strings.TrimSpace(baseURL) != "" && strings.TrimSpace(apiKey) != ""
|
||||
}
|
||||
|
||||
func compactPersistedValue(value interface{}) interface{} {
|
||||
|
||||
@@ -349,10 +349,7 @@ export function useEffectiveConfig() {
|
||||
const customChannelsEnabled = useUserStore((state) => state.features.customChannelsEnabled);
|
||||
const catalogState = useLocalDreaminaModelStore((state) => state.state);
|
||||
const dreaminaModels = useLocalDreaminaModelStore((state) => state.models);
|
||||
return useMemo(
|
||||
() => effectiveConfigWithDreamina(effectiveConfigForCustomChannels(config, customChannelsEnabled), catalogState, dreaminaModels),
|
||||
[catalogState, config, customChannelsEnabled, dreaminaModels],
|
||||
);
|
||||
return useMemo(() => effectiveConfigWithDreamina(effectiveConfigForCustomChannels(config, customChannelsEnabled), catalogState, dreaminaModels), [catalogState, config, customChannelsEnabled, dreaminaModels]);
|
||||
}
|
||||
|
||||
export function effectiveConfigForCustomChannels(config: AiConfig, customChannelsEnabled: boolean): AiConfig {
|
||||
|
||||
@@ -218,7 +218,15 @@ test("effective config removes custom channels when administrators disable them"
|
||||
const config = normalizeConfigSnapshot({
|
||||
config: {
|
||||
channels: [
|
||||
createModelChannel({ id: "system-1", scope: "system", name: "系统渠道", baseUrl: "/api/ai/system/system-1", apiKey: "system", models: ["system-model"], modelCosts: [{ model: "system-model", capability: "text", billingMode: "fixed_request", unitPriceMicrocredits: 0 }] }),
|
||||
createModelChannel({
|
||||
id: "system-1",
|
||||
scope: "system",
|
||||
name: "系统渠道",
|
||||
baseUrl: "/api/ai/system/system-1",
|
||||
apiKey: "system",
|
||||
models: ["system-model"],
|
||||
modelCosts: [{ model: "system-model", capability: "text", billingMode: "fixed_request", unitPriceMicrocredits: 0 }],
|
||||
}),
|
||||
createModelChannel({ id: "custom-1", scope: "user", name: "自定义渠道", baseUrl: "https://example.com", apiKey: "private-key", models: ["custom-model"] }),
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user