diff --git a/furniture-3d-system/.env.example b/furniture-3d-system/.env.example index 0cb5c7c1..4433026c 100644 --- a/furniture-3d-system/.env.example +++ b/furniture-3d-system/.env.example @@ -97,6 +97,7 @@ BOM_COSTING_MARKET_TIMEOUT_MS=60000 BOM_COSTING_AI_TIMEOUT_MS=300000 BOM_COSTING_AI_MAX_IMAGES=20 BOM_COSTING_AI_MAX_TOKENS=24000 +BOM_COSTING_AI_REASONING_EFFORT=low BOM_COSTING_MODELING_PROVIDER= # 素材库白底图回传 diff --git a/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-analyzer.test.ts b/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-analyzer.test.ts index 44666e46..27339ed6 100644 --- a/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-analyzer.test.ts +++ b/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-analyzer.test.ts @@ -228,7 +228,7 @@ describe('BOM 多模态分析器', () => { name: '多模态模型', baseUrl: 'https://ai.example.com/v1', apiKey: 'test-ai-key', - model: 'vision-model', + model: 'gpt-5.6-luna', extra: null, isActive: true, sortOrder: 0, @@ -710,6 +710,9 @@ describe('BOM 多模态分析器', () => { message.content.some((content) => content.type === 'image_url'), ), ).toBe(false) + expect(requestBody).toMatchObject({ + reasoning_effort: 'low', + }) expect(output.trace).toMatchObject({ imageCount: 4, factBatchCount: 0, diff --git a/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-gateway.ts b/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-gateway.ts index fdc5b62c..4e082c0d 100644 --- a/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-gateway.ts +++ b/furniture-3d-system/src/server/services/bom-costing/bom-costing-multimodal-gateway.ts @@ -28,6 +28,13 @@ export interface BomCostingMultimodalCallResult { export type BomCostingMultimodalOperation = 'IMAGE_FACTS' | 'SYNTHESIS' +const BOM_COSTING_REASONING_EFFORTS = new Set([ + 'minimal', + 'low', + 'medium', + 'high', +]) + export function readBomCostingBoundedInteger( value: string | undefined, fallback: number, @@ -44,6 +51,20 @@ function getAiServiceType() { return process.env.BOM_COSTING_AI_SERVICE_TYPE?.trim() || 'prompt-optimizer' } +function getBomCostingReasoningEffort(model: string) { + const configured = process.env.BOM_COSTING_AI_REASONING_EFFORT + ?.trim() + .toLowerCase() + if (configured && BOM_COSTING_REASONING_EFFORTS.has(configured)) { + return configured + } + + // The configured GPT-5-compatible gateway terminates long, non-streaming + // reasoning around two minutes. BOM synthesis is structured extraction, not + // an open-ended reasoning task, so keep the default response bounded. + return /^gpt-5(?:[.-]|$)/i.test(model) ? 'low' : undefined +} + export async function getBomCostingMultimodalProviderConfig(): Promise { const active = await providerConfigService.getActive(getAiServiceType()) @@ -280,6 +301,7 @@ export async function callBomCostingMultimodalModel(input: { timeoutMs: number }): Promise { const endpoint = `${input.config.baseUrl.replace(/\/+$/, '')}/chat/completions` + const reasoningEffort = getBomCostingReasoningEffort(input.config.model) const startedAt = Date.now() let response: Response try { @@ -299,6 +321,7 @@ export async function callBomCostingMultimodalModel(input: { temperature: 0.1, max_tokens: input.maxTokens, stream: true, + ...(reasoningEffort ? { reasoning_effort: reasoningEffort } : {}), }), cache: 'no-store', signal: AbortSignal.timeout(input.timeoutMs),