import asyncio import json import os import sys # Path to the orchestrator sys.path.append(os.path.join(os.getcwd(), 'competitor-analysis-app')) from competitor_analysis_orchestrator import analyze_single_competitor_references async def refresh_references(): json_path = 'analysis_robo-planet.de.json' with open(json_path, 'r') as f: data = json.load(f) competitors = data.get('competitors_shortlist', []) if not competitors: competitors = data.get('competitor_candidates', []) print(f"Refreshing references for {len(competitors)} competitors...") tasks = [analyze_single_competitor_references(c) for c in competitors] results = await asyncio.gather(*tasks) # Filter and update data['reference_analysis'] = [r for r in results if r is not None] with open(json_path, 'w') as f: json.dump(data, f, indent=2) print(f"Successfully updated {json_path} with grounded reference data.") if __name__ == "__main__": asyncio.run(refresh_references())