Refactor content handling in activity logging and simulation scripts
- Removed content truncation logic from the AgentActivity class, allowing full content to be logged for posts, comments, and quotes. - Updated the `fetch_new_actions_from_db` function to retain complete content in action arguments, enhancing data accuracy. - Adjusted simulation scripts to ensure that full content is sent during action creation, improving the representation of agent activities.
This commit is contained in:
parent
e9b49e38bf
commit
29bff9ca27
2 changed files with 5 additions and 12 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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 += 1
|
||||
initial_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 += 1
|
||||
initial_action_count += 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue