feat(ca): Finalize v5 pipeline - Hybrid Matrix, CoT Enrichment & User Repair Mode

This commit is contained in:
2026-01-12 15:29:43 +00:00
parent b5e6c415c7
commit 70e689384e
15 changed files with 547 additions and 1224 deletions

View File

@@ -1,6 +1,6 @@
import React, { useState, useCallback, useEffect, useRef } from 'react';
import type { AppState, CompetitorCandidate, Product, TargetIndustry, Keyword, SilverBullet, Battlecard, ReferenceAnalysis } from './types';
import { fetchStep1Data, fetchStep2Data, fetchStep3Data, fetchStep4Data, fetchStep5Data_SilverBullets, fetchStep6Data_Conclusion, fetchStep7Data_Battlecards, fetchStep8Data_ReferenceAnalysis } from './services/geminiService';
import { fetchStep1Data, fetchStep2Data, fetchStep3Data, fetchStep4Data, fetchStep5Data_SilverBullets, fetchStep6Data_Conclusion, fetchStep7Data_Battlecards, fetchStep8Data_ReferenceAnalysis, reanalyzeCompetitor } from './services/geminiService';
import { generatePdfReport } from './services/pdfService';
import InputForm from './components/InputForm';
import StepIndicator from './components/StepIndicator';
@@ -91,6 +91,15 @@ const App: React.FC = () => {
}
}, []);
const handleUpdateAnalysis = useCallback((index: number, updatedAnalysis: any) => {
setAppState(prevState => {
if (!prevState) return null;
const newAnalyses = [...prevState.analyses];
newAnalyses[index] = updatedAnalysis;
return { ...prevState, analyses: newAnalyses };
});
}, []);
const handleConfirmStep = useCallback(async () => {
if (!appState) return;
@@ -112,7 +121,11 @@ const App: React.FC = () => {
case 3:
const shortlist = [...appState.competitor_candidates]
.sort((a, b) => b.confidence - a.confidence)
.slice(0, appState.initial_params.max_competitors);
.slice(0, appState.initial_params.max_competitors)
.map(c => ({
...c,
manual_urls: c.manual_urls ? c.manual_urls.split('\n').map(u => u.trim()).filter(u => u) : []
}));
const { analyses } = await fetchStep4Data(appState.company, shortlist, lang);
newState = { competitors_shortlist: shortlist, analyses, step: 4 };
break;
@@ -158,7 +171,7 @@ const App: React.FC = () => {
case 1: return <Step1Extraction products={appState.products} industries={appState.target_industries} onProductsChange={(p) => handleUpdateState('products', p)} onIndustriesChange={(i) => handleUpdateState('target_industries', i)} t={t.step1} lang={appState.initial_params.language} />;
case 2: return <Step2Keywords keywords={appState.keywords} onKeywordsChange={(k) => handleUpdateState('keywords', k)} t={t.step2} />;
case 3: return <Step3Competitors candidates={appState.competitor_candidates} onCandidatesChange={(c) => handleUpdateState('competitor_candidates', c)} maxCompetitors={appState.initial_params.max_competitors} t={t.step3} />;
case 4: return <Step4Analysis analyses={appState.analyses} t={t.step4} />;
case 4: return <Step4Analysis analyses={appState.analyses} company={appState.company} onAnalysisUpdate={handleUpdateAnalysis} t={t.step4} />;
case 5: return <Step5SilverBullets silver_bullets={appState.silver_bullets} t={t.step5} />;
case 6: return <Step6Conclusion appState={appState} t={t.step6} />;
case 7: return <Step7_Battlecards appState={appState} t={t.step7} />;