|
@@ -687,8 +687,8 @@ HTML_TEMPLATE = """<!DOCTYPE html>
|
|
|
|
|
|
|
|
.modal-images-grid {
|
|
.modal-images-grid {
|
|
|
display: grid;
|
|
display: grid;
|
|
|
- grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
|
|
|
- gap: 15px;
|
|
|
|
|
|
|
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
|
|
|
+ gap: 12px;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.modal-image-item {
|
|
.modal-image-item {
|
|
@@ -696,6 +696,7 @@ HTML_TEMPLATE = """<!DOCTYPE html>
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
|
border: 2px solid #e5e7eb;
|
|
border: 2px solid #e5e7eb;
|
|
|
transition: border-color 0.2s;
|
|
transition: border-color 0.2s;
|
|
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.modal-image-item:hover {
|
|
.modal-image-item:hover {
|
|
@@ -706,6 +707,8 @@ HTML_TEMPLATE = """<!DOCTYPE html>
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
height: auto;
|
|
height: auto;
|
|
|
display: block;
|
|
display: block;
|
|
|
|
|
+ max-height: 250px;
|
|
|
|
|
+ object-fit: cover;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.modal-section {
|
|
.modal-section {
|
|
@@ -1150,9 +1153,15 @@ def build_post_json_data(note, evaluation=None):
|
|
|
|
|
|
|
|
image_list = note.get('image_list', [])
|
|
image_list = note.get('image_list', [])
|
|
|
if not image_list and note.get('cover_image'):
|
|
if not image_list and note.get('cover_image'):
|
|
|
- image_list = [note.get('cover_image')]
|
|
|
|
|
|
|
+ cover = note.get('cover_image')
|
|
|
|
|
+ # cover_image 可能是字典或字符串
|
|
|
|
|
+ if isinstance(cover, dict):
|
|
|
|
|
+ image_list = [cover.get('image_url', '')]
|
|
|
|
|
+ else:
|
|
|
|
|
+ image_list = [cover]
|
|
|
|
|
|
|
|
- images = [img.get('image_url', '') for img in image_list if img.get('image_url')]
|
|
|
|
|
|
|
+ # image_list 现在已经是 URL 字符串列表(由搜索API预处理)
|
|
|
|
|
+ images = [img if isinstance(img, str) else img.get('image_url', '') for img in image_list if img]
|
|
|
|
|
|
|
|
interact = note.get('interact_info', {})
|
|
interact = note.get('interact_info', {})
|
|
|
user = note.get('user', {})
|
|
user = note.get('user', {})
|
|
@@ -1406,16 +1415,20 @@ def render_search_results(step):
|
|
|
# 渲染该query的帖子
|
|
# 渲染该query的帖子
|
|
|
posts_cards = ""
|
|
posts_cards = ""
|
|
|
for note in notes_summary:
|
|
for note in notes_summary:
|
|
|
- cover = note.get("cover_image", {})
|
|
|
|
|
- cover_url = cover.get("image_url", "") if cover else ""
|
|
|
|
|
|
|
+ # 获取封面图
|
|
|
|
|
+ image_list = note.get('image_list', [])
|
|
|
|
|
+ if image_list:
|
|
|
|
|
+ # image_list 已经是 URL 字符串列表,第一张就是封面
|
|
|
|
|
+ cover_url = image_list[0] if isinstance(image_list[0], str) else image_list[0].get('image_url', '')
|
|
|
|
|
+ else:
|
|
|
|
|
+ cover = note.get("cover_image", {})
|
|
|
|
|
+ cover_url = cover.get("image_url", "") if isinstance(cover, dict) else cover if cover else ""
|
|
|
|
|
+
|
|
|
interact = note.get("interact_info", {})
|
|
interact = note.get("interact_info", {})
|
|
|
user = note.get("user", {})
|
|
user = note.get("user", {})
|
|
|
|
|
|
|
|
- # 获取所有图片用于轮播
|
|
|
|
|
- image_list = note.get('image_list', [])
|
|
|
|
|
- if not image_list and cover:
|
|
|
|
|
- image_list = [cover]
|
|
|
|
|
- images = [img.get('image_url', '') for img in image_list if img.get('image_url')]
|
|
|
|
|
|
|
+ # image_list 现在已经是 URL 字符串列表
|
|
|
|
|
+ images = [img if isinstance(img, str) else img.get('image_url', '') for img in image_list if img]
|
|
|
|
|
|
|
|
# 构建帖子数据用于模态框
|
|
# 构建帖子数据用于模态框
|
|
|
post_data = build_post_json_data(note)
|
|
post_data = build_post_json_data(note)
|
|
@@ -1507,18 +1520,21 @@ def render_note_evaluations(step):
|
|
|
# 渲染满足需求的帖子
|
|
# 渲染满足需求的帖子
|
|
|
satisfied_cards = ""
|
|
satisfied_cards = ""
|
|
|
for note in satisfied_notes:
|
|
for note in satisfied_notes:
|
|
|
- cover = note.get("cover_image", {})
|
|
|
|
|
- cover_url = cover.get("image_url", "") if cover else ""
|
|
|
|
|
|
|
+ # 获取封面图
|
|
|
|
|
+ image_list = note.get('image_list', [])
|
|
|
|
|
+ if image_list:
|
|
|
|
|
+ cover_url = image_list[0] if isinstance(image_list[0], str) else image_list[0].get('image_url', '')
|
|
|
|
|
+ else:
|
|
|
|
|
+ cover = note.get("cover_image", {})
|
|
|
|
|
+ cover_url = cover.get("image_url", "") if isinstance(cover, dict) else cover if cover else ""
|
|
|
|
|
+
|
|
|
interact = note.get("interact_info", {})
|
|
interact = note.get("interact_info", {})
|
|
|
user = note.get("user", {})
|
|
user = note.get("user", {})
|
|
|
evaluation = note.get("evaluation", {})
|
|
evaluation = note.get("evaluation", {})
|
|
|
confidence = evaluation.get("confidence_score", 0)
|
|
confidence = evaluation.get("confidence_score", 0)
|
|
|
|
|
|
|
|
- # 获取所有图片用于轮播
|
|
|
|
|
- image_list = note.get('image_list', [])
|
|
|
|
|
- if not image_list and cover:
|
|
|
|
|
- image_list = [cover]
|
|
|
|
|
- images = [img.get('image_url', '') for img in image_list if img.get('image_url')]
|
|
|
|
|
|
|
+ # image_list 现在已经是 URL 字符串列表
|
|
|
|
|
+ images = [img if isinstance(img, str) else img.get('image_url', '') for img in image_list if img]
|
|
|
|
|
|
|
|
# 构建帖子数据用于模态框
|
|
# 构建帖子数据用于模态框
|
|
|
post_data = build_post_json_data(note, evaluation)
|
|
post_data = build_post_json_data(note, evaluation)
|
|
@@ -1544,16 +1560,7 @@ def render_note_evaluations(step):
|
|
|
title_rel = evaluation.get("title_relevance", 0)
|
|
title_rel = evaluation.get("title_relevance", 0)
|
|
|
content_exp = evaluation.get("content_expectation", 0)
|
|
content_exp = evaluation.get("content_expectation", 0)
|
|
|
|
|
|
|
|
- eval_details = f"""
|
|
|
|
|
- <div class="evaluation-reason">
|
|
|
|
|
- <strong>💡 评估理由:</strong><br>
|
|
|
|
|
- {eval_reason}
|
|
|
|
|
- <div class="evaluation-scores">
|
|
|
|
|
- <span class="score-item">📌 标题相关性: {title_rel:.2f}</span>
|
|
|
|
|
- <span class="score-item">📄 内容期望: {content_exp:.2f}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- """ if eval_reason else ""
|
|
|
|
|
|
|
+ eval_details = ""
|
|
|
|
|
|
|
|
# 置信度百分比
|
|
# 置信度百分比
|
|
|
confidence_percent = int(confidence * 100)
|
|
confidence_percent = int(confidence * 100)
|
|
@@ -1588,17 +1595,21 @@ def render_note_evaluations(step):
|
|
|
# 渲染不满足需求的帖子
|
|
# 渲染不满足需求的帖子
|
|
|
unsatisfied_cards = ""
|
|
unsatisfied_cards = ""
|
|
|
for note in unsatisfied_notes:
|
|
for note in unsatisfied_notes:
|
|
|
- cover = note.get("cover_image", {})
|
|
|
|
|
- cover_url = cover.get("image_url", "") if cover else ""
|
|
|
|
|
|
|
+ # 获取封面图
|
|
|
|
|
+ image_list = note.get('image_list', [])
|
|
|
|
|
+ if image_list:
|
|
|
|
|
+ cover_url = image_list[0] if isinstance(image_list[0], str) else image_list[0].get('image_url', '')
|
|
|
|
|
+ else:
|
|
|
|
|
+ cover = note.get("cover_image", {})
|
|
|
|
|
+ cover_url = cover.get("image_url", "") if isinstance(cover, dict) else cover if cover else ""
|
|
|
|
|
+
|
|
|
interact = note.get("interact_info", {})
|
|
interact = note.get("interact_info", {})
|
|
|
user = note.get("user", {})
|
|
user = note.get("user", {})
|
|
|
evaluation = note.get("evaluation", {})
|
|
evaluation = note.get("evaluation", {})
|
|
|
confidence = evaluation.get("confidence_score", 0)
|
|
confidence = evaluation.get("confidence_score", 0)
|
|
|
|
|
|
|
|
- image_list = note.get('image_list', [])
|
|
|
|
|
- if not image_list and cover:
|
|
|
|
|
- image_list = [cover]
|
|
|
|
|
- images = [img.get('image_url', '') for img in image_list if img.get('image_url')]
|
|
|
|
|
|
|
+ # image_list 现在已经是 URL 字符串列表
|
|
|
|
|
+ images = [img if isinstance(img, str) else img.get('image_url', '') for img in image_list if img]
|
|
|
|
|
|
|
|
post_data = build_post_json_data(note, evaluation)
|
|
post_data = build_post_json_data(note, evaluation)
|
|
|
images_json = json.dumps(images)
|
|
images_json = json.dumps(images)
|
|
@@ -1621,16 +1632,7 @@ def render_note_evaluations(step):
|
|
|
title_rel = evaluation.get("title_relevance", 0)
|
|
title_rel = evaluation.get("title_relevance", 0)
|
|
|
content_exp = evaluation.get("content_expectation", 0)
|
|
content_exp = evaluation.get("content_expectation", 0)
|
|
|
|
|
|
|
|
- eval_details = f"""
|
|
|
|
|
- <div class="evaluation-reason">
|
|
|
|
|
- <strong>💡 评估理由:</strong><br>
|
|
|
|
|
- {eval_reason}
|
|
|
|
|
- <div class="evaluation-scores">
|
|
|
|
|
- <span class="score-item">📌 标题相关性: {title_rel:.2f}</span>
|
|
|
|
|
- <span class="score-item">📄 内容期望: {content_exp:.2f}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- """ if eval_reason else ""
|
|
|
|
|
|
|
+ eval_details = ""
|
|
|
|
|
|
|
|
confidence_percent = int(confidence * 100)
|
|
confidence_percent = int(confidence * 100)
|
|
|
|
|
|
|
@@ -1728,16 +1730,19 @@ def render_answer_generation(step):
|
|
|
# 渲染引用的帖子
|
|
# 渲染引用的帖子
|
|
|
cited_html = ""
|
|
cited_html = ""
|
|
|
for note in cited_notes:
|
|
for note in cited_notes:
|
|
|
- cover = note.get("cover_image", {})
|
|
|
|
|
- cover_url = cover.get("image_url", "") if cover else ""
|
|
|
|
|
|
|
+ # 获取封面图
|
|
|
|
|
+ image_list = note.get('image_list', [])
|
|
|
|
|
+ if image_list:
|
|
|
|
|
+ cover_url = image_list[0] if isinstance(image_list[0], str) else image_list[0].get('image_url', '')
|
|
|
|
|
+ else:
|
|
|
|
|
+ cover = note.get("cover_image", {})
|
|
|
|
|
+ cover_url = cover.get("image_url", "") if isinstance(cover, dict) else cover if cover else ""
|
|
|
|
|
+
|
|
|
interact = note.get("interact_info", {})
|
|
interact = note.get("interact_info", {})
|
|
|
user = note.get("user", {})
|
|
user = note.get("user", {})
|
|
|
|
|
|
|
|
- # 获取所有图片用于轮播
|
|
|
|
|
- image_list = note.get('image_list', [])
|
|
|
|
|
- if not image_list and cover:
|
|
|
|
|
- image_list = [cover]
|
|
|
|
|
- images = [img.get('image_url', '') for img in image_list if img.get('image_url')]
|
|
|
|
|
|
|
+ # image_list 现在已经是 URL 字符串列表
|
|
|
|
|
+ images = [img if isinstance(img, str) else img.get('image_url', '') for img in image_list if img]
|
|
|
|
|
|
|
|
# 构建帖子数据用于模态框(包含评估信息)
|
|
# 构建帖子数据用于模态框(包含评估信息)
|
|
|
eval_data = {
|
|
eval_data = {
|
|
@@ -1751,6 +1756,11 @@ def render_answer_generation(step):
|
|
|
|
|
|
|
|
image_html = f'<img src="{cover_url}" class="post-image" alt="{note.get("title", "")}">' if cover_url else '<div class="no-image">无图片</div>'
|
|
image_html = f'<img src="{cover_url}" class="post-image" alt="{note.get("title", "")}">' if cover_url else '<div class="no-image">无图片</div>'
|
|
|
|
|
|
|
|
|
|
+ # 类型标识
|
|
|
|
|
+ type_badge = ""
|
|
|
|
|
+ if note.get("type") == "video":
|
|
|
|
|
+ type_badge = '<div class="post-type-badge">📹 视频</div>'
|
|
|
|
|
+
|
|
|
# 轮播指示器
|
|
# 轮播指示器
|
|
|
dots_html = ""
|
|
dots_html = ""
|
|
|
if len(images) > 1:
|
|
if len(images) > 1:
|
|
@@ -1765,16 +1775,7 @@ def render_answer_generation(step):
|
|
|
title_rel = note.get("title_relevance", 0)
|
|
title_rel = note.get("title_relevance", 0)
|
|
|
content_exp = note.get("content_expectation", 0)
|
|
content_exp = note.get("content_expectation", 0)
|
|
|
|
|
|
|
|
- eval_details = f"""
|
|
|
|
|
- <div class="evaluation-reason">
|
|
|
|
|
- <strong>💡 评估理由:</strong><br>
|
|
|
|
|
- {eval_reason}
|
|
|
|
|
- <div class="evaluation-scores">
|
|
|
|
|
- <span class="score-item">📌 标题相关性: {title_rel:.2f}</span>
|
|
|
|
|
- <span class="score-item">📄 内容期望: {content_exp:.2f}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- """ if eval_reason else ""
|
|
|
|
|
|
|
+ eval_details = ""
|
|
|
|
|
|
|
|
# 置信度百分比
|
|
# 置信度百分比
|
|
|
note_confidence = note.get('confidence_score', 0)
|
|
note_confidence = note.get('confidence_score', 0)
|
|
@@ -1784,6 +1785,7 @@ def render_answer_generation(step):
|
|
|
<div class="post-card" onclick='openModal({post_data})' data-images='{images_json}'>
|
|
<div class="post-card" onclick='openModal({post_data})' data-images='{images_json}'>
|
|
|
<div class="post-image-wrapper">
|
|
<div class="post-image-wrapper">
|
|
|
{image_html}
|
|
{image_html}
|
|
|
|
|
+ {type_badge}
|
|
|
{dots_html}
|
|
{dots_html}
|
|
|
</div>
|
|
</div>
|
|
|
<div class="post-info">
|
|
<div class="post-info">
|