fix code
This commit is contained in:
@@ -22,7 +22,7 @@ from backend.app.ai.crud.image_task_crud import image_task_dao
|
||||
from backend.app.ai.schema.image_task import CreateImageTaskParam
|
||||
from backend.app.admin.service.points_service import points_service
|
||||
from backend.app.ai.service.rate_limit_service import rate_limit_service
|
||||
from backend.common.const import SENTENCE_CARD_COST, SENTENCE_TYPE_SCENE_SENTENCE, SENTENCE_TYPE_SCENE_DIALOGUE, SENTENCE_TYPE_SCENE_EXERCISE, LLM_CHAT_COST
|
||||
from backend.common.const import SENTENCE_TYPE_SCENE_SENTENCE, SENTENCE_TYPE_SCENE_DIALOGUE, SENTENCE_TYPE_SCENE_EXERCISE, LLM_CHAT_COST
|
||||
|
||||
|
||||
class SentenceService:
|
||||
@@ -336,7 +336,7 @@ class SentenceService:
|
||||
if latest_task:
|
||||
await db.commit()
|
||||
return {"task_id": str(latest_task.id), "status": latest_task.status}
|
||||
if not await points_service.check_sufficient_points(user_id, SENTENCE_CARD_COST):
|
||||
if not await points_service.check_sufficient_points(user_id, LLM_CHAT_COST):
|
||||
raise errors.ForbiddenError(msg='积分不足,请获取积分后继续使用')
|
||||
slot_acquired = await rate_limit_service.acquire_task_slot(user_id)
|
||||
if not slot_acquired:
|
||||
@@ -405,7 +405,7 @@ class SentenceService:
|
||||
total_tokens = 0
|
||||
if isinstance(result, dict):
|
||||
total_tokens = int((result.get("token_usage") or {}).get("total_tokens") or 0)
|
||||
deduct_amount = SENTENCE_CARD_COST
|
||||
deduct_amount = LLM_CHAT_COST
|
||||
if total_tokens > 0:
|
||||
units = math.ceil(max(total_tokens, 1) / 1000)
|
||||
deduct_amount = units * LLM_CHAT_COST
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"""Constants used throughout the application."""
|
||||
|
||||
# Image recognition service cost in points
|
||||
IMAGE_RECOGNITION_COST = 2 # 0.0015/1000 * 1
|
||||
IMAGE_RECOGNITION_COST = 1 # 1000 / 1
|
||||
SPEECH_ASSESSMENT_COST = 1
|
||||
SENTENCE_CARD_COST = 2
|
||||
LLM_CHAT_COST = 1
|
||||
|
||||
QWEN_TOKEN_COST = 0.002
|
||||
|
||||
Reference in New Issue
Block a user