mirror of https://github.com/langgenius/dify.git
remove publish workflow when app import
This commit is contained in:
parent
594de43dec
commit
403c2f436d
|
|
@ -155,10 +155,9 @@ class AppService:
|
|||
db.session.commit()
|
||||
|
||||
if workflow_graph:
|
||||
# init draft workflow
|
||||
workflow_service = WorkflowService()
|
||||
draft_workflow = 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
|
||||
workflow_service.sync_draft_workflow(app, workflow_graph, account)
|
||||
|
||||
app_model_config = AppModelConfig()
|
||||
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
|
||||
# message_feedbacks, message_annotations, message_chains BY message
|
||||
# message_agent_thoughts, message_files, saved_messages BY message
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ class WorkflowService:
|
|||
# return draft workflow
|
||||
return workflow
|
||||
|
||||
def publish_draft_workflow(self, app_model: App,
|
||||
account: Account,
|
||||
draft_workflow: Optional[Workflow] = None) -> Workflow:
|
||||
def publish_workflow(self, app_model: App,
|
||||
account: Account,
|
||||
draft_workflow: Optional[Workflow] = None) -> Workflow:
|
||||
"""
|
||||
Publish draft workflow
|
||||
Publish workflow from draft
|
||||
|
||||
:param app_model: App instance
|
||||
:param account: Account instance
|
||||
|
|
@ -76,6 +76,8 @@ class WorkflowService:
|
|||
if not draft_workflow:
|
||||
raise ValueError('No valid workflow found.')
|
||||
|
||||
# TODO check if the workflow is valid
|
||||
|
||||
# create new workflow
|
||||
workflow = Workflow(
|
||||
tenant_id=app_model.tenant_id,
|
||||
|
|
@ -90,6 +92,30 @@ class WorkflowService:
|
|||
db.session.add(workflow)
|
||||
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 workflow
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue