A Simple and Universal Swarm Intelligence Engine, Predicting Anything. 简洁通用的群体智能引擎,预测万物
Python agent-memoryfinancial-forecastingfuture-predictionknowledge-graphllmsmulti-agent-simulationpublic-opinion-analysispython3social-predictionswarm-intelligence
Refactor content handling in activity logging and simulation scripts
666ghj29bff9ca270d
diff --git a/backend/app/services/zep_graph_memory_updater.py b/backend/app/services/zep_graph_memory_updater.pyindex b73b8f12..fff50572 100644--- a/backend/app/services/zep_graph_memory_updater.py+++ b/backend/app/services/zep_graph_memory_updater.py@@ -63,9 +63,6 @@ class AgentActivity:def _describe_create_post(self) -> str:content = self.action_args.get("content", "")if content:- # 截取内容,避免过长- if len(content) > 300:- content = content[:300] + "..."return f"发布了一条帖子:「{content}」"return "发布了一条帖子"@@ -86,7 +83,7 @@ class AgentActivity:content = self.action_args.get("content", "")if quoted_id:if content:- return f"引用帖子#{quoted_id}并评论:「{content[:100]}{'...' if len(content) > 100 else ''}」"+ return f"引用帖子#{quoted_id}并评论:「{content}」"return f"引用了帖子#{quoted_id}"return "引用了一条帖子"@@ -98,8 +95,6 @@ class AgentActivity:content = self.action_args.get("content", "")post_id = self.action_args.get("post_id", "")if content:- if len(content) > 200:- content = content[:200] + "..."base = f"评论道:「{content}」"if post_id:base = f"在帖子#{post_id}下{base}"diff --git a/backend/scripts/run_parallel_simulation.py b/backend/scripts/run_parallel_simulation.pyindex 9277abab..17026565 100644--- a/backend/scripts/run_parallel_simulation.py+++ b/backend/scripts/run_parallel_simulation.py@@ -251,12 +251,10 @@ def fetch_new_actions_from_db(except json.JSONDecodeError:action_args = {}- # 精简 action_args,只保留关键字段+ # 精简 action_args,只保留关键字段(保留完整内容,不截断)simplified_args = {}if 'content' in action_args:- content = action_args['content']- # 截断过长的内容- simplified_args['content'] = content[:200] + '...' if len(content) > 200 else content+ simplified_args['content'] = action_args['content']if 'post_id' in action_args:simplified_args['post_id'] = action_args['post_id']if 'comment_id' in action_args:@@ -492,7 +490,7 @@ async def run_twitter_simulation(agent_id=agent_id,agent_name=agent_names.get(agent_id, f"Agent_{agent_id}"),action_type="CREATE_POST",- action_args={"content": content[:100] + "..." if len(content) > 100 else content}+ action_args={"content": content})total_actions += 1initial_action_count += 1@@ -677,7 +675,7 @@ async def run_reddit_simulation(agent_id=agent_id,agent_name=agent_names.get(agent_id, f"Agent_{agent_id}"),action_type="CREATE_POST",- action_args={"content": content[:100] + "..." if len(content) > 100 else content}+ action_args={"content": content})total_actions += 1initial_action_count += 1