Spaces:
Sleeping
Sleeping
Toan2004-ai commited on
Commit ·
4eecb7b
1
Parent(s): aa6b9c9
add readme config
Browse files
app.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
-
from engine import final_process_eme_technical_guided
|
| 5 |
|
| 6 |
def parse_energy_plan(text_input):
|
|
|
|
|
|
|
| 7 |
if not text_input or not text_input.strip():
|
| 8 |
return json.dumps({"error": "Đầu vào không được để trống"}, indent=2)
|
| 9 |
|
|
@@ -15,12 +16,11 @@ def parse_energy_plan(text_input):
|
|
| 15 |
if isinstance(parsed_json, dict) and "instances" in parsed_json:
|
| 16 |
final_input = parsed_json["instances"][0].get("raw_text", text_input)
|
| 17 |
else:
|
| 18 |
-
final_input = json.dumps(parsed_json)
|
| 19 |
except json.JSONDecodeError:
|
| 20 |
final_input = text_input
|
| 21 |
|
| 22 |
result = final_process_eme_technical_guided(final_input)
|
| 23 |
-
|
| 24 |
result_dict = result.model_dump() if hasattr(result, "model_dump") else result
|
| 25 |
return json.dumps(result_dict, indent=2, ensure_ascii=False)
|
| 26 |
|
|
@@ -29,11 +29,7 @@ def parse_energy_plan(text_input):
|
|
| 29 |
|
| 30 |
demo = gr.Interface(
|
| 31 |
fn=parse_energy_plan,
|
| 32 |
-
inputs=gr.Textbox(
|
| 33 |
-
label="Energy Plan Input",
|
| 34 |
-
placeholder="Dán dữ liệu đầu vào tại đây...",
|
| 35 |
-
lines=10
|
| 36 |
-
),
|
| 37 |
outputs=gr.Code(label="Extracted Schema", language="json"),
|
| 38 |
title="Volta Energy Plan Parser",
|
| 39 |
description="Giao diện kiểm thử trích xuất dữ liệu năng lượng."
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
import os
|
|
|
|
| 4 |
|
| 5 |
def parse_energy_plan(text_input):
|
| 6 |
+
from engine import final_process_eme_technical_guided
|
| 7 |
+
|
| 8 |
if not text_input or not text_input.strip():
|
| 9 |
return json.dumps({"error": "Đầu vào không được để trống"}, indent=2)
|
| 10 |
|
|
|
|
| 16 |
if isinstance(parsed_json, dict) and "instances" in parsed_json:
|
| 17 |
final_input = parsed_json["instances"][0].get("raw_text", text_input)
|
| 18 |
else:
|
| 19 |
+
final_input = json.dumps(parsed_json)
|
| 20 |
except json.JSONDecodeError:
|
| 21 |
final_input = text_input
|
| 22 |
|
| 23 |
result = final_process_eme_technical_guided(final_input)
|
|
|
|
| 24 |
result_dict = result.model_dump() if hasattr(result, "model_dump") else result
|
| 25 |
return json.dumps(result_dict, indent=2, ensure_ascii=False)
|
| 26 |
|
|
|
|
| 29 |
|
| 30 |
demo = gr.Interface(
|
| 31 |
fn=parse_energy_plan,
|
| 32 |
+
inputs=gr.Textbox(label="Energy Plan Input", placeholder="Dán dữ liệu đầu vào tại đây...", lines=10),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
outputs=gr.Code(label="Extracted Schema", language="json"),
|
| 34 |
title="Volta Energy Plan Parser",
|
| 35 |
description="Giao diện kiểm thử trích xuất dữ liệu năng lượng."
|