mirror of
https://github.com/langgenius/dify.git
synced 2026-04-30 13:37:24 +08:00
remove publish workflow when app import
This commit is contained in:
parent
742b87df5e
commit
7d51d6030b
@ -155,10 +155,9 @@ class AppService:
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
if workflow_graph:
|
if workflow_graph:
|
||||||
|
# init draft workflow
|
||||||
workflow_service = WorkflowService()
|
workflow_service = WorkflowService()
|
||||||
draft_workflow = workflow_service.sync_draft_workflow(app, workflow_graph, account)
|
workflow_service.sync_draft_workflow(app, workflow_graph, account)
|
||||||
published_workflow = workflow_service.publish_draft_workflow(app, account, draft_workflow)
|
|
||||||
model_config_data['workflow_id'] = published_workflow.id
|
|
||||||
|
|
||||||
app_model_config = AppModelConfig()
|
app_model_config = AppModelConfig()
|
||||||
app_model_config = app_model_config.from_model_config_dict(model_config_data)
|
app_model_config = app_model_config.from_model_config_dict(model_config_data)
|
||||||
@ -282,5 +281,3 @@ class AppService:
|
|||||||
# conversations, pinned_conversations, messages BY app
|
# conversations, pinned_conversations, messages BY app
|
||||||
# message_feedbacks, message_annotations, message_chains BY message
|
# message_feedbacks, message_annotations, message_chains BY message
|
||||||
# message_agent_thoughts, message_files, saved_messages BY message
|
# message_agent_thoughts, message_files, saved_messages BY message
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -59,11 +59,11 @@ class WorkflowService:
|
|||||||
# return draft workflow
|
# return draft workflow
|
||||||
return workflow
|
return workflow
|
||||||
|
|
||||||
def publish_draft_workflow(self, app_model: App,
|
def publish_workflow(self, app_model: App,
|
||||||
account: Account,
|
account: Account,
|
||||||
draft_workflow: Optional[Workflow] = None) -> Workflow:
|
draft_workflow: Optional[Workflow] = None) -> Workflow:
|
||||||
"""
|
"""
|
||||||
Publish draft workflow
|
Publish workflow from draft
|
||||||
|
|
||||||
:param app_model: App instance
|
:param app_model: App instance
|
||||||
:param account: Account instance
|
:param account: Account instance
|
||||||
@ -76,6 +76,8 @@ class WorkflowService:
|
|||||||
if not draft_workflow:
|
if not draft_workflow:
|
||||||
raise ValueError('No valid workflow found.')
|
raise ValueError('No valid workflow found.')
|
||||||
|
|
||||||
|
# TODO check if the workflow is valid
|
||||||
|
|
||||||
# create new workflow
|
# create new workflow
|
||||||
workflow = Workflow(
|
workflow = Workflow(
|
||||||
tenant_id=app_model.tenant_id,
|
tenant_id=app_model.tenant_id,
|
||||||
@ -90,6 +92,30 @@ class WorkflowService:
|
|||||||
db.session.add(workflow)
|
db.session.add(workflow)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
app_model_config = app_model.app_model_config
|
||||||
|
|
||||||
|
# create new app model config record
|
||||||
|
new_app_model_config = app_model_config.copy()
|
||||||
|
new_app_model_config.id = None
|
||||||
|
new_app_model_config.app_id = app_model.id
|
||||||
|
new_app_model_config.external_data_tools = ''
|
||||||
|
new_app_model_config.model = ''
|
||||||
|
new_app_model_config.user_input_form = ''
|
||||||
|
new_app_model_config.dataset_query_variable = None
|
||||||
|
new_app_model_config.pre_prompt = None
|
||||||
|
new_app_model_config.agent_mode = ''
|
||||||
|
new_app_model_config.prompt_type = 'simple'
|
||||||
|
new_app_model_config.chat_prompt_config = ''
|
||||||
|
new_app_model_config.completion_prompt_config = ''
|
||||||
|
new_app_model_config.dataset_configs = ''
|
||||||
|
new_app_model_config.workflow_id = workflow.id
|
||||||
|
|
||||||
|
db.session.add(new_app_model_config)
|
||||||
|
db.session.flush()
|
||||||
|
|
||||||
|
app_model.app_model_config_id = new_app_model_config.id
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
# return new workflow
|
# return new workflow
|
||||||
return workflow
|
return workflow
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user