correct mismatched kb doc number (#826)
### What problem does this PR solve? #620 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
f6a599461f
commit
a1586e0af9
@ -21,6 +21,8 @@ from copy import deepcopy
|
|||||||
from api.db import LLMType, UserTenantRole
|
from api.db import LLMType, UserTenantRole
|
||||||
from api.db.db_models import init_database_tables as init_web_db, LLMFactories, LLM, TenantLLM
|
from api.db.db_models import init_database_tables as init_web_db, LLMFactories, LLM, TenantLLM
|
||||||
from api.db.services import UserService
|
from api.db.services import UserService
|
||||||
|
from api.db.services.document_service import DocumentService
|
||||||
|
from api.db.services.knowledgebase_service import KnowledgebaseService
|
||||||
from api.db.services.llm_service import LLMFactoriesService, LLMService, TenantLLMService, LLMBundle
|
from api.db.services.llm_service import LLMFactoriesService, LLMService, TenantLLMService, LLMBundle
|
||||||
from api.db.services.user_service import TenantService, UserTenantService
|
from api.db.services.user_service import TenantService, UserTenantService
|
||||||
from api.settings import CHAT_MDL, EMBEDDING_MDL, ASR_MDL, IMAGE2TEXT_MDL, PARSERS, LLM_FACTORY, API_KEY, LLM_BASE_URL
|
from api.settings import CHAT_MDL, EMBEDDING_MDL, ASR_MDL, IMAGE2TEXT_MDL, PARSERS, LLM_FACTORY, API_KEY, LLM_BASE_URL
|
||||||
@ -406,6 +408,8 @@ def init_llm_factory():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
|
for kb_id in KnowledgebaseService.get_all_ids():
|
||||||
|
KnowledgebaseService.update_by_id(kb_id, {"doc_num": DocumentService.get_kb_doc_count(kb_id)})
|
||||||
"""
|
"""
|
||||||
drop table llm;
|
drop table llm;
|
||||||
drop table llm_factories;
|
drop table llm_factories;
|
||||||
|
|||||||
@ -265,3 +265,9 @@ class DocumentService(CommonService):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
stat_logger.error("fetch task exception:" + str(e))
|
stat_logger.error("fetch task exception:" + str(e))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@DB.connection_context()
|
||||||
|
def get_kb_doc_count(cls, kb_id):
|
||||||
|
return len(cls.model.select(cls.model.id).where(
|
||||||
|
cls.model.kb_id == kb_id).dicts())
|
||||||
|
|
||||||
|
|||||||
@ -112,3 +112,8 @@ class KnowledgebaseService(CommonService):
|
|||||||
if kb:
|
if kb:
|
||||||
return True, kb[0]
|
return True, kb[0]
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@DB.connection_context()
|
||||||
|
def get_all_ids(cls):
|
||||||
|
return [m["id"] for m in cls.model.select(cls.model.id).dicts()]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user