Show vision suggestions from current layout version
This commit is contained in:
parent
8d3f7d3013
commit
0764e698d3
|
|
@ -2435,6 +2435,8 @@ def document_detail(document_id: str, request: Request, queue: str | None = None
|
|||
|
||||
latest_vision_output = None
|
||||
vision_analysis_json = None
|
||||
vision_candidate_fields = []
|
||||
vision_field_suggestions = []
|
||||
try:
|
||||
DocumentVisionAnalysisOutput.__table__.create(bind=db.get_bind(), checkfirst=True)
|
||||
latest_vision_output = (
|
||||
|
|
@ -2450,6 +2452,16 @@ def document_detail(document_id: str, request: Request, queue: str | None = None
|
|||
latest_vision_output = None
|
||||
vision_analysis_json = None
|
||||
|
||||
vision_source_json = layout_source_json if isinstance(layout_source_json, dict) else {}
|
||||
|
||||
if current_text_version and isinstance(getattr(current_text_version, "layout_json", None), dict):
|
||||
current_layout_json = current_text_version.layout_json
|
||||
if current_layout_json.get("vision_candidate_fields") or current_layout_json.get("vision_field_suggestions"):
|
||||
vision_source_json = current_layout_json
|
||||
|
||||
vision_candidate_fields = vision_source_json.get("vision_candidate_fields") or []
|
||||
vision_field_suggestions = vision_source_json.get("vision_field_suggestions") or []
|
||||
|
||||
diagnostic_outputs = []
|
||||
try:
|
||||
diagnostic_outputs = list_candidate_outputs(db.connection(), document.id)
|
||||
|
|
@ -2559,6 +2571,8 @@ def document_detail(document_id: str, request: Request, queue: str | None = None
|
|||
"diagnostic_outputs": diagnostic_outputs,
|
||||
"latest_vision_output": latest_vision_output,
|
||||
"vision_analysis_json": vision_analysis_json,
|
||||
"vision_candidate_fields": vision_candidate_fields,
|
||||
"vision_field_suggestions": vision_field_suggestions,
|
||||
"overlay_page_data": overlay_page_data,
|
||||
"layout_review_pages": layout_review_pages,
|
||||
"replica_clean_output": replica_clean_output,
|
||||
|
|
|
|||
|
|
@ -1987,11 +1987,40 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% set vision_fields = [] %}
|
||||
{% if vision_analysis_json and vision_analysis_json.get("vision_candidate_fields") %}
|
||||
{% set vision_fields = vision_analysis_json.get("vision_candidate_fields") %}
|
||||
{% elif layout_review_pages and layout_review_pages[0].get("vision_candidate_fields") %}
|
||||
{% set vision_fields = layout_review_pages[0].get("vision_candidate_fields") %}
|
||||
{% set vision_fields = vision_candidate_fields or [] %}
|
||||
{% set vision_suggestions = vision_field_suggestions or [] %}
|
||||
|
||||
{% if vision_suggestions %}
|
||||
<div class="detail-card" style="margin:0.75rem 0; border-left:4px solid #16a34a;">
|
||||
<div style="display:flex; justify-content:space-between; gap:1rem; align-items:center;">
|
||||
<h3 style="margin:0;">Vision Field Suggestions</h3>
|
||||
<span style="font-size:0.85rem; color:#64748b;">{{ vision_suggestions|length }} suggestions</span>
|
||||
</div>
|
||||
<div style="margin-top:0.5rem; overflow-x:auto;">
|
||||
<table class="data-table" style="width:100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Action</th>
|
||||
<th>Field</th>
|
||||
<th>Value</th>
|
||||
<th>Confidence</th>
|
||||
<th>OCR Conf.</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for suggestion in vision_suggestions[:12] %}
|
||||
<tr>
|
||||
<td>{{ suggestion.get("action", "") }}</td>
|
||||
<td>{{ suggestion.get("target_field", "") }}</td>
|
||||
<td><code>{{ suggestion.get("value", "") }}</code></td>
|
||||
<td>{{ suggestion.get("confidence", "") }}</td>
|
||||
<td>{{ suggestion.get("ocr_confidence", "") }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if vision_fields %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue