mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 01:25:53 +08:00
refactor: rename plugin manager to plugin client and rename path from manager to impl (#18876)
This commit is contained in:
parent
d91828dd90
commit
abafa68647
@ -40,7 +40,7 @@ from core.indexing_runner import IndexingRunner
|
|||||||
from core.model_manager import ModelManager
|
from core.model_manager import ModelManager
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.errors.invoke import InvokeAuthorizationError
|
from core.model_runtime.errors.invoke import InvokeAuthorizationError
|
||||||
from core.plugin.manager.exc import PluginDaemonClientSideError
|
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||||
from core.rag.extractor.entity.extract_setting import ExtractSetting
|
from core.rag.extractor.entity.extract_setting import ExtractSetting
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
|
@ -5,7 +5,7 @@ from werkzeug.exceptions import Forbidden
|
|||||||
from controllers.console import api
|
from controllers.console import api
|
||||||
from controllers.console.wraps import account_initialization_required, setup_required
|
from controllers.console.wraps import account_initialization_required, setup_required
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from core.plugin.manager.exc import PluginPermissionDeniedError
|
from core.plugin.impl.exc import PluginPermissionDeniedError
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from services.plugin.endpoint_service import EndpointService
|
from services.plugin.endpoint_service import EndpointService
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from controllers.console import api
|
|||||||
from controllers.console.workspace import plugin_permission_required
|
from controllers.console.workspace import plugin_permission_required
|
||||||
from controllers.console.wraps import account_initialization_required, setup_required
|
from controllers.console.wraps import account_initialization_required, setup_required
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from core.plugin.manager.exc import PluginDaemonClientSideError
|
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||||
from libs.login import login_required
|
from libs.login import login_required
|
||||||
from models.account import TenantPluginPermission
|
from models.account import TenantPluginPermission
|
||||||
from services.plugin.plugin_permission_service import PluginPermissionService
|
from services.plugin.plugin_permission_service import PluginPermissionService
|
||||||
|
@ -4,7 +4,7 @@ from typing import Any, Optional
|
|||||||
from core.agent.entities import AgentInvokeMessage
|
from core.agent.entities import AgentInvokeMessage
|
||||||
from core.agent.plugin_entities import AgentStrategyEntity, AgentStrategyParameter
|
from core.agent.plugin_entities import AgentStrategyEntity, AgentStrategyParameter
|
||||||
from core.agent.strategy.base import BaseAgentStrategy
|
from core.agent.strategy.base import BaseAgentStrategy
|
||||||
from core.plugin.manager.agent import PluginAgentManager
|
from core.plugin.impl.agent import PluginAgentClient
|
||||||
from core.plugin.utils.converter import convert_parameters_to_plugin_format
|
from core.plugin.utils.converter import convert_parameters_to_plugin_format
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class PluginAgentStrategy(BaseAgentStrategy):
|
|||||||
"""
|
"""
|
||||||
Invoke the agent strategy.
|
Invoke the agent strategy.
|
||||||
"""
|
"""
|
||||||
manager = PluginAgentManager()
|
manager = PluginAgentClient()
|
||||||
|
|
||||||
initialized_params = self.initialize_parameters(params)
|
initialized_params = self.initialize_parameters(params)
|
||||||
params = convert_parameters_to_plugin_format(initialized_params)
|
params = convert_parameters_to_plugin_format(initialized_params)
|
||||||
|
@ -26,7 +26,7 @@ from core.model_runtime.errors.invoke import (
|
|||||||
)
|
)
|
||||||
from core.model_runtime.model_providers.__base.tokenizers.gpt2_tokenzier import GPT2Tokenizer
|
from core.model_runtime.model_providers.__base.tokenizers.gpt2_tokenzier import GPT2Tokenizer
|
||||||
from core.plugin.entities.plugin_daemon import PluginDaemonInnerError, PluginModelProviderEntity
|
from core.plugin.entities.plugin_daemon import PluginDaemonInnerError, PluginModelProviderEntity
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
|
|
||||||
class AIModel(BaseModel):
|
class AIModel(BaseModel):
|
||||||
@ -141,7 +141,7 @@ class AIModel(BaseModel):
|
|||||||
:param credentials: model credentials
|
:param credentials: model credentials
|
||||||
:return: model schema
|
:return: model schema
|
||||||
"""
|
"""
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
cache_key = f"{self.tenant_id}:{self.plugin_id}:{self.provider_name}:{self.model_type.value}:{model}"
|
cache_key = f"{self.tenant_id}:{self.plugin_id}:{self.provider_name}:{self.model_type.value}:{model}"
|
||||||
# sort credentials
|
# sort credentials
|
||||||
sorted_credentials = sorted(credentials.items()) if credentials else []
|
sorted_credentials = sorted(credentials.items()) if credentials else []
|
||||||
|
@ -21,7 +21,7 @@ from core.model_runtime.entities.model_entities import (
|
|||||||
)
|
)
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.model_runtime.utils.helper import convert_llm_result_chunk_to_str
|
from core.model_runtime.utils.helper import convert_llm_result_chunk_to_str
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class LargeLanguageModel(AIModel):
|
|||||||
result: Union[LLMResult, Generator[LLMResultChunk, None, None]]
|
result: Union[LLMResult, Generator[LLMResultChunk, None, None]]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
result = plugin_model_manager.invoke_llm(
|
result = plugin_model_manager.invoke_llm(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id=user or "unknown",
|
user_id=user or "unknown",
|
||||||
@ -329,7 +329,7 @@ class LargeLanguageModel(AIModel):
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if dify_config.PLUGIN_BASED_TOKEN_COUNTING_ENABLED:
|
if dify_config.PLUGIN_BASED_TOKEN_COUNTING_ENABLED:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.get_llm_num_tokens(
|
return plugin_model_manager.get_llm_num_tokens(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id="unknown",
|
user_id="unknown",
|
||||||
|
@ -5,7 +5,7 @@ from pydantic import ConfigDict
|
|||||||
|
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
|
|
||||||
class ModerationModel(AIModel):
|
class ModerationModel(AIModel):
|
||||||
@ -31,7 +31,7 @@ class ModerationModel(AIModel):
|
|||||||
self.started_at = time.perf_counter()
|
self.started_at = time.perf_counter()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.invoke_moderation(
|
return plugin_model_manager.invoke_moderation(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id=user or "unknown",
|
user_id=user or "unknown",
|
||||||
|
@ -3,7 +3,7 @@ from typing import Optional
|
|||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.entities.rerank_entities import RerankResult
|
from core.model_runtime.entities.rerank_entities import RerankResult
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
|
|
||||||
class RerankModel(AIModel):
|
class RerankModel(AIModel):
|
||||||
@ -36,7 +36,7 @@ class RerankModel(AIModel):
|
|||||||
:return: rerank result
|
:return: rerank result
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.invoke_rerank(
|
return plugin_model_manager.invoke_rerank(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id=user or "unknown",
|
user_id=user or "unknown",
|
||||||
|
@ -4,7 +4,7 @@ from pydantic import ConfigDict
|
|||||||
|
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
|
|
||||||
class Speech2TextModel(AIModel):
|
class Speech2TextModel(AIModel):
|
||||||
@ -28,7 +28,7 @@ class Speech2TextModel(AIModel):
|
|||||||
:return: text for given audio file
|
:return: text for given audio file
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.invoke_speech_to_text(
|
return plugin_model_manager.invoke_speech_to_text(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id=user or "unknown",
|
user_id=user or "unknown",
|
||||||
|
@ -6,7 +6,7 @@ from core.entities.embedding_type import EmbeddingInputType
|
|||||||
from core.model_runtime.entities.model_entities import ModelPropertyKey, ModelType
|
from core.model_runtime.entities.model_entities import ModelPropertyKey, ModelType
|
||||||
from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult
|
from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
|
|
||||||
class TextEmbeddingModel(AIModel):
|
class TextEmbeddingModel(AIModel):
|
||||||
@ -38,7 +38,7 @@ class TextEmbeddingModel(AIModel):
|
|||||||
:return: embeddings result
|
:return: embeddings result
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.invoke_text_embedding(
|
return plugin_model_manager.invoke_text_embedding(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id=user or "unknown",
|
user_id=user or "unknown",
|
||||||
@ -61,7 +61,7 @@ class TextEmbeddingModel(AIModel):
|
|||||||
:param texts: texts to embed
|
:param texts: texts to embed
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.get_text_embedding_num_tokens(
|
return plugin_model_manager.get_text_embedding_num_tokens(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id="unknown",
|
user_id="unknown",
|
||||||
|
@ -6,7 +6,7 @@ from pydantic import ConfigDict
|
|||||||
|
|
||||||
from core.model_runtime.entities.model_entities import ModelType
|
from core.model_runtime.entities.model_entities import ModelType
|
||||||
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
from core.model_runtime.model_providers.__base.ai_model import AIModel
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class TTSModel(AIModel):
|
|||||||
:return: translated audio file
|
:return: translated audio file
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.invoke_tts(
|
return plugin_model_manager.invoke_tts(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id=user or "unknown",
|
user_id=user or "unknown",
|
||||||
@ -65,7 +65,7 @@ class TTSModel(AIModel):
|
|||||||
:param credentials: The credentials required to access the TTS model.
|
:param credentials: The credentials required to access the TTS model.
|
||||||
:return: A list of voices supported by the TTS model.
|
:return: A list of voices supported by the TTS model.
|
||||||
"""
|
"""
|
||||||
plugin_model_manager = PluginModelManager()
|
plugin_model_manager = PluginModelClient()
|
||||||
return plugin_model_manager.get_tts_model_voices(
|
return plugin_model_manager.get_tts_model_voices(
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
user_id="unknown",
|
user_id="unknown",
|
||||||
|
@ -22,8 +22,8 @@ from core.model_runtime.schema_validators.model_credential_schema_validator impo
|
|||||||
from core.model_runtime.schema_validators.provider_credential_schema_validator import ProviderCredentialSchemaValidator
|
from core.model_runtime.schema_validators.provider_credential_schema_validator import ProviderCredentialSchemaValidator
|
||||||
from core.plugin.entities.plugin import ModelProviderID
|
from core.plugin.entities.plugin import ModelProviderID
|
||||||
from core.plugin.entities.plugin_daemon import PluginModelProviderEntity
|
from core.plugin.entities.plugin_daemon import PluginModelProviderEntity
|
||||||
from core.plugin.manager.asset import PluginAssetManager
|
from core.plugin.impl.asset import PluginAssetManager
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class ModelProviderFactory:
|
|||||||
self.provider_position_map = {}
|
self.provider_position_map = {}
|
||||||
|
|
||||||
self.tenant_id = tenant_id
|
self.tenant_id = tenant_id
|
||||||
self.plugin_model_manager = PluginModelManager()
|
self.plugin_model_manager = PluginModelClient()
|
||||||
|
|
||||||
if not self.provider_position_map:
|
if not self.provider_position_map:
|
||||||
# get the path of current classes
|
# get the path of current classes
|
||||||
|
@ -6,10 +6,10 @@ from core.plugin.entities.plugin import GenericProviderID
|
|||||||
from core.plugin.entities.plugin_daemon import (
|
from core.plugin.entities.plugin_daemon import (
|
||||||
PluginAgentProviderEntity,
|
PluginAgentProviderEntity,
|
||||||
)
|
)
|
||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
class PluginAgentManager(BasePluginManager):
|
class PluginAgentClient(BasePluginClient):
|
||||||
def fetch_agent_strategy_providers(self, tenant_id: str) -> list[PluginAgentProviderEntity]:
|
def fetch_agent_strategy_providers(self, tenant_id: str) -> list[PluginAgentProviderEntity]:
|
||||||
"""
|
"""
|
||||||
Fetch agent providers for the given tenant.
|
Fetch agent providers for the given tenant.
|
@ -1,7 +1,7 @@
|
|||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
class PluginAssetManager(BasePluginManager):
|
class PluginAssetManager(BasePluginClient):
|
||||||
def fetch_asset(self, tenant_id: str, id: str) -> bytes:
|
def fetch_asset(self, tenant_id: str, id: str) -> bytes:
|
||||||
"""
|
"""
|
||||||
Fetch an asset by id.
|
Fetch an asset by id.
|
@ -18,7 +18,7 @@ from core.model_runtime.errors.invoke import (
|
|||||||
)
|
)
|
||||||
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
from core.model_runtime.errors.validate import CredentialsValidateFailedError
|
||||||
from core.plugin.entities.plugin_daemon import PluginDaemonBasicResponse, PluginDaemonError, PluginDaemonInnerError
|
from core.plugin.entities.plugin_daemon import PluginDaemonBasicResponse, PluginDaemonError, PluginDaemonInnerError
|
||||||
from core.plugin.manager.exc import (
|
from core.plugin.impl.exc import (
|
||||||
PluginDaemonBadRequestError,
|
PluginDaemonBadRequestError,
|
||||||
PluginDaemonInternalServerError,
|
PluginDaemonInternalServerError,
|
||||||
PluginDaemonNotFoundError,
|
PluginDaemonNotFoundError,
|
||||||
@ -37,7 +37,7 @@ T = TypeVar("T", bound=(BaseModel | dict | list | bool | str))
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BasePluginManager:
|
class BasePluginClient:
|
||||||
def _request(
|
def _request(
|
||||||
self,
|
self,
|
||||||
method: str,
|
method: str,
|
@ -1,9 +1,9 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
class PluginDebuggingManager(BasePluginManager):
|
class PluginDebuggingClient(BasePluginClient):
|
||||||
def get_debugging_key(self, tenant_id: str) -> str:
|
def get_debugging_key(self, tenant_id: str) -> str:
|
||||||
"""
|
"""
|
||||||
Get the debugging key for the given tenant.
|
Get the debugging key for the given tenant.
|
@ -1,8 +1,8 @@
|
|||||||
from core.plugin.entities.endpoint import EndpointEntityWithInstance
|
from core.plugin.entities.endpoint import EndpointEntityWithInstance
|
||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
class PluginEndpointManager(BasePluginManager):
|
class PluginEndpointClient(BasePluginClient):
|
||||||
def create_endpoint(
|
def create_endpoint(
|
||||||
self, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict
|
self, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict
|
||||||
) -> bool:
|
) -> bool:
|
@ -18,10 +18,10 @@ from core.plugin.entities.plugin_daemon import (
|
|||||||
PluginTextEmbeddingNumTokensResponse,
|
PluginTextEmbeddingNumTokensResponse,
|
||||||
PluginVoicesResponse,
|
PluginVoicesResponse,
|
||||||
)
|
)
|
||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
class PluginModelManager(BasePluginManager):
|
class PluginModelClient(BasePluginClient):
|
||||||
def fetch_model_providers(self, tenant_id: str) -> Sequence[PluginModelProviderEntity]:
|
def fetch_model_providers(self, tenant_id: str) -> Sequence[PluginModelProviderEntity]:
|
||||||
"""
|
"""
|
||||||
Fetch model providers for the given tenant.
|
Fetch model providers for the given tenant.
|
6
api/core/plugin/impl/oauth.py
Normal file
6
api/core/plugin/impl/oauth.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
|
class OAuthHandler(BasePluginClient):
|
||||||
|
def get_authorization_url(self, tenant_id: str, user_id: str, provider_name: str) -> str:
|
||||||
|
return "1234567890"
|
@ -10,10 +10,10 @@ from core.plugin.entities.plugin import (
|
|||||||
PluginInstallationSource,
|
PluginInstallationSource,
|
||||||
)
|
)
|
||||||
from core.plugin.entities.plugin_daemon import PluginInstallTask, PluginInstallTaskStartResponse, PluginUploadResponse
|
from core.plugin.entities.plugin_daemon import PluginInstallTask, PluginInstallTaskStartResponse, PluginUploadResponse
|
||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
class PluginInstallationManager(BasePluginManager):
|
class PluginInstaller(BasePluginClient):
|
||||||
def fetch_plugin_by_identifier(
|
def fetch_plugin_by_identifier(
|
||||||
self,
|
self,
|
||||||
tenant_id: str,
|
tenant_id: str,
|
@ -5,11 +5,11 @@ from pydantic import BaseModel
|
|||||||
|
|
||||||
from core.plugin.entities.plugin import GenericProviderID, ToolProviderID
|
from core.plugin.entities.plugin import GenericProviderID, ToolProviderID
|
||||||
from core.plugin.entities.plugin_daemon import PluginBasicBooleanResponse, PluginToolProviderEntity
|
from core.plugin.entities.plugin_daemon import PluginBasicBooleanResponse, PluginToolProviderEntity
|
||||||
from core.plugin.manager.base import BasePluginManager
|
from core.plugin.impl.base import BasePluginClient
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter
|
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter
|
||||||
|
|
||||||
|
|
||||||
class PluginToolManager(BasePluginManager):
|
class PluginToolManager(BasePluginClient):
|
||||||
def fetch_tool_providers(self, tenant_id: str) -> list[PluginToolProviderEntity]:
|
def fetch_tool_providers(self, tenant_id: str) -> list[PluginToolProviderEntity]:
|
||||||
"""
|
"""
|
||||||
Fetch tool providers for the given tenant.
|
Fetch tool providers for the given tenant.
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from core.plugin.manager.tool import PluginToolManager
|
from core.plugin.impl.tool import PluginToolManager
|
||||||
from core.tools.__base.tool_runtime import ToolRuntime
|
from core.tools.__base.tool_runtime import ToolRuntime
|
||||||
from core.tools.builtin_tool.provider import BuiltinToolProviderController
|
from core.tools.builtin_tool.provider import BuiltinToolProviderController
|
||||||
from core.tools.entities.tool_entities import ToolProviderEntityWithPlugin, ToolProviderType
|
from core.tools.entities.tool_entities import ToolProviderEntityWithPlugin, ToolProviderType
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from core.plugin.manager.tool import PluginToolManager
|
from core.plugin.impl.tool import PluginToolManager
|
||||||
from core.plugin.utils.converter import convert_parameters_to_plugin_format
|
from core.plugin.utils.converter import convert_parameters_to_plugin_format
|
||||||
from core.tools.__base.tool import Tool
|
from core.tools.__base.tool import Tool
|
||||||
from core.tools.__base.tool_runtime import ToolRuntime
|
from core.tools.__base.tool_runtime import ToolRuntime
|
||||||
|
@ -10,7 +10,7 @@ from yarl import URL
|
|||||||
|
|
||||||
import contexts
|
import contexts
|
||||||
from core.plugin.entities.plugin import ToolProviderID
|
from core.plugin.entities.plugin import ToolProviderID
|
||||||
from core.plugin.manager.tool import PluginToolManager
|
from core.plugin.impl.tool import PluginToolManager
|
||||||
from core.tools.__base.tool_provider import ToolProviderController
|
from core.tools.__base.tool_provider import ToolProviderController
|
||||||
from core.tools.__base.tool_runtime import ToolRuntime
|
from core.tools.__base.tool_runtime import ToolRuntime
|
||||||
from core.tools.plugin_tool.provider import PluginToolProviderController
|
from core.tools.plugin_tool.provider import PluginToolProviderController
|
||||||
|
@ -7,8 +7,8 @@ from core.agent.plugin_entities import AgentStrategyParameter
|
|||||||
from core.memory.token_buffer_memory import TokenBufferMemory
|
from core.memory.token_buffer_memory import TokenBufferMemory
|
||||||
from core.model_manager import ModelInstance, ModelManager
|
from core.model_manager import ModelInstance, ModelManager
|
||||||
from core.model_runtime.entities.model_entities import AIModelEntity, ModelType
|
from core.model_runtime.entities.model_entities import AIModelEntity, ModelType
|
||||||
from core.plugin.manager.exc import PluginDaemonClientSideError
|
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||||
from core.plugin.manager.plugin import PluginInstallationManager
|
from core.plugin.impl.plugin import PluginInstaller
|
||||||
from core.provider_manager import ProviderManager
|
from core.provider_manager import ProviderManager
|
||||||
from core.tools.entities.tool_entities import ToolParameter, ToolProviderType
|
from core.tools.entities.tool_entities import ToolParameter, ToolProviderType
|
||||||
from core.tools.tool_manager import ToolManager
|
from core.tools.tool_manager import ToolManager
|
||||||
@ -297,7 +297,7 @@ class AgentNode(ToolNode):
|
|||||||
Get agent strategy icon
|
Get agent strategy icon
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
plugins = manager.list_plugins(self.tenant_id)
|
plugins = manager.list_plugins(self.tenant_id)
|
||||||
try:
|
try:
|
||||||
current_plugin = next(
|
current_plugin = next(
|
||||||
|
@ -6,8 +6,8 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
|
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
|
||||||
from core.file import File, FileTransferMethod
|
from core.file import File, FileTransferMethod
|
||||||
from core.plugin.manager.exc import PluginDaemonClientSideError
|
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||||
from core.plugin.manager.plugin import PluginInstallationManager
|
from core.plugin.impl.plugin import PluginInstaller
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter
|
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter
|
||||||
from core.tools.errors import ToolInvokeError
|
from core.tools.errors import ToolInvokeError
|
||||||
from core.tools.tool_engine import ToolEngine
|
from core.tools.tool_engine import ToolEngine
|
||||||
@ -307,7 +307,7 @@ class ToolNode(BaseNode[ToolNodeData]):
|
|||||||
icon = tool_info.get("icon", "")
|
icon = tool_info.get("icon", "")
|
||||||
dict_metadata = dict(message.message.metadata)
|
dict_metadata = dict(message.message.metadata)
|
||||||
if dict_metadata.get("provider"):
|
if dict_metadata.get("provider"):
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
plugins = manager.list_plugins(self.tenant_id)
|
plugins = manager.list_plugins(self.tenant_id)
|
||||||
try:
|
try:
|
||||||
current_plugin = next(
|
current_plugin = next(
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from core.agent.strategy.plugin import PluginAgentStrategy
|
from core.agent.strategy.plugin import PluginAgentStrategy
|
||||||
from core.plugin.manager.agent import PluginAgentManager
|
from core.plugin.impl.agent import PluginAgentClient
|
||||||
|
|
||||||
|
|
||||||
def get_plugin_agent_strategy(
|
def get_plugin_agent_strategy(
|
||||||
tenant_id: str, agent_strategy_provider_name: str, agent_strategy_name: str
|
tenant_id: str, agent_strategy_provider_name: str, agent_strategy_name: str
|
||||||
) -> PluginAgentStrategy:
|
) -> PluginAgentStrategy:
|
||||||
# TODO: use contexts to cache the agent provider
|
# TODO: use contexts to cache the agent provider
|
||||||
manager = PluginAgentManager()
|
manager = PluginAgentClient()
|
||||||
agent_provider = manager.fetch_agent_strategy_provider(tenant_id, agent_strategy_provider_name)
|
agent_provider = manager.fetch_agent_strategy_provider(tenant_id, agent_strategy_provider_name)
|
||||||
for agent_strategy in agent_provider.declaration.strategies:
|
for agent_strategy in agent_provider.declaration.strategies:
|
||||||
if agent_strategy.identity.name == agent_strategy_name:
|
if agent_strategy.identity.name == agent_strategy_name:
|
||||||
|
@ -6,8 +6,8 @@ from flask_login import current_user # type: ignore
|
|||||||
|
|
||||||
import contexts
|
import contexts
|
||||||
from core.app.app_config.easy_ui_based_app.agent.manager import AgentConfigManager
|
from core.app.app_config.easy_ui_based_app.agent.manager import AgentConfigManager
|
||||||
from core.plugin.manager.agent import PluginAgentManager
|
from core.plugin.impl.agent import PluginAgentClient
|
||||||
from core.plugin.manager.exc import PluginDaemonClientSideError
|
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||||
from core.tools.tool_manager import ToolManager
|
from core.tools.tool_manager import ToolManager
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from models.account import Account
|
from models.account import Account
|
||||||
@ -161,7 +161,7 @@ class AgentService:
|
|||||||
"""
|
"""
|
||||||
List agent providers
|
List agent providers
|
||||||
"""
|
"""
|
||||||
manager = PluginAgentManager()
|
manager = PluginAgentClient()
|
||||||
return manager.fetch_agent_strategy_providers(tenant_id)
|
return manager.fetch_agent_strategy_providers(tenant_id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -169,7 +169,7 @@ class AgentService:
|
|||||||
"""
|
"""
|
||||||
Get agent provider
|
Get agent provider
|
||||||
"""
|
"""
|
||||||
manager = PluginAgentManager()
|
manager = PluginAgentClient()
|
||||||
try:
|
try:
|
||||||
return manager.fetch_agent_strategy_provider(tenant_id, provider_name)
|
return manager.fetch_agent_strategy_provider(tenant_id, provider_name)
|
||||||
except PluginDaemonClientSideError as e:
|
except PluginDaemonClientSideError as e:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
from core.helper import marketplace
|
from core.helper import marketplace
|
||||||
from core.plugin.entities.plugin import ModelProviderID, PluginDependency, PluginInstallationSource, ToolProviderID
|
from core.plugin.entities.plugin import ModelProviderID, PluginDependency, PluginInstallationSource, ToolProviderID
|
||||||
from core.plugin.manager.plugin import PluginInstallationManager
|
from core.plugin.impl.plugin import PluginInstaller
|
||||||
|
|
||||||
|
|
||||||
class DependenciesAnalysisService:
|
class DependenciesAnalysisService:
|
||||||
@ -38,7 +38,7 @@ class DependenciesAnalysisService:
|
|||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
required_plugin_unique_identifiers.append(dependency.value.plugin_unique_identifier)
|
required_plugin_unique_identifiers.append(dependency.value.plugin_unique_identifier)
|
||||||
|
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
|
|
||||||
# get leaked dependencies
|
# get leaked dependencies
|
||||||
missing_plugins = manager.fetch_missing_dependencies(tenant_id, required_plugin_unique_identifiers)
|
missing_plugins = manager.fetch_missing_dependencies(tenant_id, required_plugin_unique_identifiers)
|
||||||
@ -64,7 +64,7 @@ class DependenciesAnalysisService:
|
|||||||
Generate dependencies through the list of plugin ids
|
Generate dependencies through the list of plugin ids
|
||||||
"""
|
"""
|
||||||
dependencies = list(set(dependencies))
|
dependencies = list(set(dependencies))
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
plugins = manager.fetch_plugin_installation_by_ids(tenant_id, dependencies)
|
plugins = manager.fetch_plugin_installation_by_ids(tenant_id, dependencies)
|
||||||
result = []
|
result = []
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from core.plugin.manager.endpoint import PluginEndpointManager
|
from core.plugin.impl.endpoint import PluginEndpointClient
|
||||||
|
|
||||||
|
|
||||||
class EndpointService:
|
class EndpointService:
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_endpoint(cls, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict):
|
def create_endpoint(cls, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict):
|
||||||
return PluginEndpointManager().create_endpoint(
|
return PluginEndpointClient().create_endpoint(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
plugin_unique_identifier=plugin_unique_identifier,
|
plugin_unique_identifier=plugin_unique_identifier,
|
||||||
@ -14,7 +14,7 @@ class EndpointService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list_endpoints(cls, tenant_id: str, user_id: str, page: int, page_size: int):
|
def list_endpoints(cls, tenant_id: str, user_id: str, page: int, page_size: int):
|
||||||
return PluginEndpointManager().list_endpoints(
|
return PluginEndpointClient().list_endpoints(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
page=page,
|
page=page,
|
||||||
@ -23,7 +23,7 @@ class EndpointService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list_endpoints_for_single_plugin(cls, tenant_id: str, user_id: str, plugin_id: str, page: int, page_size: int):
|
def list_endpoints_for_single_plugin(cls, tenant_id: str, user_id: str, plugin_id: str, page: int, page_size: int):
|
||||||
return PluginEndpointManager().list_endpoints_for_single_plugin(
|
return PluginEndpointClient().list_endpoints_for_single_plugin(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
plugin_id=plugin_id,
|
plugin_id=plugin_id,
|
||||||
@ -33,7 +33,7 @@ class EndpointService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str, name: str, settings: dict):
|
def update_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str, name: str, settings: dict):
|
||||||
return PluginEndpointManager().update_endpoint(
|
return PluginEndpointClient().update_endpoint(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
endpoint_id=endpoint_id,
|
endpoint_id=endpoint_id,
|
||||||
@ -43,7 +43,7 @@ class EndpointService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
|
def delete_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
|
||||||
return PluginEndpointManager().delete_endpoint(
|
return PluginEndpointClient().delete_endpoint(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
endpoint_id=endpoint_id,
|
endpoint_id=endpoint_id,
|
||||||
@ -51,7 +51,7 @@ class EndpointService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def enable_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
|
def enable_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
|
||||||
return PluginEndpointManager().enable_endpoint(
|
return PluginEndpointClient().enable_endpoint(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
endpoint_id=endpoint_id,
|
endpoint_id=endpoint_id,
|
||||||
@ -59,7 +59,7 @@ class EndpointService:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def disable_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
|
def disable_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
|
||||||
return PluginEndpointManager().disable_endpoint(
|
return PluginEndpointClient().disable_endpoint(
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
endpoint_id=endpoint_id,
|
endpoint_id=endpoint_id,
|
||||||
|
7
api/services/plugin/oauth_service.py
Normal file
7
api/services/plugin/oauth_service.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from core.plugin.impl.base import BasePluginClient
|
||||||
|
|
||||||
|
|
||||||
|
class OAuthService(BasePluginClient):
|
||||||
|
@classmethod
|
||||||
|
def get_authorization_url(cls, tenant_id: str, user_id: str, provider_name: str) -> str:
|
||||||
|
return "1234567890"
|
@ -17,7 +17,7 @@ from core.agent.entities import AgentToolEntity
|
|||||||
from core.helper import marketplace
|
from core.helper import marketplace
|
||||||
from core.plugin.entities.plugin import ModelProviderID, PluginInstallationSource, ToolProviderID
|
from core.plugin.entities.plugin import ModelProviderID, PluginInstallationSource, ToolProviderID
|
||||||
from core.plugin.entities.plugin_daemon import PluginInstallTaskStatus
|
from core.plugin.entities.plugin_daemon import PluginInstallTaskStatus
|
||||||
from core.plugin.manager.plugin import PluginInstallationManager
|
from core.plugin.impl.plugin import PluginInstaller
|
||||||
from core.tools.entities.tool_entities import ToolProviderType
|
from core.tools.entities.tool_entities import ToolProviderType
|
||||||
from models.account import Tenant
|
from models.account import Tenant
|
||||||
from models.engine import db
|
from models.engine import db
|
||||||
@ -331,7 +331,7 @@ class PluginMigration:
|
|||||||
"""
|
"""
|
||||||
Install plugins.
|
Install plugins.
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
|
|
||||||
plugins = cls.extract_unique_plugins(extracted_plugins)
|
plugins = cls.extract_unique_plugins(extracted_plugins)
|
||||||
not_installed = []
|
not_installed = []
|
||||||
@ -426,7 +426,7 @@ class PluginMigration:
|
|||||||
"""
|
"""
|
||||||
Install plugins for a tenant.
|
Install plugins for a tenant.
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
|
|
||||||
# download all the plugins and upload
|
# download all the plugins and upload
|
||||||
thread_pool = ThreadPoolExecutor(max_workers=10)
|
thread_pool = ThreadPoolExecutor(max_workers=10)
|
||||||
|
@ -18,9 +18,9 @@ from core.plugin.entities.plugin import (
|
|||||||
PluginInstallationSource,
|
PluginInstallationSource,
|
||||||
)
|
)
|
||||||
from core.plugin.entities.plugin_daemon import PluginInstallTask, PluginUploadResponse
|
from core.plugin.entities.plugin_daemon import PluginInstallTask, PluginUploadResponse
|
||||||
from core.plugin.manager.asset import PluginAssetManager
|
from core.plugin.impl.asset import PluginAssetManager
|
||||||
from core.plugin.manager.debugging import PluginDebuggingManager
|
from core.plugin.impl.debugging import PluginDebuggingClient
|
||||||
from core.plugin.manager.plugin import PluginInstallationManager
|
from core.plugin.impl.plugin import PluginInstaller
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -91,7 +91,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
get the debugging key of the tenant
|
get the debugging key of the tenant
|
||||||
"""
|
"""
|
||||||
manager = PluginDebuggingManager()
|
manager = PluginDebuggingClient()
|
||||||
return manager.get_debugging_key(tenant_id)
|
return manager.get_debugging_key(tenant_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -106,7 +106,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
list all plugins of the tenant
|
list all plugins of the tenant
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
plugins = manager.list_plugins(tenant_id)
|
plugins = manager.list_plugins(tenant_id)
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
List plugin installations from ids
|
List plugin installations from ids
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.fetch_plugin_installation_by_ids(tenant_id, ids)
|
return manager.fetch_plugin_installation_by_ids(tenant_id, ids)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -133,7 +133,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
check if the plugin unique identifier is already installed by other tenant
|
check if the plugin unique identifier is already installed by other tenant
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.fetch_plugin_by_identifier(tenant_id, plugin_unique_identifier)
|
return manager.fetch_plugin_by_identifier(tenant_id, plugin_unique_identifier)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -141,7 +141,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Fetch plugin manifest
|
Fetch plugin manifest
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.fetch_plugin_manifest(tenant_id, plugin_unique_identifier)
|
return manager.fetch_plugin_manifest(tenant_id, plugin_unique_identifier)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -149,12 +149,12 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Fetch plugin installation tasks
|
Fetch plugin installation tasks
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.fetch_plugin_installation_tasks(tenant_id, page, page_size)
|
return manager.fetch_plugin_installation_tasks(tenant_id, page, page_size)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fetch_install_task(tenant_id: str, task_id: str) -> PluginInstallTask:
|
def fetch_install_task(tenant_id: str, task_id: str) -> PluginInstallTask:
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.fetch_plugin_installation_task(tenant_id, task_id)
|
return manager.fetch_plugin_installation_task(tenant_id, task_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -162,7 +162,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Delete a plugin installation task
|
Delete a plugin installation task
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.delete_plugin_installation_task(tenant_id, task_id)
|
return manager.delete_plugin_installation_task(tenant_id, task_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -172,7 +172,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Delete all plugin installation task items
|
Delete all plugin installation task items
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.delete_all_plugin_installation_task_items(tenant_id)
|
return manager.delete_all_plugin_installation_task_items(tenant_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -180,7 +180,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Delete a plugin installation task item
|
Delete a plugin installation task item
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.delete_plugin_installation_task_item(tenant_id, task_id, identifier)
|
return manager.delete_plugin_installation_task_item(tenant_id, task_id, identifier)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -197,7 +197,7 @@ class PluginService:
|
|||||||
raise ValueError("you should not upgrade plugin with the same plugin")
|
raise ValueError("you should not upgrade plugin with the same plugin")
|
||||||
|
|
||||||
# check if plugin pkg is already downloaded
|
# check if plugin pkg is already downloaded
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
manager.fetch_plugin_manifest(tenant_id, new_plugin_unique_identifier)
|
manager.fetch_plugin_manifest(tenant_id, new_plugin_unique_identifier)
|
||||||
@ -230,7 +230,7 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Upgrade plugin with github
|
Upgrade plugin with github
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.upgrade_plugin(
|
return manager.upgrade_plugin(
|
||||||
tenant_id,
|
tenant_id,
|
||||||
original_plugin_unique_identifier,
|
original_plugin_unique_identifier,
|
||||||
@ -250,7 +250,7 @@ class PluginService:
|
|||||||
|
|
||||||
returns: plugin_unique_identifier
|
returns: plugin_unique_identifier
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.upload_pkg(tenant_id, pkg, verify_signature)
|
return manager.upload_pkg(tenant_id, pkg, verify_signature)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -265,7 +265,7 @@ class PluginService:
|
|||||||
f"https://github.com/{repo}/releases/download/{version}/{package}", dify_config.PLUGIN_MAX_PACKAGE_SIZE
|
f"https://github.com/{repo}/releases/download/{version}/{package}", dify_config.PLUGIN_MAX_PACKAGE_SIZE
|
||||||
)
|
)
|
||||||
|
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.upload_pkg(
|
return manager.upload_pkg(
|
||||||
tenant_id,
|
tenant_id,
|
||||||
pkg,
|
pkg,
|
||||||
@ -279,12 +279,12 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Upload a plugin bundle and return the dependencies.
|
Upload a plugin bundle and return the dependencies.
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.upload_bundle(tenant_id, bundle, verify_signature)
|
return manager.upload_bundle(tenant_id, bundle, verify_signature)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def install_from_local_pkg(tenant_id: str, plugin_unique_identifiers: Sequence[str]):
|
def install_from_local_pkg(tenant_id: str, plugin_unique_identifiers: Sequence[str]):
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.install_from_identifiers(
|
return manager.install_from_identifiers(
|
||||||
tenant_id,
|
tenant_id,
|
||||||
plugin_unique_identifiers,
|
plugin_unique_identifiers,
|
||||||
@ -298,7 +298,7 @@ class PluginService:
|
|||||||
Install plugin from github release package files,
|
Install plugin from github release package files,
|
||||||
returns plugin_unique_identifier
|
returns plugin_unique_identifier
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.install_from_identifiers(
|
return manager.install_from_identifiers(
|
||||||
tenant_id,
|
tenant_id,
|
||||||
[plugin_unique_identifier],
|
[plugin_unique_identifier],
|
||||||
@ -322,7 +322,7 @@ class PluginService:
|
|||||||
if not dify_config.MARKETPLACE_ENABLED:
|
if not dify_config.MARKETPLACE_ENABLED:
|
||||||
raise ValueError("marketplace is not enabled")
|
raise ValueError("marketplace is not enabled")
|
||||||
|
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
try:
|
try:
|
||||||
declaration = manager.fetch_plugin_manifest(tenant_id, plugin_unique_identifier)
|
declaration = manager.fetch_plugin_manifest(tenant_id, plugin_unique_identifier)
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -342,7 +342,7 @@ class PluginService:
|
|||||||
if not dify_config.MARKETPLACE_ENABLED:
|
if not dify_config.MARKETPLACE_ENABLED:
|
||||||
raise ValueError("marketplace is not enabled")
|
raise ValueError("marketplace is not enabled")
|
||||||
|
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
|
|
||||||
# check if already downloaded
|
# check if already downloaded
|
||||||
for plugin_unique_identifier in plugin_unique_identifiers:
|
for plugin_unique_identifier in plugin_unique_identifiers:
|
||||||
@ -368,7 +368,7 @@ class PluginService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def uninstall(tenant_id: str, plugin_installation_id: str) -> bool:
|
def uninstall(tenant_id: str, plugin_installation_id: str) -> bool:
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.uninstall(tenant_id, plugin_installation_id)
|
return manager.uninstall(tenant_id, plugin_installation_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -376,5 +376,5 @@ class PluginService:
|
|||||||
"""
|
"""
|
||||||
Check if the tools exist
|
Check if the tools exist
|
||||||
"""
|
"""
|
||||||
manager = PluginInstallationManager()
|
manager = PluginInstaller()
|
||||||
return manager.check_tools_existence(tenant_id, provider_ids)
|
return manager.check_tools_existence(tenant_id, provider_ids)
|
||||||
|
@ -8,7 +8,7 @@ from configs import dify_config
|
|||||||
from core.helper.position_helper import is_filtered
|
from core.helper.position_helper import is_filtered
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from core.plugin.entities.plugin import GenericProviderID, ToolProviderID
|
from core.plugin.entities.plugin import GenericProviderID, ToolProviderID
|
||||||
from core.plugin.manager.exc import PluginDaemonClientSideError
|
from core.plugin.impl.exc import PluginDaemonClientSideError
|
||||||
from core.tools.builtin_tool.providers._positions import BuiltinToolProviderSort
|
from core.tools.builtin_tool.providers._positions import BuiltinToolProviderSort
|
||||||
from core.tools.entities.api_entities import ToolApiEntity, ToolProviderApiEntity
|
from core.tools.entities.api_entities import ToolApiEntity, ToolProviderApiEntity
|
||||||
from core.tools.errors import ToolNotFoundError, ToolProviderCredentialValidationError, ToolProviderNotFoundError
|
from core.tools.errors import ToolNotFoundError, ToolProviderCredentialValidationError, ToolProviderNotFoundError
|
||||||
|
@ -6,7 +6,7 @@ import pytest
|
|||||||
# import monkeypatch
|
# import monkeypatch
|
||||||
from _pytest.monkeypatch import MonkeyPatch
|
from _pytest.monkeypatch import MonkeyPatch
|
||||||
|
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
from tests.integration_tests.model_runtime.__mock.plugin_model import MockModelClass
|
from tests.integration_tests.model_runtime.__mock.plugin_model import MockModelClass
|
||||||
|
|
||||||
|
|
||||||
@ -23,9 +23,9 @@ def mock_plugin_daemon(
|
|||||||
def unpatch() -> None:
|
def unpatch() -> None:
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
monkeypatch.setattr(PluginModelManager, "invoke_llm", MockModelClass.invoke_llm)
|
monkeypatch.setattr(PluginModelClient, "invoke_llm", MockModelClass.invoke_llm)
|
||||||
monkeypatch.setattr(PluginModelManager, "fetch_model_providers", MockModelClass.fetch_model_providers)
|
monkeypatch.setattr(PluginModelClient, "fetch_model_providers", MockModelClass.fetch_model_providers)
|
||||||
monkeypatch.setattr(PluginModelManager, "get_model_schema", MockModelClass.get_model_schema)
|
monkeypatch.setattr(PluginModelClient, "get_model_schema", MockModelClass.get_model_schema)
|
||||||
|
|
||||||
return unpatch
|
return unpatch
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@ from core.model_runtime.entities.model_entities import (
|
|||||||
)
|
)
|
||||||
from core.model_runtime.entities.provider_entities import ConfigurateMethod, ProviderEntity
|
from core.model_runtime.entities.provider_entities import ConfigurateMethod, ProviderEntity
|
||||||
from core.plugin.entities.plugin_daemon import PluginModelProviderEntity
|
from core.plugin.entities.plugin_daemon import PluginModelProviderEntity
|
||||||
from core.plugin.manager.model import PluginModelManager
|
from core.plugin.impl.model import PluginModelClient
|
||||||
|
|
||||||
|
|
||||||
class MockModelClass(PluginModelManager):
|
class MockModelClass(PluginModelClient):
|
||||||
def fetch_model_providers(self, tenant_id: str) -> Sequence[PluginModelProviderEntity]:
|
def fetch_model_providers(self, tenant_id: str) -> Sequence[PluginModelProviderEntity]:
|
||||||
"""
|
"""
|
||||||
Fetch model providers for the given tenant.
|
Fetch model providers for the given tenant.
|
||||||
@ -232,7 +232,7 @@ class MockModelClass(PluginModelManager):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def invoke_llm(
|
def invoke_llm(
|
||||||
self: PluginModelManager,
|
self: PluginModelClient,
|
||||||
*,
|
*,
|
||||||
tenant_id: str,
|
tenant_id: str,
|
||||||
user_id: str,
|
user_id: str,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from core.plugin.manager.tool import PluginToolManager
|
from core.plugin.impl.tool import PluginToolManager
|
||||||
from tests.integration_tests.plugin.__mock.http import setup_http_mock
|
from tests.integration_tests.plugin.__mock.http import setup_http_mock
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user