mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-12-02 19:27:48 +08:00
fix: delete tool parameters cache when sync draft workflow for run workflow use new parameter change in draft workflow (#3637)
This commit is contained in:
parent
d77f52bf85
commit
71cc0074ef
@ -11,3 +11,6 @@ app_model_config_was_updated = signal('app-model-config-was-updated')
|
||||
|
||||
# sender: app, kwargs: published_workflow
|
||||
app_published_workflow_was_updated = signal('app-published-workflow-was-updated')
|
||||
|
||||
# sender: app, kwargs: synced_draft_workflow
|
||||
app_draft_workflow_was_synced = signal('app-draft-workflow-was-synced')
|
||||
|
@ -5,6 +5,7 @@ from .create_installed_app_when_app_created import handle
|
||||
from .create_site_record_when_app_created import handle
|
||||
from .deduct_quota_when_messaeg_created import handle
|
||||
from .delete_installed_app_when_app_deleted import handle
|
||||
from .delete_tool_parameters_cache_when_sync_draft_workflow import handle
|
||||
from .update_app_dataset_join_when_app_model_config_updated import handle
|
||||
from .update_app_dataset_join_when_app_published_workflow_updated import handle
|
||||
from .update_provider_last_used_at_when_messaeg_created import handle
|
||||
|
@ -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()
|
@ -9,7 +9,7 @@ from core.model_runtime.utils.encoders import jsonable_encoder
|
||||
from core.workflow.entities.node_entities import NodeType
|
||||
from core.workflow.errors import WorkflowNodeRunFailedError
|
||||
from core.workflow.workflow_engine_manager import WorkflowEngineManager
|
||||
from events.app_event import app_published_workflow_was_updated
|
||||
from events.app_event import app_draft_workflow_was_synced, app_published_workflow_was_updated
|
||||
from extensions.ext_database import db
|
||||
from models.account import Account
|
||||
from models.model import App, AppMode
|
||||
@ -98,6 +98,9 @@ class WorkflowService:
|
||||
# commit db session changes
|
||||
db.session.commit()
|
||||
|
||||
# trigger app workflow events
|
||||
app_draft_workflow_was_synced.send(app_model, synced_draft_workflow=workflow)
|
||||
|
||||
# return draft workflow
|
||||
return workflow
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user