mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-24 23:28:32 +08:00
chore: Reduce the invocation of the plugin interface (#19629)
Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
parent
618981f1ae
commit
c58678d84d
@ -754,7 +754,7 @@ class ProviderConfiguration(BaseModel):
|
|||||||
:param only_active: return active model only
|
:param only_active: return active model only
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
provider_models = self.get_provider_models(model_type, only_active)
|
provider_models = self.get_provider_models(model_type, only_active, model)
|
||||||
|
|
||||||
for provider_model in provider_models:
|
for provider_model in provider_models:
|
||||||
if provider_model.model == model:
|
if provider_model.model == model:
|
||||||
@ -763,12 +763,13 @@ class ProviderConfiguration(BaseModel):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_provider_models(
|
def get_provider_models(
|
||||||
self, model_type: Optional[ModelType] = None, only_active: bool = False
|
self, model_type: Optional[ModelType] = None, only_active: bool = False, model: Optional[str] = None
|
||||||
) -> list[ModelWithProviderEntity]:
|
) -> list[ModelWithProviderEntity]:
|
||||||
"""
|
"""
|
||||||
Get provider models.
|
Get provider models.
|
||||||
:param model_type: model type
|
:param model_type: model type
|
||||||
:param only_active: only active models
|
:param only_active: only active models
|
||||||
|
:param model: model name
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
model_provider_factory = ModelProviderFactory(self.tenant_id)
|
model_provider_factory = ModelProviderFactory(self.tenant_id)
|
||||||
@ -791,7 +792,10 @@ class ProviderConfiguration(BaseModel):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
provider_models = self._get_custom_provider_models(
|
provider_models = self._get_custom_provider_models(
|
||||||
model_types=model_types, provider_schema=provider_schema, model_setting_map=model_setting_map
|
model_types=model_types,
|
||||||
|
provider_schema=provider_schema,
|
||||||
|
model_setting_map=model_setting_map,
|
||||||
|
model=model,
|
||||||
)
|
)
|
||||||
|
|
||||||
if only_active:
|
if only_active:
|
||||||
@ -943,6 +947,7 @@ class ProviderConfiguration(BaseModel):
|
|||||||
model_types: Sequence[ModelType],
|
model_types: Sequence[ModelType],
|
||||||
provider_schema: ProviderEntity,
|
provider_schema: ProviderEntity,
|
||||||
model_setting_map: dict[ModelType, dict[str, ModelSettings]],
|
model_setting_map: dict[ModelType, dict[str, ModelSettings]],
|
||||||
|
model: Optional[str] = None,
|
||||||
) -> list[ModelWithProviderEntity]:
|
) -> list[ModelWithProviderEntity]:
|
||||||
"""
|
"""
|
||||||
Get custom provider models.
|
Get custom provider models.
|
||||||
@ -995,7 +1000,8 @@ class ProviderConfiguration(BaseModel):
|
|||||||
for model_configuration in self.custom_configuration.models:
|
for model_configuration in self.custom_configuration.models:
|
||||||
if model_configuration.model_type not in model_types:
|
if model_configuration.model_type not in model_types:
|
||||||
continue
|
continue
|
||||||
|
if model and model != model_configuration.model:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
custom_model_schema = self.get_model_schema(
|
custom_model_schema = self.get_model_schema(
|
||||||
model_type=model_configuration.model_type,
|
model_type=model_configuration.model_type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user