会员积分改版V3
This commit is contained in:
@@ -157,7 +157,7 @@ async def build_prompt_with_chatapi(db: AsyncSession, record: ChatGenerationTask
|
||||
)
|
||||
latency_ms = int((time.perf_counter() - started) * 1000)
|
||||
if response.status_code >= 400:
|
||||
message = response.text[:1000]
|
||||
message = response.text[:5000]
|
||||
await log_provider_call(
|
||||
record,
|
||||
provider=config.provider,
|
||||
|
||||
@@ -245,14 +245,14 @@ async def finish_call_failure(ctx: LlmBillingContext, *, error: str, status: str
|
||||
# 供应商已成功并已记录 Token;后续解析/校验/落库失败只能记为后处理失败,
|
||||
# 不能覆盖真实供应商成功事实,也不能重复累计失败调用次数。
|
||||
attempt.postprocess_status = "failed"
|
||||
attempt.postprocess_error = str(error)[:1000]
|
||||
attempt.postprocess_error = str(error)[:5000]
|
||||
return "postprocess_failure"
|
||||
if attempt.status != LlmCallAttemptStatus.STARTED.value:
|
||||
return "noop"
|
||||
attempt.status = LlmCallAttemptStatus.TIMEOUT.value if status == "timeout" else LlmCallAttemptStatus.FAILED.value
|
||||
attempt.response_received_at = now
|
||||
attempt.duration_ms = max(0, int((now - attempt.request_started_at).total_seconds() * 1000))
|
||||
attempt.error_message = str(error)[:1000]
|
||||
attempt.error_message = str(error)[:5000]
|
||||
attempt.token_unavailable_reason = "供应商调用失败,未返回Token使用量"
|
||||
execution_result = await db.execute(
|
||||
select(LlmBillingExecution)
|
||||
|
||||
@@ -463,7 +463,7 @@ async def refund_on_final_failure(db: AsyncSession, ctx: LlmBillingContext, *, e
|
||||
# 调用方只有在业务最终失败时才能进这里;允许从业务成功调用记录转最终失败退款。
|
||||
pass
|
||||
execution.status = LlmBillingExecutionStatus.FINAL_FAILED.value
|
||||
execution.final_error_message = str(error or "业务最终失败")[:1000]
|
||||
execution.final_error_message = str(error or "业务最终失败")[:5000]
|
||||
execution.completed_at = utc_now()
|
||||
_log(ctx, LlmBillingEvent.FINAL_FAILURE_START, status="started", error=error)
|
||||
try:
|
||||
@@ -534,7 +534,7 @@ async def finalize_llm_business_failure(
|
||||
execution = await _find_execution(audit_session, ctx, for_update=True)
|
||||
if execution is not None and execution.status != LlmBillingExecutionStatus.REFUNDED.value:
|
||||
execution.status = LlmBillingExecutionStatus.REFUND_FAILED.value
|
||||
execution.final_error_message = str(error or exc)[:1000]
|
||||
execution.final_error_message = str(error or exc)[:5000]
|
||||
execution.completed_at = utc_now()
|
||||
except Exception:
|
||||
_log(ctx, LlmBillingEvent.FINAL_FAILURE_REFUND_FAILED, status="failed", error=str(exc), persist_failed_status=False)
|
||||
|
||||
Reference in New Issue
Block a user