@@ -59,16 +59,43 @@ def get_config():
5959
6060@router .post ("/update" , response_model = response .UpdateWorkflows )
6161def update_workflows ():
62- base_path = Path (WORKFLOWS_BASE )
62+ chat_config_path = Path (CHAT_DIR ) / CHAT_CONFIG_FILENAME
6363
64- if HAS_GIT :
65- updated , message = update_by_git (base_path )
66- else :
67- updated , message = update_by_zip (base_path )
64+ if chat_config_path .exists ():
65+ with open (chat_config_path , "r" , encoding = "utf-8" ) as file :
66+ chat_config = yaml .safe_load (file )
67+
68+ providers = chat_config .get ("providers" , {})
69+ devchat_api_key = providers .get ("devchat" , {}).get ("api_key" , "" )
70+ openai_api_key = providers .get ("openai" , {}).get ("api_key" , "" )
71+
72+ if devchat_api_key or openai_api_key :
73+ update_public_workflow = chat_config .get ("update_public_workflow" , True )
6874
69- copy_workflows_usr ()
75+ if update_public_workflow :
76+ base_path = Path (WORKFLOWS_BASE )
7077
71- return response .UpdateWorkflows (updated = updated , message = message )
78+ if HAS_GIT :
79+ updated , message = update_by_git (base_path )
80+ else :
81+ updated , message = update_by_zip (base_path )
82+
83+ copy_workflows_usr ()
84+
85+ return response .UpdateWorkflows (updated = updated , message = message )
86+ else :
87+ return response .UpdateWorkflows (
88+ updated = False ,
89+ message = "Workflow update has been ignored due to configuration settings." ,
90+ )
91+ else :
92+ return response .UpdateWorkflows (
93+ updated = False , message = "No valid API key found, workflow update ignored."
94+ )
95+ else :
96+ return response .UpdateWorkflows (
97+ updated = False , message = "Configuration file not found, workflow update ignored."
98+ )
7299
73100
74101@router .post ("/custom_update" , response_model = response .UpdateWorkflows )
0 commit comments