瀏覽代碼

Ignore tenant not found error while increasing token usage. (#4950)

### What problem does this PR solve?

#4940

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.17.0
Kevin Hu 8 月之前
父節點
當前提交
849d9eb463
No account linked to committer's email address
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4
    2
      api/db/services/llm_service.py

+ 4
- 2
api/db/services/llm_service.py 查看文件

@@ -173,7 +173,8 @@ class TenantLLMService(CommonService):
def increase_usage(cls, tenant_id, llm_type, used_tokens, llm_name=None):
e, tenant = TenantService.get_by_id(tenant_id)
if not e:
raise LookupError("Tenant not found")
logging.error(f"Tenant not found: {tenant_id}")
return 0

llm_map = {
LLMType.EMBEDDING.value: tenant.embd_id,
@@ -186,7 +187,8 @@ class TenantLLMService(CommonService):

mdlnm = llm_map.get(llm_type)
if mdlnm is None:
raise ValueError("LLM type error")
logging.error(f"LLM type error: {llm_type}")
return 0

llm_name, llm_factory = TenantLLMService.split_model_name_and_factory(mdlnm)


Loading…
取消
儲存