镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
新版HTML报告页面
这个提交包含在:
@@ -73,7 +73,7 @@ def produce_report_markdown(gpt_response_collection, meta, paper_meta_info, chat
|
||||
return res_path
|
||||
|
||||
def translate_pdf(article_dict, llm_kwargs, chatbot, fp, generated_conclusion_files, TOKEN_LIMIT_PER_FRAGMENT, DST_LANG):
|
||||
from crazy_functions.crazy_utils import construct_html
|
||||
from crazy_functions.pdf_fns.report_gen_html import construct_html
|
||||
from crazy_functions.crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
|
||||
from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
||||
from crazy_functions.crazy_utils import request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from toolbox import update_ui, get_conf, trimmed_format_exc, get_log_folder
|
||||
import os
|
||||
|
||||
|
||||
|
||||
|
||||
class construct_html():
|
||||
def __init__(self) -> None:
|
||||
self.html_string = ""
|
||||
|
||||
def add_row(self, a, b):
|
||||
from toolbox import markdown_convertion
|
||||
template = """
|
||||
{
|
||||
primary_col: {
|
||||
header: `__PRIMARY_HEADER__`,
|
||||
msg: `__PRIMARY_MSG__`,
|
||||
},
|
||||
secondary_rol: {
|
||||
header: `__SECONDARY_HEADER__`,
|
||||
msg: `__SECONDARY_MSG__`,
|
||||
}
|
||||
},
|
||||
"""
|
||||
template_ = template
|
||||
if len(a.split('\n')) == 1:
|
||||
template_ = template_.replace("__PRIMARY_HEADER__", markdown_convertion(a[:10]) + ' ...')
|
||||
template_ = template_.replace("__PRIMARY_MSG__", markdown_convertion(a))
|
||||
else:
|
||||
template_ = template_.replace("__PRIMARY_HEADER__", markdown_convertion(a.split('\n')[0]))
|
||||
template_ = template_.replace("__PRIMARY_MSG__", markdown_convertion('\n'.join(a.split('\n')[1:])))
|
||||
|
||||
if len(b.split('\n')) == 1:
|
||||
template_ = template_.replace("__SECONDARY_HEADER__", markdown_convertion(b[:10]) + ' ...')
|
||||
template_ = template_.replace("__SECONDARY_MSG__", markdown_convertion(b))
|
||||
else:
|
||||
template_ = template_.replace("__SECONDARY_HEADER__", markdown_convertion(b.split('\n')[0]))
|
||||
template_ = template_.replace("__SECONDARY_MSG__", markdown_convertion('\n'.join(b.split('\n')[1:])))
|
||||
self.html_string += template_
|
||||
|
||||
def save_file(self, file_name):
|
||||
from toolbox import get_log_folder
|
||||
with open('crazy_functions/pdf_fns/report_template.html', 'r', encoding='utf8') as f:
|
||||
html_template = f.read()
|
||||
html_template = html_template.replace("__TF_ARR__", self.html_string)
|
||||
with open(os.path.join(get_log_folder(), file_name), 'w', encoding='utf8') as f:
|
||||
f.write(html_template.encode('utf-8', 'ignore').decode())
|
||||
return os.path.join(get_log_folder(), file_name)
|
||||
文件差异因一行或多行过长而隐藏
在新工单中引用
屏蔽一个用户