@@ -36,7 +36,8 @@ def check_api_url() -> tuple[bool, str]:
3636
3737 response = r .json ()
3838 if is_succeed (response ):
39- return True , "API地址配置正确"
39+ timeutils .print_log (f"ragflow version:{ response .get ('data' )} " )
40+ return True , f"API地址配置正确"
4041
4142 code = response .get ("code" )
4243 message = response .get ("message" )
@@ -139,8 +140,8 @@ def parse_chunks_with_check(filename, doc_id=None):
139140
140141 if not doc_id :
141142 timeutils .print_log (f'根据文件名[{ filename } ]从数据库获取文档id' )
142- doc_item = ragflowdb .get_doc_item_by_name (filename , max_retries = configs .SQL_RETRIES )
143- if not doc_item :
143+ doc_item = ragflowdb .get_doc_item_by_name (filename , max_retries = configs .SQL_RETRIES ) or {}
144+ if not doc_item . get ( 'id' ) :
144145 timeutils .print_log (f'找不到{ filename } 对应的数据库记录,跳过' )
145146 return False
146147
@@ -197,8 +198,14 @@ def set_document_metadata(doc_id, filepath) -> bool:
197198 return False
198199
199200 if not doc_id :
200- timeutils .print_log (F'设置文档元数据失败: doc_id为空,跳过' )
201- return False
201+ filename = os .path .basename (filepath )
202+ timeutils .print_log (f'根据文件名[{ filename } ]从数据库获取文档id' )
203+ doc_item = ragflowdb .get_doc_item_by_name (filename , max_retries = configs .SQL_RETRIES ) or {}
204+ if not doc_item .get ('id' ):
205+ timeutils .print_log (F'设置文档元数据失败: doc_id为空,跳过' )
206+ return False
207+
208+ doc_id = doc_item .get ('id' )
202209
203210 # 构建元数据文件路径-移除原文件后缀再拼接元数据后缀
204211 filepath_without_ext = os .path .splitext (filepath )[0 ]
0 commit comments