feat: enhance model handling with default parameters and cache model check

v3.2
CaptainB 2025-10-22 12:30:47 +08:00
parent 92d5e17600
commit 887de56877
3 changed files with 10 additions and 1 deletions

View File

@ -27,7 +27,9 @@ def get_embedding_model(model_id, exception_handler=lambda e: maxkb_logger.error
))):
try:
model = QuerySet(Model).filter(id=model_id).first()
embedding_model = ModelManage.get_model(model_id, lambda _id: get_model(model))
s = {p.get('field'): p.get('default_value') for p in model.model_params_form if p.get('default_value') is not None}
embedding_model = ModelManage.get_model(model_id, lambda _id: get_model(model, **{**s}))
except Exception as e:
exception_handler(e)
raise e
@ -77,6 +79,7 @@ def embedding_by_document(document_id, model_id, state_list=None):
))
embedding_model = get_embedding_model(model_id, exception_handler)
#
ListenerManagement.embedding_by_document(document_id, embedding_model, state_list)

View File

@ -22,6 +22,9 @@ class AliyunBaiLianEmbedding(MaxKBBaseModel):
self.model_name = model_name
self.optional_params = optional_params
def is_cache_model(self):
return False
@staticmethod
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
optional_params = MaxKBBaseModel.filter_optional_params(model_kwargs)

View File

@ -22,6 +22,9 @@ class OpenAIEmbeddingModel(MaxKBBaseModel):
self.model_name = model_name
self.optional_params = optional_params
def is_cache_model(self):
return False
@staticmethod
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
optional_params = MaxKBBaseModel.filter_optional_params(model_kwargs)