mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 08:58:09 +08:00
refactor: using plugin id to dispatch request instead
This commit is contained in:
@ -20,7 +20,13 @@ class PluginEncrypter:
|
||||
return {
|
||||
"data": encrypter.encrypt(payload.data),
|
||||
}
|
||||
else:
|
||||
elif payload.opt == "decrypt":
|
||||
return {
|
||||
"data": encrypter.decrypt(payload.data),
|
||||
}
|
||||
elif payload.opt == "clear":
|
||||
return {
|
||||
"data": encrypter.delete_tool_credentials_cache(),
|
||||
}
|
||||
else:
|
||||
raise ValueError(f"Invalid opt: {payload.opt}")
|
||||
|
||||
@ -173,7 +173,7 @@ class RequestInvokeEncrypt(BaseModel):
|
||||
Request to encryption
|
||||
"""
|
||||
|
||||
opt: Literal["encrypt", "decrypt"]
|
||||
opt: Literal["encrypt", "decrypt", "clear"]
|
||||
namespace: Literal["endpoint"]
|
||||
identity: str
|
||||
data: dict = Field(default_factory=dict)
|
||||
|
||||
@ -34,7 +34,7 @@ class PluginToolManager(BasePluginManager):
|
||||
self,
|
||||
tenant_id: str,
|
||||
user_id: str,
|
||||
plugin_unique_identifier: str,
|
||||
plugin_id: str,
|
||||
tool_provider: str,
|
||||
tool_name: str,
|
||||
credentials: dict[str, Any],
|
||||
@ -45,7 +45,6 @@ class PluginToolManager(BasePluginManager):
|
||||
f"plugin/{tenant_id}/dispatch/tool/invoke",
|
||||
ToolInvokeMessage,
|
||||
data={
|
||||
"plugin_unique_identifier": plugin_unique_identifier,
|
||||
"user_id": user_id,
|
||||
"data": {
|
||||
"provider": tool_provider,
|
||||
@ -55,14 +54,14 @@ class PluginToolManager(BasePluginManager):
|
||||
},
|
||||
},
|
||||
headers={
|
||||
"X-Plugin-Identifier": plugin_unique_identifier,
|
||||
"X-Plugin-ID": plugin_id,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
},
|
||||
)
|
||||
return response
|
||||
|
||||
def validate_provider_credentials(
|
||||
self, tenant_id: str, user_id: str, plugin_unique_identifier: str, provider: str, credentials: dict[str, Any]
|
||||
self, tenant_id: str, user_id: str, plugin_id: str, provider: str, credentials: dict[str, Any]
|
||||
) -> bool:
|
||||
"""
|
||||
validate the credentials of the provider
|
||||
@ -72,7 +71,6 @@ class PluginToolManager(BasePluginManager):
|
||||
f"plugin/{tenant_id}/dispatch/tool/validate_credentials",
|
||||
PluginBasicBooleanResponse,
|
||||
data={
|
||||
"plugin_unique_identifier": plugin_unique_identifier,
|
||||
"user_id": user_id,
|
||||
"data": {
|
||||
"provider": provider,
|
||||
@ -80,12 +78,12 @@ class PluginToolManager(BasePluginManager):
|
||||
},
|
||||
},
|
||||
headers={
|
||||
"X-Plugin-Identifier": plugin_unique_identifier,
|
||||
"X-Plugin-ID": plugin_id,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
for resp in response:
|
||||
return resp.result
|
||||
|
||||
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user