feat: Add created_by and cost fields to generation models, populate created_by from the authenticated user, and implement cost calculation.

This commit is contained in:
xds
2026-02-09 01:52:23 +03:00
parent fa3e1bb05f
commit 4461964791
11 changed files with 20 additions and 5 deletions

View File

@@ -56,10 +56,10 @@ async def get_generations(character_id: Optional[str] = None, limit: int = 10, o
@router.post("/_run", response_model=GenerationResponse)
async def post_generation(generation: GenerationRequest, request: Request,
generation_service: GenerationService = Depends(
get_generation_service)) -> GenerationResponse:
generation_service: GenerationService = Depends(get_generation_service),
current_user: dict = Depends(get_current_user)) -> GenerationResponse:
logger.info(f"post_generation (run) called. LinkedCharId: {generation.linked_character_id}, PromptLength: {len(generation.prompt)}")
return await generation_service.create_generation_task(generation)
return await generation_service.create_generation_task(generation, user_id=current_user.get("username"))
@router.get("/{generation_id}", response_model=GenerationResponse)