This commit is contained in:
2026-09-27 23:06:24 +08:00
parent 2d4f9230b1
commit 22450e5bb3
40 changed files with 3040 additions and 697 deletions
+12 -11
View File
@@ -72,23 +72,24 @@ active_agents_per_round_max should be about {max(3, int(population * 0.4))}"""
if proposed_change:
user_prompt += f'\n\nPROPOSED CHANGE being introduced into this world:\n"{proposed_change}"'
response = await self.llm.generate(
system=system,
user=user_prompt,
json_mode=True,
max_tokens=3000,
)
response = await self.llm.generate(
system=system,
user=user_prompt,
json_mode=True,
max_tokens=3000,
purpose="world_gen",
)
data = parse_json(response)
data = parse_json(response, purpose="世界生成")
if not data:
logger.error("World generation produced empty result, using fallback")
logger.error("世界生成返回空结果,将使用备用世界")
return self._fallback_blueprint(rules_text, population, duration_days, proposed_change)
# Some LLMs occasionally return a list (e.g. citizens array) instead of
# a blueprint object. Wrap it defensively so the rest of the code keeps
# working.
if isinstance(data, list):
logger.warning("World blueprint came back as a list, treating as fallback")
logger.warning("世界蓝图返回了列表,将使用备用世界")
return self._fallback_blueprint(rules_text, population, duration_days, proposed_change)
try:
@@ -135,7 +136,7 @@ active_agents_per_round_max should be about {max(3, int(population * 0.4))}"""
time_config=time_config,
)
except Exception as e:
logger.error("Failed to parse world blueprint: %s", e)
logger.error("世界蓝图解析失败:%s", e)
return self._fallback_blueprint(rules_text, population, duration_days, proposed_change)
@staticmethod
@@ -209,4 +210,4 @@ active_agents_per_round_max should be about {max(3, int(population * 0.4))}"""
active_agents_per_round_min=3,
active_agents_per_round_max=max(3, int(population * 0.4)),
),
)
)