Browse Source

过滤已处理的条目

jihuaqiang 5 days ago
parent
commit
6d650c165b
2 changed files with 11 additions and 0 deletions
  1. 9 0
      agent.py
  2. 2 0
      agents/expand_agent/agent.py

+ 9 - 0
agent.py

@@ -177,6 +177,15 @@ def create_langgraph_workflow():
                     crawl_data = item.get('crawl_data') or {}
                     content_id = item.get('content_id') or ''
                     task_id = item.get('task_id') or ''
+
+                    # 先在库中查询是否已经处理过
+                    check_sql = "SELECT id,status FROM knowledge_parsing_content WHERE request_id = %s AND content_id = %s"
+                    check_result = MysqlHelper.get_values(check_sql, (state["request_id"], content_id))
+                    if check_result:
+                        id, status = check_result[0]
+                        if status == 5:
+                            success_count += 1
+                            continue
                     
                     # Step 1: 识别
                     identify_result = identify_tool.run(

+ 2 - 0
agents/expand_agent/agent.py

@@ -174,6 +174,8 @@ def execute_expand_agent_with_api(requestId: str, query: str = "") -> Dict[str,
             """
             for sample in data_samples:
                 total += 1
+                if not sample:
+                    continue
                 prompt = _build_prompt(sample, query)
                 expanded = _run_llm(prompt)
                 if not expanded: