fix(ai): 9router fallback về local qwen3 + gộp số Điều VBPL bị tách#79
Merged
Conversation
Luongduytoan2006
commented
Jul 2, 2026
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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=truevà 9router lỗi hết retry, tự động rớt về local OllamaOLLAMA_FALLBACK_MODELcho 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)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.