fix
Browse files- poster/poster.py +9 -8
poster/poster.py
CHANGED
@@ -5,6 +5,7 @@ import os
|
|
5 |
import re
|
6 |
import subprocess
|
7 |
import time
|
|
|
8 |
import cairosvg
|
9 |
from concurrent.futures import ThreadPoolExecutor
|
10 |
|
@@ -429,8 +430,8 @@ def generate_html_v2(vendor: str, model: str, poster: BaseModel, figures: list[s
|
|
429 |
|
430 |
# 初始生成两个HTML布局
|
431 |
prompt_inputs = [
|
432 |
-
{"style": style, "poster": poster},
|
433 |
-
{"style": style, "poster": poster}
|
434 |
]
|
435 |
|
436 |
with ThreadPoolExecutor(max_workers=2) as executor:
|
@@ -439,7 +440,7 @@ def generate_html_v2(vendor: str, model: str, poster: BaseModel, figures: list[s
|
|
439 |
# 检查初始生成的两个结果
|
440 |
for result in initial_results:
|
441 |
proportion = result["proportion"]
|
442 |
-
print(f"初始生成比例: {proportion:.0%}")
|
443 |
|
444 |
# 更新最佳结果
|
445 |
if proportion < min_proportion:
|
@@ -452,7 +453,7 @@ def generate_html_v2(vendor: str, model: str, poster: BaseModel, figures: list[s
|
|
452 |
|
453 |
# 如果找到满足条件的结果,直接返回
|
454 |
if proportion <= 0.1:
|
455 |
-
print(f"Initial generation successful, remaining {proportion:.0%} blank spaces.")
|
456 |
return {"html": result["html"], "html_with_figures": result["html_with_figures"]}
|
457 |
|
458 |
while True:
|
@@ -460,7 +461,7 @@ def generate_html_v2(vendor: str, model: str, poster: BaseModel, figures: list[s
|
|
460 |
if attempt > max_attempts:
|
461 |
if min_proportion <= 0.2:
|
462 |
print(
|
463 |
-
f"Reached max attempts ({max_attempts}), returning best result with {min_proportion:.0%} blank spaces."
|
464 |
)
|
465 |
return {"html": min_html, "html_with_figures": min_html_with_figures}
|
466 |
else:
|
@@ -494,7 +495,7 @@ Now there are {min_proportion:.0%} blank spaces. Please regenerate the content t
|
|
494 |
# 检查两个结果
|
495 |
for result in results:
|
496 |
proportion = result["proportion"]
|
497 |
-
print(f"当前比例: {proportion:.0%}")
|
498 |
|
499 |
# 更新最佳结果
|
500 |
if proportion < min_proportion:
|
@@ -508,7 +509,7 @@ Now there are {min_proportion:.0%} blank spaces. Please regenerate the content t
|
|
508 |
# 如果找到满足条件的结果,直接返回
|
509 |
if proportion <= 0.1:
|
510 |
print(
|
511 |
-
f"Attempted {attempt} times, remaining {proportion:.0%} blank spaces."
|
512 |
)
|
513 |
return {"html": result["html"], "html_with_figures": result["html_with_figures"]}
|
514 |
|
@@ -736,7 +737,7 @@ Paper content:
|
|
736 |
|
737 |
for result in results:
|
738 |
i = result["index"]
|
739 |
-
print(f"处理图片 {i} 完成")
|
740 |
figures_with_descriptions += f"""
|
741 |
<figure_{i}>
|
742 |
{result["description"]}
|
|
|
5 |
import re
|
6 |
import subprocess
|
7 |
import time
|
8 |
+
from datetime import datetime
|
9 |
import cairosvg
|
10 |
from concurrent.futures import ThreadPoolExecutor
|
11 |
|
|
|
430 |
|
431 |
# 初始生成两个HTML布局
|
432 |
prompt_inputs = [
|
433 |
+
{"style": style, "poster": poster, "react": []},
|
434 |
+
{"style": style, "poster": poster, "react": []}
|
435 |
]
|
436 |
|
437 |
with ThreadPoolExecutor(max_workers=2) as executor:
|
|
|
440 |
# 检查初始生成的两个结果
|
441 |
for result in initial_results:
|
442 |
proportion = result["proportion"]
|
443 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] 初始生成比例: {proportion:.0%}")
|
444 |
|
445 |
# 更新最佳结果
|
446 |
if proportion < min_proportion:
|
|
|
453 |
|
454 |
# 如果找到满足条件的结果,直接返回
|
455 |
if proportion <= 0.1:
|
456 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Initial generation successful, remaining {proportion:.0%} blank spaces.")
|
457 |
return {"html": result["html"], "html_with_figures": result["html_with_figures"]}
|
458 |
|
459 |
while True:
|
|
|
461 |
if attempt > max_attempts:
|
462 |
if min_proportion <= 0.2:
|
463 |
print(
|
464 |
+
f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Reached max attempts ({max_attempts}), returning best result with {min_proportion:.0%} blank spaces."
|
465 |
)
|
466 |
return {"html": min_html, "html_with_figures": min_html_with_figures}
|
467 |
else:
|
|
|
495 |
# 检查两个结果
|
496 |
for result in results:
|
497 |
proportion = result["proportion"]
|
498 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] 当前比例: {proportion:.0%}")
|
499 |
|
500 |
# 更新最佳结果
|
501 |
if proportion < min_proportion:
|
|
|
509 |
# 如果找到满足条件的结果,直接返回
|
510 |
if proportion <= 0.1:
|
511 |
print(
|
512 |
+
f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Attempted {attempt} times, remaining {proportion:.0%} blank spaces."
|
513 |
)
|
514 |
return {"html": result["html"], "html_with_figures": result["html_with_figures"]}
|
515 |
|
|
|
737 |
|
738 |
for result in results:
|
739 |
i = result["index"]
|
740 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] 处理图片 {i} 完成")
|
741 |
figures_with_descriptions += f"""
|
742 |
<figure_{i}>
|
743 |
{result["description"]}
|