feat(market-intel): complete end-to-end audit with enhanced UX and grounding
- Integrated ICP-based lookalike sourcing. - Implemented Deep Tech Audit with automated evidence collection. - Enhanced processing terminal with real-time logs. - Refined daily logging and resolved all dependency issues. - Documented final status and next steps.
This commit is contained in:
@@ -63,13 +63,47 @@ export const generateSearchStrategy = async (
|
||||
}
|
||||
};
|
||||
|
||||
export const identifyCompetitors = async (referenceUrl: string, targetMarket: string, language: Language): Promise<Partial<Competitor>[]> => {
|
||||
// Dieser Teil muss noch im Python-Backend implementiert werden
|
||||
console.warn("identifyCompetitors ist noch nicht im Python-Backend implementiert.");
|
||||
return [
|
||||
{ id: "temp1", name: "Temp Competitor 1", description: "Temporär vom Frontend", url: "https://www.google.com" },
|
||||
{ id: "temp2", name: "Temp Competitor 2", description: "Temporär vom Frontend", url: "https://www.bing.com" },
|
||||
];
|
||||
// Helper to generate IDs
|
||||
const generateId = () => Math.random().toString(36).substr(2, 9);
|
||||
|
||||
export const identifyCompetitors = async (
|
||||
referenceUrl: string,
|
||||
targetMarket: string,
|
||||
contextContent: string,
|
||||
referenceCity?: string,
|
||||
referenceCountry?: string,
|
||||
summaryOfOffer?: string
|
||||
): Promise<{ localCompetitors: Competitor[], nationalCompetitors: Competitor[], internationalCompetitors: Competitor[] }> => {
|
||||
console.log("Frontend: identifyCompetitors API-Aufruf gestartet.");
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/identify-competitors`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ referenceUrl, targetMarket, contextContent, referenceCity, referenceCountry, summaryOfOffer }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
console.error(`Frontend: Backend-Fehler bei identifyCompetitors: ${errorData.error || response.statusText}`);
|
||||
throw new Error(`Backend-Fehler: ${errorData.error || response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log("Frontend: identifyCompetitors API-Aufruf erfolgreich. Empfangene Daten:", data);
|
||||
|
||||
const addIds = (comps: any[]) => (comps || []).map(c => ({ ...c, id: c.id || generateId() }));
|
||||
|
||||
return {
|
||||
localCompetitors: addIds(data.localCompetitors),
|
||||
nationalCompetitors: addIds(data.nationalCompetitors),
|
||||
internationalCompetitors: addIds(data.internationalCompetitors)
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Frontend: Konkurrenten-Identifikation über API Bridge fehlgeschlagen", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -80,19 +114,54 @@ export const analyzeCompanyWithStrategy = async (
|
||||
strategy: SearchStrategy,
|
||||
language: Language
|
||||
): Promise<AnalysisResult> => {
|
||||
// Dieser Teil muss noch im Python-Backend implementiert werden
|
||||
console.warn(`analyzeCompanyWithStrategy für ${companyName} ist noch nicht im Python-Backend implementiert.`);
|
||||
return {
|
||||
companyName,
|
||||
status: LeadStatus.UNKNOWN,
|
||||
revenue: "?",
|
||||
employees: "?",
|
||||
tier: Tier.TIER_3,
|
||||
dataSource: "Frontend Placeholder",
|
||||
dynamicAnalysis: {},
|
||||
recommendation: "Bitte im Backend implementieren",
|
||||
processingChecks: { wiki: false, revenue: false, signalsChecked: false }
|
||||
};
|
||||
console.log(`Frontend: Starte Audit für ${companyName}...`);
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/analyze-company`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
companyName,
|
||||
strategy,
|
||||
targetMarket: language === 'de' ? 'Germany' : 'USA' // Einfache Ableitung, kann verfeinert werden
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(`Backend-Fehler: ${errorData.error || response.statusText}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log(`Frontend: Audit für ${companyName} erfolgreich.`);
|
||||
return result as AnalysisResult;
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Frontend: Audit fehlgeschlagen für ${companyName}`, error);
|
||||
|
||||
// Fallback-Analyse erstellen, damit die UI nicht abstürzt
|
||||
const fallbackAnalysis: Record<string, { value: string; proof: string }> = {};
|
||||
if (strategy && strategy.signals) {
|
||||
strategy.signals.forEach(s => {
|
||||
fallbackAnalysis[s.id] = { value: "N/A (Error)", proof: "Audit failed" };
|
||||
});
|
||||
}
|
||||
|
||||
// Fallback-Objekt bei Fehler, damit der Prozess nicht komplett stoppt
|
||||
return {
|
||||
companyName,
|
||||
status: LeadStatus.UNKNOWN,
|
||||
revenue: "Error",
|
||||
employees: "Error",
|
||||
tier: Tier.TIER_3,
|
||||
dataSource: "Error",
|
||||
dynamicAnalysis: fallbackAnalysis,
|
||||
recommendation: "Fehler bei der Analyse: " + (error as Error).message,
|
||||
processingChecks: { wiki: false, revenue: false, signalsChecked: false }
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const generateOutreachCampaign = async (
|
||||
|
||||
Reference in New Issue
Block a user