v1.0.162: auto-classify backend — classify/grouping services, 7 new columns, /classify-batch, /api/groups, /apply-groups
This commit is contained in:
@@ -44,6 +44,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._handle_app_js()
|
||||
elif parsed.path == "/api/supplements":
|
||||
self._handle_api_supplements(parsed)
|
||||
elif parsed.path == "/api/groups":
|
||||
self._handle_api_groups(parsed)
|
||||
elif parsed.path == "/api/batch-progress":
|
||||
self._handle_api_batch_progress(parsed)
|
||||
elif parsed.path.startswith("/api/documents/"):
|
||||
self._handle_api_document(parsed)
|
||||
else:
|
||||
@@ -58,6 +62,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._handle_llm_ops()
|
||||
elif self.path == "/convert-doc":
|
||||
self._handle_convert_doc()
|
||||
elif self.path == "/classify-batch":
|
||||
self._handle_classify_batch()
|
||||
elif self.path == "/apply-groups":
|
||||
self._handle_apply_groups()
|
||||
else:
|
||||
self.send_error(404)
|
||||
|
||||
@@ -119,6 +127,57 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"elements_json": doc.get("elements_json"),
|
||||
})
|
||||
|
||||
# ── /api/groups ?batch=X ─────────────────────────────────────────────
|
||||
|
||||
def _handle_api_groups(self, parsed):
|
||||
params = parse_qs(parsed.query)
|
||||
batch_id = params.get("batch", [None])[0]
|
||||
if not batch_id:
|
||||
self._json({"ok": False, "error": "batch required"}, 400)
|
||||
return
|
||||
from services.grouping import group_documents
|
||||
result = group_documents(batch_id)
|
||||
self._json(result)
|
||||
|
||||
# ── /api/batch-progress ?batch=X ─────────────────────────────────────
|
||||
|
||||
def _handle_api_batch_progress(self, parsed):
|
||||
params = parse_qs(parsed.query)
|
||||
batch_id = params.get("batch", [None])[0]
|
||||
if not batch_id:
|
||||
self._json({"ok": False, "error": "batch required"}, 400)
|
||||
return
|
||||
counts = db_documents.count_by_status(batch_id)
|
||||
docs = db_documents.list_by_batch(batch_id)
|
||||
self._json({"ok": True, "counts": counts, "total": len(docs)})
|
||||
|
||||
# ── POST /classify-batch ─────────────────────────────────────────────
|
||||
|
||||
def _handle_classify_batch(self):
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
body = json.loads(self.rfile.read(length))
|
||||
batch_id = body.get("batch_id")
|
||||
if not batch_id:
|
||||
self._json({"ok": False, "error": "batch_id required"}, 400)
|
||||
return
|
||||
from services.classify import classify_batch
|
||||
result = classify_batch(batch_id)
|
||||
self._json(result)
|
||||
|
||||
# ── POST /apply-groups ───────────────────────────────────────────────
|
||||
|
||||
def _handle_apply_groups(self):
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
body = json.loads(self.rfile.read(length))
|
||||
batch_id = body.get("batch_id")
|
||||
groups = body.get("groups", [])
|
||||
if not batch_id:
|
||||
self._json({"ok": False, "error": "batch_id required"}, 400)
|
||||
return
|
||||
from services.grouping import apply_groups
|
||||
result = apply_groups(batch_id, groups)
|
||||
self._json(result)
|
||||
|
||||
# ── /app.js (static) ───────────────────────────────────────────────────
|
||||
|
||||
def _handle_app_js(self):
|
||||
|
||||
Reference in New Issue
Block a user