MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / process_feedback

Function process_feedback

agents/feedback-agent/main.py:617–880  ·  view source on GitHub ↗

处理用户反馈 Args: user_id: 用户 ID push_id: 推送 ID(用于关联行为日志) reply: 用户回复文本 papers: 推送的论文列表 feishu_user_id: 飞书用户 ID(open_id) chat_id: 聊天 ID(优先使用,发送到原对话框) Returns: 处理结果

(
    user_id: str,
    push_id: str,
    reply: str,
    papers: List[Dict],
    feishu_user_id: Optional[str] = None,
    chat_id: Optional[str] = None,
    send_to_feishu: bool = True,
    auto_create_reports: Optional[bool] = None
)

Source from the content-addressed store, hash-verified

615def process_feedback(
616 user_id: str,
617 push_id: str,
618 reply: str,
619 papers: List[Dict],
620 feishu_user_id: Optional[str] = None,
621 chat_id: Optional[str] = None,
622 send_to_feishu: bool = True,
623 auto_create_reports: Optional[bool] = None
624) -> Dict[str, Any]:
625 """
626 处理用户反馈
627
628 Args:
629 user_id: 用户 ID
630 push_id: 推送 ID(用于关联行为日志)
631 reply: 用户回复文本
632 papers: 推送的论文列表
633 feishu_user_id: 飞书用户 ID(open_id)
634 chat_id: 聊天 ID(优先使用,发送到原对话框)
635
636 Returns:
637 处理结果
638 """
639 print(f"Processing feedback from user: {user_id}")
640 print(f"Reply: {reply}")
641
642 # 优先使用 chat_id,否则使用 feishu_user_id
643 target_id = chat_id or feishu_user_id
644 use_chat_id = chat_id is not None
645
646 # 1. 解析用户回复
647 parsed_selected = parse_user_reply(reply, papers)
648 reply_lower = reply.lower().strip()
649 is_none_command = reply_lower == "none"
650
651 if not parsed_selected and not is_none_command:
652 # 没有有效选择,发送提示
653 message = "未识别到有效的论文编号。请回复数字,如:1 2 4 6、1-5 8 10,或直接回复 none。"
654 if target_id and send_to_feishu:
655 send_text(target_id, message, use_chat_id=use_chat_id)
656 return {"status": "error", "message": message}
657
658 previously_selected = get_existing_selected_numbers(user_id, push_id, papers)
659 selected = set() if is_none_command else previously_selected | parsed_selected
660 newly_selected = set() if is_none_command else parsed_selected - previously_selected
661
662 print(f"Selected paper numbers: {sorted(selected)}")
663 if previously_selected:
664 print(f"Previously selected in this push: {sorted(previously_selected)}")
665 if newly_selected != parsed_selected:
666 print(f"Newly selected in this reply: {sorted(newly_selected)}")
667 current_timestamp = datetime.now()
668 feedback_strength_multiplier, feedback_latency_seconds = estimate_feedback_strength_multiplier(push_id, current_timestamp)
669 history_before_update = get_recent_selected_papers(
670 user_id,
671 limit=60,
672 days=60,
673 before_timestamp=current_timestamp.isoformat(sep=" "),
674 )

Callers 2

mainFunction · 0.85
main.pyFile · 0.85

Tested by

no test coverage detected