fix: ревью Opus — баги #1-2 + Protocol расширен + BatchGroupingResult
This commit is contained in:
@@ -79,13 +79,18 @@ def _call_llm_classify(header_text, llm_client=None):
|
||||
return parsed, raw_text, needed_fix
|
||||
|
||||
|
||||
def classify_batch(batch_id):
|
||||
def classify_batch(batch_id, llm_client=None, repo=None):
|
||||
"""
|
||||
Классифицировать все документы в batch.
|
||||
Сбрасывает статус на 'pending' для всех перед началом.
|
||||
Параллельно (ThreadPoolExecutor) обрабатывает до MAX_WORKERS документов.
|
||||
Возвращает {ok, total, done, failed}.
|
||||
Возвращает {ok, total, done, failed, garbage, json_fix_rate}.
|
||||
llm_client: LLMClient (optional, default — HttpxLLMClient)
|
||||
repo: Repository (optional, default — direct db.* calls)
|
||||
"""
|
||||
_db = repo if repo else db_docs
|
||||
_llm = llm_client if llm_client else _get_classify_client()
|
||||
|
||||
# Сбросить статус — allow re-classify after file changes
|
||||
db_docs.reset_classify_status(batch_id)
|
||||
pending = db_docs.list_pending(batch_id)
|
||||
@@ -118,7 +123,7 @@ def classify_batch(batch_id):
|
||||
|
||||
# Stage 3: LLM classification (only for remaining)
|
||||
db_docs.set_classify_processing(doc["id"]) # crash recovery marker
|
||||
result, raw, needed_fix = _call_llm_classify(text)
|
||||
result, raw, needed_fix = _call_llm_classify(text, _llm)
|
||||
json_total += 1
|
||||
if needed_fix:
|
||||
json_fixes += 1
|
||||
|
||||
Reference in New Issue
Block a user