KevinHuSh commited on
Commit
2587709
·
1 Parent(s): d1675fa

fix task losting isssue (#665)

Browse files

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

api/db/services/llm_service.py CHANGED
@@ -128,9 +128,11 @@ class TenantLLMService(CommonService):
128
  else:
129
  assert False, "LLM type error"
130
 
131
- num = cls.model.update(used_tokens=cls.model.used_tokens + used_tokens)\
132
- .where(cls.model.tenant_id == tenant_id, cls.model.llm_name == mdlnm)\
133
- .execute()
 
 
134
  return num
135
 
136
 
 
128
  else:
129
  assert False, "LLM type error"
130
 
131
+ num = 0
132
+ for u in cls.query(tenant_id = tenant_id, llm_name=mdlnm):
133
+ num += cls.model.update(used_tokens = u.used_tokens + used_tokens)\
134
+ .where(cls.model.tenant_id == tenant_id, cls.model.llm_name == mdlnm)\
135
+ .execute()
136
  return num
137
 
138
 
api/db/services/task_service.py CHANGED
@@ -155,8 +155,8 @@ def queue_tasks(doc, bucket, name):
155
  else:
156
  tsks.append(new_task())
157
 
158
- for t in tsks:
159
- REDIS_CONN.queue_product(SVR_QUEUE_NAME, message=t)
160
-
161
  bulk_insert_into_db(Task, tsks, True)
162
  DocumentService.begin2parse(doc["id"])
 
 
 
 
155
  else:
156
  tsks.append(new_task())
157
 
 
 
 
158
  bulk_insert_into_db(Task, tsks, True)
159
  DocumentService.begin2parse(doc["id"])
160
+
161
+ for t in tsks:
162
+ REDIS_CONN.queue_product(SVR_QUEUE_NAME, message=t)