更改import nougat时机
This commit is contained in:
		
							parent
							
								
									84b45dc4fb
								
							
						
					
					
						commit
						362b545a45
					
				@ -57,6 +57,12 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
 | 
			
		||||
        "批量翻译PDF文档。函数插件贡献者: Binary-Husky"])
 | 
			
		||||
    yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
 | 
			
		||||
 | 
			
		||||
    # 清空历史,以免输入溢出
 | 
			
		||||
    history = []
 | 
			
		||||
 | 
			
		||||
    from .crazy_utils import get_files_from_everything
 | 
			
		||||
    success, file_manifest, project_folder = get_files_from_everything(txt, type='.pdf')
 | 
			
		||||
    if len(file_manifest) > 0:
 | 
			
		||||
        # 尝试导入依赖,如果缺少依赖,则给出安装建议
 | 
			
		||||
        try:
 | 
			
		||||
            import nougat
 | 
			
		||||
@ -67,12 +73,6 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
 | 
			
		||||
                             b=f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade nougat-ocr tiktoken```。")
 | 
			
		||||
            yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
    # 清空历史,以免输入溢出
 | 
			
		||||
    history = []
 | 
			
		||||
 | 
			
		||||
    from .crazy_utils import get_files_from_everything
 | 
			
		||||
    success, file_manifest, project_folder = get_files_from_everything(txt, type='.pdf')
 | 
			
		||||
    success_mmd, file_manifest_mmd, _ = get_files_from_everything(txt, type='.mmd')
 | 
			
		||||
    success = success or success_mmd
 | 
			
		||||
    file_manifest += file_manifest_mmd
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user