import gradio as gr import json from engine import final_process_eme_technical_guided def parse_energy_plan_ui(text_input): """Hàm xử lý logic trích xuất dữ liệu""" if not text_input or not text_input.strip(): return json.dumps({"error": "Input không được để trống"}, indent=2, ensure_ascii=False) try: # Xử lý input đầu vào final_input = text_input.strip() # Gọi engine xử lý (đảm bảo engine.py không chứa code nặng ở global) result = final_process_eme_technical_guided(final_input) # Chuyển đổi kết quả sang dict result_dict = result.model_dump() if hasattr(result, "model_dump") else result return json.dumps(result_dict, indent=2, ensure_ascii=False) except Exception as e: return json.dumps({"error": str(e)}, indent=2, ensure_ascii=False) # Tạo giao diện with gr.Blocks(theme=gr.themes.Soft(primary_hue="yellow", secondary_hue="amber"), title="Volta Parser") as demo: gr.HTML("""
Dán JSON hợp đồng điện để trích xuất dữ liệu chi tiết