Skip to content

fix(ai): 9router fallback về local qwen3 + gộp số Điều VBPL bị tách#79

Merged
Luongduytoan2006 merged 1 commit into
devfrom
feat/ai-update
Jul 2, 2026
Merged

fix(ai): 9router fallback về local qwen3 + gộp số Điều VBPL bị tách#79
Luongduytoan2006 merged 1 commit into
devfrom
feat/ai-update

Conversation

@Luongduytoan2006

Copy link
Copy Markdown
Collaborator
  • llm.py: khi USE_NINE_ROUTER=true mà 9router lỗi hết retry, rớt thẳng về local qwen3 (OLLAMA_FALLBACK_MODEL) thay vì raise 500. Áp cho cả complete() async lẫn complete_sync().
  • vbpl.py: VBPL editor tách số Điều ra nhiều ("Điều 1 3") làm vỡ số hiệu; gộp lại chữ số ngay sau "Điều" trong _strip_html.

- llm.py: khi USE_NINE_ROUTER=true mà 9router lỗi hết retry, rớt thẳng
  về local qwen3 (OLLAMA_FALLBACK_MODEL) thay vì raise 500. Áp cho cả
  complete() async lẫn complete_sync().
- vbpl.py: VBPL editor tách số Điều ra nhiều <span> ("Điều 1 3") làm vỡ
  số hiệu; gộp lại chữ số ngay sau "Điều" trong _strip_html.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 2, 2026 09:07
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fairinsight Ready Ready Preview, Comment Jul 2, 2026 9:07am

@Luongduytoan2006 Luongduytoan2006 merged commit 6675a0b into dev Jul 2, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

PR này cải thiện độ bền (resilience) của luồng gọi LLM khi bật 9router và tăng độ chính xác khi trích xuất toàn văn VBPL bằng cách “vá” hiện tượng số Điều bị tách do HTML editor của VBPL.

Changes:

  • Thêm cơ chế fallback: khi USE_NINE_ROUTER=true và 9router lỗi hết retry, tự động rớt về local Ollama OLLAMA_FALLBACK_MODEL cho cả complete() (async) và complete_sync() thay vì raise 500.
  • Cập nhật _strip_html() của VBPL để gộp chuỗi chữ số ngay sau “Điều” bị tách bởi <span> thành số Điều liền mạch.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
AI/backend_reasoning/src/services/llm.py Bổ sung fallback khi 9router thất bại sau retry, chuyển sang local Ollama để tránh trả 500.
AI/backend_reasoning/src/services/vbpl.py Gộp số Điều bị tách bởi HTML <span> sau khi get_text(' ') chèn khoảng trắng, giúp unit parsing ổn định hơn.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# VBPL editor hay tách SỐ Điều ra nhiều <span> rời ("Điều 1"+"3" → "Điều 1 3" sau khi
# get_text(' ') chèn space). Gộp lại chữ số bị tách NGAY SAU "Điều" để không vỡ số Điều.
# Chỉ đụng cụm "Điều <số> <số>..." — an toàn, không chạm nội dung khác.
_ART_NUM_SPLIT = re.compile(r"(Điều)\s+(\d(?:\s+\d){1,3})\b", re.I)
Comment on lines +194 to +196
except Exception as e: # noqa: BLE001 — 9router chết → local qwen3
_log(f"[LLM-FALLBACK] 9router lỗi hết retry → local qwen3 ({settings.OLLAMA_FALLBACK_MODEL}): {e}")
providers = [(settings.OLLAMA_BASE_URL, settings.OLLAMA_FALLBACK_MODEL)]
Comment on lines +236 to +238
except Exception as e: # noqa: BLE001 — 9router chết → local qwen3
_log(f"[LLM-FALLBACK] 9router lỗi hết retry → local qwen3 ({settings.OLLAMA_FALLBACK_MODEL}): {e}")
providers = [(settings.OLLAMA_BASE_URL, settings.OLLAMA_FALLBACK_MODEL)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants