Skip to content

Commit

Permalink
fix html_file_path bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LiChengxin007 committed Feb 6, 2024
1 parent b5c9afd commit 729ba4b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ai/backend/aidb/autopilot/autopilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import os


class Autopilot(AIDB):
def get_agent_user_proxy(self):
""" Human Proxy """
Expand Down Expand Up @@ -154,12 +155,13 @@ def generate_report_template(self, data):
data['report_thought'].remove(item)

# 获取当前工作目录的路径
current_directory = CONFIG.up_file_path
current_directory = CONFIG.up_file_path

# 构建路径时使用 os.path.join,并使用 os.path.normpath 进行规范化
html_template_path = os.path.join(os.path.normpath(current_directory.replace('user_upload_files', '')), 'ai', 'backend', 'aidb', 'autopilot')
html_template_path = os.path.join(os.path.normpath(current_directory.replace('user_upload_files', '')), 'ai',
'backend', 'aidb', 'autopilot')
html_template_path = html_template_path.replace('\\', '/')
html_file_path = os.path.normpath(html_file_path)
# html_file_path = os.path.normpath(html_file_path)

if CONFIG.web_language == 'CN':
html_template_path = os.path.join(html_template_path, 'html_template')
Expand All @@ -174,7 +176,7 @@ def generate_report_template(self, data):

print('html_template_path:', html_template_path)
print('template_str:', template_str)
# print('template_str :', template_str)
# print('template_str :', template_str)

# 使用Jinja2渲染模板
timestamp = int(time.time() * 1000)
Expand All @@ -183,7 +185,7 @@ def generate_report_template(self, data):
# print('rendered_html : ', rendered_html)

# 将渲染后的HTML写入文件
with open(CONFIG.up_file_path + 'output_' + str(timestamp) + '.html', 'w',encoding='utf-8') as output_file:
with open(CONFIG.up_file_path + 'output_' + str(timestamp) + '.html', 'w', encoding='utf-8') as output_file:
output_file.write(rendered_html)

print("HTML文件已生成:output.html")
Expand Down

0 comments on commit 729ba4b

Please sign in to comment.