converting to pydantic-settings
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from dataclasses import replace
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
@@ -17,7 +16,6 @@ from python.ebook_search.ingest import ingest_configured_paths
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/admin")
|
||||
EMBED_ALL_BATCH_SIZE = 32
|
||||
|
||||
|
||||
@router.get("", response_class=HTMLResponse)
|
||||
@@ -70,7 +68,7 @@ def embed_all(request: Request) -> HTMLResponse:
|
||||
"""Embed all chunks missing vectors in fixed-size batches."""
|
||||
total = 0
|
||||
batches = 0
|
||||
config = replace(request.app.state.config, embedding_batch_size=EMBED_ALL_BATCH_SIZE)
|
||||
config = request.app.state.config
|
||||
try:
|
||||
with Session(request.app.state.engine) as session:
|
||||
while True:
|
||||
@@ -103,5 +101,5 @@ def embed_all(request: Request) -> HTMLResponse:
|
||||
return templates.TemplateResponse(
|
||||
request,
|
||||
"partials/admin_status.html",
|
||||
{"message": f"Embedded {total} chunks in {batches} batches of {EMBED_ALL_BATCH_SIZE}"},
|
||||
{"message": f"Embedded {total} chunks in {batches} batches of {config.embedding_batch_size}"},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user