|
@@ -23,7 +23,7 @@ class Handler:
|
|
|
source_type: Optional[str],
|
|
|
source_channel: Optional[str]) -> Tuple[str, Tuple]:
|
|
|
"""构建查询条件和参数"""
|
|
|
- conditions = ["formatted_content is not null", "multimodal_recognition is null"]
|
|
|
+ conditions = ["multimodal_recognition is not null", "structured_data is null"]
|
|
|
params = []
|
|
|
|
|
|
if query_word is not None:
|
|
@@ -50,7 +50,7 @@ class Handler:
|
|
|
# 构建查询条件和参数
|
|
|
where_clause, params = self.build_query_conditions(query_word, source_type, source_channel)
|
|
|
sql = f"""
|
|
|
- SELECT id, formatted_content
|
|
|
+ SELECT id, multimodal_recognition
|
|
|
FROM knowledge_search_content
|
|
|
WHERE {where_clause}
|
|
|
"""
|
|
@@ -65,26 +65,31 @@ class Handler:
|
|
|
try:
|
|
|
# 处理内容
|
|
|
result = self.processor.process(row[1], self.system_prompt)
|
|
|
-
|
|
|
+
|
|
|
+ print(result)
|
|
|
+
|
|
|
# 更新数据库
|
|
|
update_sql = """
|
|
|
UPDATE knowledge_search_content
|
|
|
- SET multimodal_recognition = %s
|
|
|
+ SET structured_data = %s
|
|
|
WHERE id = %s
|
|
|
"""
|
|
|
- MysqlHelper.update_values(update_sql, (result, row[0]))
|
|
|
-
|
|
|
- # 添加延迟避免API限制
|
|
|
- time.sleep(1)
|
|
|
+
|
|
|
+ affected_rows = MysqlHelper.update_values(update_sql, (result, row[0]))
|
|
|
+
|
|
|
+
|
|
|
total_success += 1
|
|
|
+
|
|
|
+ # 添加延迟避免API限制
|
|
|
+ time.sleep(5)
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"处理记录 {row[0]} 失败: {str(e)}")
|
|
|
+ finally:
|
|
|
+ print(f"处理完成!总数据量 {len(records)},已处理 {total_processed} ,成功 {total_success} ")
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"处理过程中发生错误: {str(e)}")
|
|
|
- finally:
|
|
|
- print(f"处理完成!总共处理 {total_processed} 条记录,成功 {total_success} 条")
|
|
|
|
|
|
|
|
|
def main():
|