feat: enhance parseAllChapters API to support force parsing and update Audiobook component for AI mode handling
This commit is contained in:
@@ -629,6 +629,7 @@ async def parse_chapter(
|
||||
async def parse_all_chapters_endpoint(
|
||||
project_id: int,
|
||||
only_errors: bool = False,
|
||||
force: bool = False,
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -639,13 +640,19 @@ async def parse_all_chapters_endpoint(
|
||||
raise HTTPException(status_code=400, detail=f"Project must be in 'ready' state, current: {project.status}")
|
||||
|
||||
from db.crud import get_system_setting
|
||||
if not get_system_setting(db, "llm_api_key") or not get_system_setting(db, "llm_base_url") or not get_system_setting(db, "llm_model"):
|
||||
raise HTTPException(status_code=400, detail="LLM config not set")
|
||||
if project.source_type != "ai_generated":
|
||||
if not get_system_setting(db, "llm_api_key") or not get_system_setting(db, "llm_base_url") or not get_system_setting(db, "llm_model"):
|
||||
raise HTTPException(status_code=400, detail="LLM config not set")
|
||||
|
||||
from core.audiobook_service import parse_all_chapters
|
||||
from core.database import SessionLocal
|
||||
|
||||
statuses = ("error",) if only_errors else ("pending", "error")
|
||||
if only_errors:
|
||||
statuses = ("error",)
|
||||
elif force:
|
||||
statuses = ("pending", "error", "ready", "done")
|
||||
else:
|
||||
statuses = ("pending", "error")
|
||||
|
||||
async def run():
|
||||
async_db = SessionLocal()
|
||||
|
||||
Reference in New Issue
Block a user