feat: 调整 AI 规格解析等待时间 (#286)

This commit is contained in:
chengma
2026-08-21 10:31:17 +08:00
parent 7d9d83d2fa
commit dc808e2a95
6 changed files with 8 additions and 7 deletions
+2 -1
View File
@@ -15,7 +15,8 @@ func TestAIConfigTemplate_密钥不回显且表单语义完整(t *testing.T) {
for _, want := range []string{ for _, want := range []string{
`action="/settings/ai/save"`, `action="/settings/ai/secret"`, `action="/settings/ai/save"`, `action="/settings/ai/secret"`,
`action="/settings/ai/test"`, `action="/settings/ai/enable"`, `action="/settings/ai/test"`, `action="/settings/ai/enable"`,
`type="password"`, `autocomplete="new-password"`, "连接测试", "置信度%", `type="password"`, `autocomplete="new-password"`, `name="timeout_seconds"`,
`min="1" max="120" value="66"`, "连接测试", "置信度%",
} { } {
if !strings.Contains(source, want) { if !strings.Contains(source, want) {
t.Errorf("AI 配置模板缺少 %q", want) t.Errorf("AI 配置模板缺少 %q", want)
+1 -1
View File
@@ -26,7 +26,7 @@ const (
MaxPurchaseSpecResolutionBodyBytes = 64 << 10 MaxPurchaseSpecResolutionBodyBytes = 64 << 10
PurchaseSpecRulesVersion = "purchase_rules_v1" PurchaseSpecRulesVersion = "purchase_rules_v1"
purchaseSpecSchemaVersion = 1 purchaseSpecSchemaVersion = 1
purchaseSpecResolutionAITimeout = 30 * time.Second purchaseSpecResolutionAITimeout = 66 * time.Second
) )
var ( var (
@@ -132,7 +132,7 @@ func (client *stubAIModelClient) Match(ctx context.Context, _ model.AIProviderCo
return client.response, client.err return client.response, client.err
} }
func TestMatchPurchaseSpecWithRuntimeAI_限制30秒并继承更早取消(t *testing.T) { func TestMatchPurchaseSpecWithRuntimeAI_限制66秒并继承更早取消(t *testing.T) {
req, _, _ := validRuntimeSpecRequest(t, "cg257-timeout", "L码", "M码", "XL码") req, _, _ := validRuntimeSpecRequest(t, "cg257-timeout", "L码", "M码", "XL码")
client := &runtimeDeadlineAIClient{} client := &runtimeDeadlineAIClient{}
loader := func(context.Context, *sql.DB, AISecretStore, AIEndpointPolicy) (AIMatchSnapshot, error) { loader := func(context.Context, *sql.DB, AISecretStore, AIEndpointPolicy) (AIMatchSnapshot, error) {
@@ -151,7 +151,7 @@ func TestMatchPurchaseSpecWithRuntimeAI_限制30秒并继承更早取消(t *test
t.Fatal("运行时 AI 上下文缺少截止时间") t.Fatal("运行时 AI 上下文缺少截止时间")
} }
budget := client.deadline.Sub(startedAt) budget := client.deadline.Sub(startedAt)
if budget < 29*time.Second || budget > purchaseSpecResolutionAITimeout { if budget < 65*time.Second || budget > purchaseSpecResolutionAITimeout {
t.Fatalf("运行时 AI 时间预算=%s,期望不超过 %s", budget, purchaseSpecResolutionAITimeout) t.Fatalf("运行时 AI 时间预算=%s,期望不超过 %s", budget, purchaseSpecResolutionAITimeout)
} }
+1 -1
View File
@@ -11,7 +11,7 @@
<label for="ai-model">模型</label> <label for="ai-model">模型</label>
<input id="ai-model" name="model" maxlength="191" required placeholder="模型名称"> <input id="ai-model" name="model" maxlength="191" required placeholder="模型名称">
<label for="ai-timeout">超时</label> <label for="ai-timeout">超时</label>
<input id="ai-timeout" class="input-short" name="timeout_seconds" type="number" min="1" max="120" value="30" required aria-describedby="ai-create-help"> <input id="ai-timeout" class="input-short" name="timeout_seconds" type="number" min="1" max="120" value="66" required aria-describedby="ai-create-help">
<label for="ai-concurrency">并发</label> <label for="ai-concurrency">并发</label>
<input id="ai-concurrency" class="input-short" name="max_concurrency" type="number" min="1" max="16" value="2" required> <input id="ai-concurrency" class="input-short" name="max_concurrency" type="number" min="1" max="16" value="2" required>
<label for="ai-threshold">置信度%</label> <label for="ai-threshold">置信度%</label>
+1 -1
View File
@@ -26,7 +26,7 @@ from .task_models import TaskType
DEFAULT_ADMIN_BASE_URL = "https://buy.833729.com" DEFAULT_ADMIN_BASE_URL = "https://buy.833729.com"
PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS = 60.0 PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS = 132.0
class HttpAdminGateway(AdminGateway): class HttpAdminGateway(AdminGateway):
+1 -1
View File
@@ -250,7 +250,7 @@ class HttpAdminGatewayTest(unittest.TestCase):
self.assertEqual( self.assertEqual(
opener.timeout, PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS opener.timeout, PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS
) )
self.assertEqual(PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS, 60.0) self.assertEqual(PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS, 132.0)
def test_resolve_purchase_spec_accepts_all_nonmatched_business_outcomes(self): def test_resolve_purchase_spec_accepts_all_nonmatched_business_outcomes(self):
for outcome in ("uncertain", "rejected", "failed"): for outcome in ("uncertain", "rejected", "failed"):