feat: enhance LLM model creation with optional default pipeline setting

- Updated create_llm_model method to include auto_set_to_default_pipeline parameter.
- Adjusted ModelManager to set auto_set_to_default_pipeline to False when creating models.
- Improved logic for setting the default pipeline model based on the new parameter.
This commit is contained in:
Junyan Qin
2026-01-31 13:24:33 +08:00
parent 3204292360
commit 50dff55217
2 changed files with 16 additions and 12 deletions
+4 -1
View File
@@ -64,7 +64,9 @@ class LLMModelsService:
models = result.all() models = result.all()
return [self.ap.persistence_mgr.serialize_model(persistence_model.LLMModel, m) for m in models] return [self.ap.persistence_mgr.serialize_model(persistence_model.LLMModel, m) for m in models]
async def create_llm_model(self, model_data: dict, preserve_uuid: bool = False) -> str: async def create_llm_model(
self, model_data: dict, preserve_uuid: bool = False, auto_set_to_default_pipeline: bool = True
) -> str:
"""Create a new LLM model""" """Create a new LLM model"""
if not preserve_uuid: if not preserve_uuid:
model_data['uuid'] = str(uuid.uuid4()) model_data['uuid'] = str(uuid.uuid4())
@@ -95,6 +97,7 @@ class LLMModelsService:
) )
self.ap.model_mgr.llm_models.append(runtime_llm_model) self.ap.model_mgr.llm_models.append(runtime_llm_model)
if auto_set_to_default_pipeline:
# set the default pipeline model to this model # set the default pipeline model to this model
result = await self.ap.persistence_mgr.execute_async( result = await self.ap.persistence_mgr.execute_async(
sqlalchemy.select(persistence_pipeline.LegacyPipeline).where( sqlalchemy.select(persistence_pipeline.LegacyPipeline).where(
@@ -149,6 +149,7 @@ class ModelManager:
'prefered_ranking': space_model.featured_order, 'prefered_ranking': space_model.featured_order,
}, },
preserve_uuid=True, preserve_uuid=True,
auto_set_to_default_pipeline=False,
) )
elif space_model.category == 'embedding': elif space_model.category == 'embedding':