Spaces:
Sleeping
Sleeping
Update agents/graph_builder_langgraph.py
Browse files
agents/graph_builder_langgraph.py
CHANGED
|
@@ -91,24 +91,26 @@ async def node_repair(state: State, config=None, runtime=None) -> State:
|
|
| 91 |
|
| 92 |
|
| 93 |
async def node_report(state: State, config=None, runtime=None) -> State:
|
| 94 |
-
"""Generates a final UI report PDF and public link."""
|
| 95 |
html = state["html"]
|
| 96 |
session = uuid.uuid4().hex
|
| 97 |
out_dir = os.path.join("static", "outputs")
|
| 98 |
os.makedirs(out_dir, exist_ok=True)
|
|
|
|
| 99 |
html_path = os.path.join(out_dir, f"{session}.html")
|
| 100 |
with open(html_path, "w", encoding="utf-8") as f:
|
| 101 |
f.write(html)
|
| 102 |
|
| 103 |
-
#
|
| 104 |
-
base_url = os.environ.get("BASE_PUBLIC_URL", "")
|
| 105 |
if not base_url:
|
| 106 |
-
base_url = "https://dina1-mockup-agent.hf.space"
|
| 107 |
-
base_url = base_url.rstrip("/")
|
| 108 |
public_url = f"{base_url}/static/outputs/{session}.html"
|
| 109 |
|
| 110 |
pdf_info = await generate_pdf_report(public_url)
|
| 111 |
-
return {
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
|
| 114 |
# ==========================================================
|
|
|
|
| 91 |
|
| 92 |
|
| 93 |
async def node_report(state: State, config=None, runtime=None) -> State:
|
|
|
|
| 94 |
html = state["html"]
|
| 95 |
session = uuid.uuid4().hex
|
| 96 |
out_dir = os.path.join("static", "outputs")
|
| 97 |
os.makedirs(out_dir, exist_ok=True)
|
| 98 |
+
|
| 99 |
html_path = os.path.join(out_dir, f"{session}.html")
|
| 100 |
with open(html_path, "w", encoding="utf-8") as f:
|
| 101 |
f.write(html)
|
| 102 |
|
| 103 |
+
# --- FIX: ensure Playwright gets valid absolute URL ---
|
| 104 |
+
base_url = os.environ.get("BASE_PUBLIC_URL", "").rstrip("/")
|
| 105 |
if not base_url:
|
| 106 |
+
base_url = "https://dina1-mockup-agent.hf.space" # fallback for HF Space
|
|
|
|
| 107 |
public_url = f"{base_url}/static/outputs/{session}.html"
|
| 108 |
|
| 109 |
pdf_info = await generate_pdf_report(public_url)
|
| 110 |
+
return {
|
| 111 |
+
"pdf_path": pdf_info["pdf_path"],
|
| 112 |
+
"public_url": public_url,
|
| 113 |
+
}
|
| 114 |
|
| 115 |
|
| 116 |
# ==========================================================
|