瀏覽代碼

优化日志输出

chaixuhong 5 天之前
父節點
當前提交
ed8e67ea9c
共有 1 個文件被更改,包括 9 次插入11 次删除
  1. 9 11
      llmops/agents/data_stardard.py

+ 9 - 11
llmops/agents/data_stardard.py

@@ -63,11 +63,8 @@ class TransactionParserAgent:
             print(f"❌ MinerU 调用异常: {e}")
             return ""
         finally:
-            miner_end_time = time.perf_counter()
-            miner_elapsed_time = miner_end_time - miner_start_time
             print(f"✅ 【步骤1 - 数据提取】 执行完成")
-            print(f"⏱️  执行耗时:{miner_elapsed_time:.2f} 秒")
-            print("\n" + "=" * 40)
+            print(f"⏱️  执行耗时:{ time.perf_counter() - miner_start_time:.2f} 秒")
     def _get_csv_prompt_template(self) -> ChatPromptTemplate:
         """
         构造 LangChain 的 Prompt 模板
@@ -123,7 +120,8 @@ JSON Array:
             return ""
         # 记录开始时间(使用time.perf_counter获取高精度时间)
         switch_start_time = time.perf_counter()
-        print(f"-------【步骤2--标准化转换】开始-------")
+        print("\n" + "=" * 40)
+        print("📌 【步骤2 - 标准化转换】 开始执行")
         # 初步切分
         raw_lines = md_text.splitlines()
         # 提取真正的第一行作为基准表头
@@ -225,10 +223,9 @@ JSON Array:
             finally:
                 end_time = time.perf_counter()
                 elapsed_time = end_time - start_time
-                print(f"执行耗时: {elapsed_time:.2f} 秒")
-        switch_end_time = time.perf_counter()
-        switch_elapsed_time = switch_end_time - switch_start_time
-        print(f"-------【步骤2--标准化转换】结束-------共转换{global_tx_counter-1}条数据,总耗时: {switch_elapsed_time:.2f} 秒")
+                print(f"⏱️  执行耗时: {elapsed_time:.2f} 秒")
+        print(f"📊 转换结果:共转换 {global_tx_counter - 1} 条数据")
+        print(f"✅ 【步骤2 - 标准化转换】 执行完成")
         return csv_content
 
     async def parse_and_save_to_file(self, file_path: str, output_dir: str = "output") -> str:
@@ -282,7 +279,8 @@ JSON Array:
         finally:
             end_time = time.perf_counter()
             elapsed_time = end_time - start_time
-            print(f"END---数据标准化任务执行总耗时: {elapsed_time:.2f} 秒")
+            print(f"⏱️ 执行总耗时: {elapsed_time:.2f} 秒")
+            print(f"END---数据标准化任务结束")
 
 # --- 运行 ---
 async def main():
@@ -294,7 +292,7 @@ async def main():
     current_script_path = os.path.abspath(__file__)
     current_dir = os.path.dirname(current_script_path)
     # 模拟 Workflow 传入一个待处理文件
-    input_pdf = "data_files/1.pdf"
+    input_pdf = "data_files/11111.png"
     filepath = os.path.normpath(os.path.join(current_dir, "..", "..", input_pdf))
 
     if not os.path.exists(filepath):