forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: delete tool parameters cache when sync draft workflow for run wo…
…rkflow use new parameter change in draft workflow (langgenius#3637)
- Loading branch information
1 parent
a11a158
commit c4509b9
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
api/events/event_handlers/delete_tool_parameters_cache_when_sync_draft_workflow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from core.tools.tool_manager import ToolManager | ||
from core.tools.utils.configuration import ToolParameterConfigurationManager | ||
from core.workflow.entities.node_entities import NodeType | ||
from core.workflow.nodes.tool.entities import ToolEntity | ||
from events.app_event import app_draft_workflow_was_synced | ||
|
||
|
||
@app_draft_workflow_was_synced.connect | ||
def handle(sender, **kwargs): | ||
app = sender | ||
for node_data in kwargs.get('synced_draft_workflow').graph_dict.get('nodes', []): | ||
if node_data.get('data', {}).get('type') == NodeType.TOOL.value: | ||
tool_entity = ToolEntity(**node_data["data"]) | ||
tool_runtime = ToolManager.get_tool_runtime( | ||
provider_type=tool_entity.provider_type, | ||
provider_name=tool_entity.provider_id, | ||
tool_name=tool_entity.tool_name, | ||
tenant_id=app.tenant_id, | ||
) | ||
manager = ToolParameterConfigurationManager( | ||
tenant_id=app.tenant_id, | ||
tool_runtime=tool_runtime, | ||
provider_name=tool_entity.provider_name, | ||
provider_type=tool_entity.provider_type, | ||
) | ||
manager.delete_tool_parameters_cache() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters