diff --git a/backend/app/services/simulation_config_generator.py b/backend/app/services/simulation_config_generator.py index d49b2c01..0a2be807 100644 --- a/backend/app/services/simulation_config_generator.py +++ b/backend/app/services/simulation_config_generator.py @@ -293,7 +293,24 @@ class SimulationConfigGenerator: ) reasoning_parts = [] - + + # ========== 预过滤:排除非社交实体 ========== + NON_SOCIAL_ENTITY_TYPES = { + 'API', 'SDK', 'Database', 'WebServer', 'CloudService', 'CloudProvider', + 'Table', 'Module', 'ManagementBackend', 'SecurityMeasure', 'Condition', + 'PaymentTime', 'RiskLevel', 'CurrentStatus', 'Order', 'OrderDetail', + 'EnrollmentInfo', 'Software', 'Technology', 'ProcessManager', 'WebPage', + } + original_count = len(entities) + entities = [e for e in entities + if e.entity_type not in NON_SOCIAL_ENTITY_TYPES + and not any(kw in e.name for kw in ['GET /', 'POST /', 'PUT /', 'DELETE /', 'HTTPS API', 'JSAPI', 'INDEX(', 'Bearer token', 'Header(', 'Hero('])] + filtered_count = original_count - len(entities) + if filtered_count > 0: + logger.info(f"过滤非社交实体: {original_count} → {len(entities)} (排除 {filtered_count} 个技术/API实体)") + num_batches = math.ceil(len(entities) / self.AGENTS_PER_BATCH) + total_steps = 3 + num_batches + # ========== 步骤1: 生成时间配置 ========== report_progress(1, t('progress.generatingTimeConfig')) num_entities = len(entities) diff --git a/backend/scripts/run_parallel_simulation.py b/backend/scripts/run_parallel_simulation.py index e816c53c..e3bfccf0 100644 --- a/backend/scripts/run_parallel_simulation.py +++ b/backend/scripts/run_parallel_simulation.py @@ -1132,6 +1132,7 @@ async def run_twitter_simulation( # Twitter 使用通用 LLM 配置 model = create_model(config, use_boost=False) + simulation_semaphore = int(os.environ.get("SIMULATION_SEMAPHORE", "50")) # OASIS Twitter使用CSV格式 profile_path = os.path.join(simulation_dir, "twitter_profiles.csv") @@ -1160,7 +1161,7 @@ async def run_twitter_simulation( agent_graph=result.agent_graph, platform=oasis.DefaultPlatformType.TWITTER, database_path=db_path, - semaphore=30, # 限制最大并发 LLM 请求数,防止 API 过载(GLM RPM 友好值) + semaphore=simulation_semaphore, # 可通过 SIMULATION_SEMAPHORE 环境变量调整 ) await result.env.reset() @@ -1321,9 +1322,10 @@ async def run_reddit_simulation( print(f"[Reddit] {msg}") log_info("初始化...") - + # Reddit 使用加速 LLM 配置(如果有的话,否则回退到通用配置) model = create_model(config, use_boost=True) + reddit_semaphore = int(os.environ.get("SIMULATION_SEMAPHORE", "50")) profile_path = os.path.join(simulation_dir, "reddit_profiles.json") if not os.path.exists(profile_path): @@ -1351,7 +1353,7 @@ async def run_reddit_simulation( agent_graph=result.agent_graph, platform=oasis.DefaultPlatformType.REDDIT, database_path=db_path, - semaphore=30, # 限制最大并发 LLM 请求数,防止 API 过载(GLM RPM 友好值) + semaphore=reddit_semaphore, # 可通过 SIMULATION_SEMAPHORE 环境变量调整 ) await result.env.reset()