mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 11:04:27 +08:00
Merge branch 'fix/chore-fix' into dev/plugin-deploy
This commit is contained in:
commit
e7a6bc0ec9
@ -1,5 +1,4 @@
|
|||||||
import decimal
|
import decimal
|
||||||
from abc import abstractmethod
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
@ -38,17 +37,6 @@ class AIModel(BaseModel):
|
|||||||
# pydantic configs
|
# pydantic configs
|
||||||
model_config = ConfigDict(protected_namespaces=())
|
model_config = ConfigDict(protected_namespaces=())
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def validate_credentials(self, model: str, credentials: dict) -> None:
|
|
||||||
"""
|
|
||||||
Validate model credentials
|
|
||||||
|
|
||||||
:param model: model name
|
|
||||||
:param credentials: model credentials
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _invoke_error_mapping(self) -> dict[type[Exception], list[type[Exception]]]:
|
def _invoke_error_mapping(self) -> dict[type[Exception], list[type[Exception]]]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -24,6 +24,7 @@ from core.plugin.manager.exc import (
|
|||||||
PluginDaemonNotFoundError,
|
PluginDaemonNotFoundError,
|
||||||
PluginDaemonUnauthorizedError,
|
PluginDaemonUnauthorizedError,
|
||||||
PluginInvokeError,
|
PluginInvokeError,
|
||||||
|
PluginNotFoundError,
|
||||||
PluginPermissionDeniedError,
|
PluginPermissionDeniedError,
|
||||||
PluginUniqueIdentifierError,
|
PluginUniqueIdentifierError,
|
||||||
)
|
)
|
||||||
@ -143,7 +144,7 @@ class BasePluginManager:
|
|||||||
if rep.code != 0:
|
if rep.code != 0:
|
||||||
try:
|
try:
|
||||||
error = PluginDaemonError(**json.loads(rep.message))
|
error = PluginDaemonError(**json.loads(rep.message))
|
||||||
except Exception as e:
|
except Exception:
|
||||||
raise ValueError(f"{rep.message}, code: {rep.code}")
|
raise ValueError(f"{rep.message}, code: {rep.code}")
|
||||||
|
|
||||||
self._handle_plugin_daemon_error(error.error_type, error.message)
|
self._handle_plugin_daemon_error(error.error_type, error.message)
|
||||||
@ -171,7 +172,7 @@ class BasePluginManager:
|
|||||||
try:
|
try:
|
||||||
line_data = json.loads(line)
|
line_data = json.loads(line)
|
||||||
rep = PluginDaemonBasicResponse[type](**line_data)
|
rep = PluginDaemonBasicResponse[type](**line_data)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# TODO modify this when line_data has code and message
|
# TODO modify this when line_data has code and message
|
||||||
if line_data and "error" in line_data:
|
if line_data and "error" in line_data:
|
||||||
raise ValueError(line_data["error"])
|
raise ValueError(line_data["error"])
|
||||||
@ -182,7 +183,7 @@ class BasePluginManager:
|
|||||||
if rep.code == -500:
|
if rep.code == -500:
|
||||||
try:
|
try:
|
||||||
error = PluginDaemonError(**json.loads(rep.message))
|
error = PluginDaemonError(**json.loads(rep.message))
|
||||||
except Exception as e:
|
except Exception:
|
||||||
raise PluginDaemonInnerError(code=rep.code, message=rep.message)
|
raise PluginDaemonInnerError(code=rep.code, message=rep.message)
|
||||||
|
|
||||||
self._handle_plugin_daemon_error(error.error_type, error.message)
|
self._handle_plugin_daemon_error(error.error_type, error.message)
|
||||||
@ -226,6 +227,8 @@ class BasePluginManager:
|
|||||||
raise PluginDaemonNotFoundError(description=message)
|
raise PluginDaemonNotFoundError(description=message)
|
||||||
case PluginUniqueIdentifierError.__name__:
|
case PluginUniqueIdentifierError.__name__:
|
||||||
raise PluginUniqueIdentifierError(description=message)
|
raise PluginUniqueIdentifierError(description=message)
|
||||||
|
case PluginNotFoundError.__name__:
|
||||||
|
raise PluginNotFoundError(description=message)
|
||||||
case PluginDaemonUnauthorizedError.__name__:
|
case PluginDaemonUnauthorizedError.__name__:
|
||||||
raise PluginDaemonUnauthorizedError(description=message)
|
raise PluginDaemonUnauthorizedError(description=message)
|
||||||
case PluginPermissionDeniedError.__name__:
|
case PluginPermissionDeniedError.__name__:
|
||||||
|
|||||||
@ -7,6 +7,7 @@ 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.manager.agent import PluginAgentManager
|
||||||
|
from core.plugin.manager.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
|
||||||
@ -169,4 +170,7 @@ class AgentService:
|
|||||||
Get agent provider
|
Get agent provider
|
||||||
"""
|
"""
|
||||||
manager = PluginAgentManager()
|
manager = PluginAgentManager()
|
||||||
return manager.fetch_agent_strategy_provider(tenant_id, provider_name)
|
try:
|
||||||
|
return manager.fetch_agent_strategy_provider(tenant_id, provider_name)
|
||||||
|
except PluginDaemonClientSideError as e:
|
||||||
|
raise ValueError(str(e)) from e
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user