|
|
|
|
@ -36,6 +36,19 @@ class PluginParameterService:
|
|
|
|
|
|
|
|
|
|
match provider_type:
|
|
|
|
|
case "tool":
|
|
|
|
|
provider_controller = ToolManager.get_builtin_provider(provider, tenant_id)
|
|
|
|
|
# init tool configuration
|
|
|
|
|
tool_configuration = ProviderConfigEncrypter(
|
|
|
|
|
tenant_id=tenant_id,
|
|
|
|
|
config=[x.to_basic_provider_config() for x in provider_controller.get_credentials_schema()],
|
|
|
|
|
provider_type=provider_controller.provider_type.value,
|
|
|
|
|
provider_identity=provider_controller.entity.identity.name,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# check if credentials are required
|
|
|
|
|
if not provider_controller.need_credentials:
|
|
|
|
|
credentials = {}
|
|
|
|
|
else:
|
|
|
|
|
# fetch credentials from db
|
|
|
|
|
with Session(db.engine) as session:
|
|
|
|
|
db_record = (
|
|
|
|
|
@ -50,20 +63,12 @@ class PluginParameterService:
|
|
|
|
|
if db_record is None:
|
|
|
|
|
raise ValueError(f"Builtin provider {provider} not found when fetching credentials")
|
|
|
|
|
|
|
|
|
|
credentials = db_record.credentials
|
|
|
|
|
provider_controller = ToolManager.get_builtin_provider(provider, tenant_id)
|
|
|
|
|
# init tool configuration
|
|
|
|
|
tool_configuration = ProviderConfigEncrypter(
|
|
|
|
|
tenant_id=tenant_id,
|
|
|
|
|
config=[x.to_basic_provider_config() for x in provider_controller.get_credentials_schema()],
|
|
|
|
|
provider_type=provider_controller.provider_type.value,
|
|
|
|
|
provider_identity=provider_controller.entity.identity.name,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
credentials = tool_configuration.decrypt(credentials)
|
|
|
|
|
credentials = tool_configuration.decrypt(db_record.credentials)
|
|
|
|
|
case _:
|
|
|
|
|
raise ValueError(f"Invalid provider type: {provider_type}")
|
|
|
|
|
|
|
|
|
|
return DynamicSelectClient().fetch_dynamic_select_options(
|
|
|
|
|
tenant_id, user_id, plugin_id, provider, action, credentials, parameter
|
|
|
|
|
return (
|
|
|
|
|
DynamicSelectClient()
|
|
|
|
|
.fetch_dynamic_select_options(tenant_id, user_id, plugin_id, provider, action, credentials, parameter)
|
|
|
|
|
.options
|
|
|
|
|
)
|
|
|
|
|
|