mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-18 02:16:07 +00:00
feat: auto set new model to default pipeline when it has no model bound
This commit is contained in:
@@ -6,6 +6,7 @@ import sqlalchemy
|
|||||||
|
|
||||||
from ....core import app
|
from ....core import app
|
||||||
from ....entity.persistence import model as persistence_model
|
from ....entity.persistence import model as persistence_model
|
||||||
|
from ....entity.persistence import pipeline as persistence_pipeline
|
||||||
|
|
||||||
|
|
||||||
class ModelsService:
|
class ModelsService:
|
||||||
@@ -40,6 +41,19 @@ class ModelsService:
|
|||||||
|
|
||||||
await self.ap.model_mgr.load_llm_model(llm_model)
|
await self.ap.model_mgr.load_llm_model(llm_model)
|
||||||
|
|
||||||
|
# check if default pipeline has no model bound
|
||||||
|
result = await self.ap.persistence_mgr.execute_async(
|
||||||
|
sqlalchemy.select(persistence_pipeline.LegacyPipeline).where(persistence_pipeline.LegacyPipeline.is_default == True)
|
||||||
|
)
|
||||||
|
pipeline = result.first()
|
||||||
|
if pipeline is not None and pipeline.config['ai']['local-agent']['model'] == '':
|
||||||
|
pipeline_config = pipeline.config
|
||||||
|
pipeline_config['ai']['local-agent']['model'] = model_data['uuid']
|
||||||
|
pipeline_data = {
|
||||||
|
"config": pipeline_config
|
||||||
|
}
|
||||||
|
await self.ap.pipeline_service.update_pipeline(pipeline.uuid, pipeline_data)
|
||||||
|
|
||||||
return model_data['uuid']
|
return model_data['uuid']
|
||||||
|
|
||||||
async def get_llm_model(self, model_uuid: str) -> dict | None:
|
async def get_llm_model(self, model_uuid: str) -> dict | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user