dify知识库同步/删除问题修复
This commit is contained in:
1 parent
4ff07f8f9b
commit
c14046f9f3
8 files changed
+89
-44
No files matched your search
@@ -1036,10 +1036,11 @@ def delete_document(document_id: int):
|
||||
if not document or document.is_deleted:
|
||||
return jsonify({'error': 'Knowledge base document not found'}), 404
|
||||
|
||||
delete_result = None
|
||||
try:
|
||||
delete_result = delete_document_from_dify(document.id)
|
||||
except Exception as exc:
|
||||
return jsonify({'error': f'删除 Dify 远端文档失败:{exc}'}), 400
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
document.is_deleted = True
|
||||
document.updated_by_id = getattr(current_user, 'id', None)
|
||||
|
||||
@@ -39,7 +39,7 @@ def _load_environment_files() -> str:
|
||||
|
||||
env_file = _ROOT_DIR / f'.env.{env_name}'
|
||||
if env_file.exists():
|
||||
load_dotenv(env_file, override=False)
|
||||
load_dotenv(env_file, override=True)
|
||||
|
||||
if env_name == 'dev':
|
||||
local_file = _ROOT_DIR / '.env.local'
|
||||
@@ -64,6 +64,10 @@ class Config:
|
||||
'pool_recycle': 3600,
|
||||
'pool_pre_ping': True,
|
||||
}
|
||||
PUBLIC_BASE_URL = os.getenv('PUBLIC_BASE_URL')
|
||||
DEFAULT_ADMIN_USERNAME = os.getenv('DEFAULT_ADMIN_USERNAME')
|
||||
DEFAULT_ADMIN_PASSWORD = os.getenv('DEFAULT_ADMIN_PASSWORD')
|
||||
TASK_EXECUTION_MODE = os.getenv('TASK_EXECUTION_MODE', 'sync').strip().lower()
|
||||
# Dify 网关配置
|
||||
DIFY_API_BASE = os.getenv('DIFY_API_BASE')
|
||||
DIFY_API_KEY = os.getenv('DIFY_API_KEY')
|
||||
|
||||
@@ -17,7 +17,10 @@ def enqueue_kb_job(job_id: int) -> tuple[bool, str]:
|
||||
- worker: 仅保留 queued,等待独立 worker 轮询;
|
||||
- manual: 保留 queued,等待管理台手动执行。
|
||||
"""
|
||||
mode = str(current_app.config.get('KB_TASK_EXECUTION_MODE', 'sync')).strip().lower()
|
||||
mode = str(
|
||||
current_app.config.get('TASK_EXECUTION_MODE')
|
||||
or current_app.config.get('KB_TASK_EXECUTION_MODE', 'sync')
|
||||
).strip().lower()
|
||||
|
||||
job = db.session.get(KbJob, job_id)
|
||||
if not job:
|
||||
@@ -32,7 +35,7 @@ def enqueue_kb_job(job_id: int) -> tuple[bool, str]:
|
||||
return run_path_upload_job(job_id)
|
||||
return False, f'unsupported_sync_job:{job.job_type}'
|
||||
|
||||
if mode == 'worker':
|
||||
if mode in ('worker', 'rq'):
|
||||
return True, 'queued_for_worker'
|
||||
|
||||
return True, 'queued_manual'
|
||||
|
||||
Reference in new issue
Block a user