积分消耗明细改版V1
This commit is contained in:
@@ -58,7 +58,7 @@ from app.services.module_generation_log_service import log_module_error, log_mod
|
||||
from app.services.llm import optimize_prompt
|
||||
from app.services.llm_billing import (
|
||||
LlmBillingContext,
|
||||
ensure_pre_deducted,
|
||||
ensure_llm_charged,
|
||||
log_provider_failure,
|
||||
record_provider_exception,
|
||||
log_provider_start,
|
||||
@@ -66,7 +66,7 @@ from app.services.llm_billing import (
|
||||
refund_on_final_failure,
|
||||
finalize_llm_business_failure,
|
||||
mark_business_success,
|
||||
pre_deduct,
|
||||
charge_llm_credits,
|
||||
)
|
||||
from app.services.module_generation_flow_base_service import (
|
||||
assert_project_has_no_active_chat_tasks as _base_assert_project_has_no_active_chat_tasks,
|
||||
@@ -842,7 +842,7 @@ async def submit_image_prompt_optimize(
|
||||
project.status = ModuleProjectStatusEnum.PROCESSING.value
|
||||
project.current_step_code = ShotReplicateStepCodeEnum.IMAGE_PROMPT_OPTIMIZE.value
|
||||
project.error_message = None
|
||||
await pre_deduct(
|
||||
await charge_llm_credits(
|
||||
db,
|
||||
LlmBillingContext(
|
||||
user_id=str(project.user_id),
|
||||
@@ -957,10 +957,10 @@ async def run_image_prompt_optimize(
|
||||
description_prefix="拆镜复刻图片AI提词优化",
|
||||
trace_id=f"shot-image-prompt:{step_id_value}",
|
||||
)
|
||||
pre_deduct_validation = await ensure_pre_deducted(db, llm_billing_context)
|
||||
if not pre_deduct_validation.can_execute:
|
||||
charge_validation = await ensure_llm_charged(db, llm_billing_context)
|
||||
if not charge_validation.can_execute:
|
||||
step.status = ModuleStepStatusEnum.FAILED.value
|
||||
step.error_message = f"LLM账务状态异常({pre_deduct_validation.state.value}),已终止任务"
|
||||
step.error_message = f"LLM账务状态异常({charge_validation.state.value}),已终止任务"
|
||||
step.completed_at = _now()
|
||||
project.status = ModuleProjectStatusEnum.FAILED.value
|
||||
project.error_message = step.error_message
|
||||
@@ -1286,7 +1286,7 @@ async def submit_video_prompt_optimize(
|
||||
project.status = ModuleProjectStatusEnum.PROCESSING.value
|
||||
project.current_step_code = ShotReplicateStepCodeEnum.VIDEO_PROMPT_OPTIMIZE.value
|
||||
project.error_message = None
|
||||
await pre_deduct(
|
||||
await charge_llm_credits(
|
||||
db,
|
||||
LlmBillingContext(
|
||||
user_id=str(project.user_id),
|
||||
@@ -1399,10 +1399,10 @@ async def run_video_prompt_optimize(
|
||||
description_prefix="拆镜复刻视频AI提词优化",
|
||||
trace_id=f"shot-video-prompt:{step_id_value}",
|
||||
)
|
||||
pre_deduct_validation = await ensure_pre_deducted(db, llm_billing_context)
|
||||
if not pre_deduct_validation.can_execute:
|
||||
charge_validation = await ensure_llm_charged(db, llm_billing_context)
|
||||
if not charge_validation.can_execute:
|
||||
step.status = ModuleStepStatusEnum.FAILED.value
|
||||
step.error_message = f"LLM账务状态异常({pre_deduct_validation.state.value}),已终止任务"
|
||||
step.error_message = f"LLM账务状态异常({charge_validation.state.value}),已终止任务"
|
||||
step.completed_at = _now()
|
||||
project.status = ModuleProjectStatusEnum.FAILED.value
|
||||
project.error_message = step.error_message
|
||||
|
||||
Reference in New Issue
Block a user