-
Notifications
You must be signed in to change notification settings - Fork 37
Description
chatglm_qa在上传文本文件时候报错
Traceback (most recent call last): File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\routes.py", line 534, in predict output = await route_utils.call_process_api( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\route_utils.py", line 226, in call_process_api output = await app.get_blocks().process_api( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\blocks.py", line 1550, in process_api result = await self.call_function( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\blocks.py", line 1185, in call_function prediction = await anyio.to_thread.run_sync( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run result = context.run(func, *args) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\utils.py", line 661, in wrapper response = f(*args, **kwargs) File "E:\ChatGLM\MachineLearningPractice-main\03_上传文档问答.py", line 91, in add_file documents = load_documents(directory) File "E:\ChatGLM\MachineLearningPractice-main\03_上传文档问答.py", line 26, in load_documents documents = loader.load() File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\langchain\document_loaders\directory.py", line 156, in load self.load_file(i, p, docs, pbar) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\langchain\document_loaders\directory.py", line 105, in load_file raise e File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\langchain\document_loaders\directory.py", line 99, in load_file sub_docs = self.loader_cls(str(item), **self.loader_kwargs).load() File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\langchain\document_loaders\unstructured.py", line 86, in load elements = self._get_elements() File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\langchain\document_loaders\unstructured.py", line 172, in _get_elements return partition(filename=self.file_path, **self.unstructured_kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\partition\auto.py", line 434, in partition elements = partition_text( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\partition\text.py", line 93, in partition_text return _partition_text( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\documents\elements.py", line 526, in wrapper elements = func(*args, **kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\file_utils\filetype.py", line 619, in wrapper elements = func(*args, **kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\file_utils\filetype.py", line 574, in wrapper elements = func(*args, **kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\chunking\__init__.py", line 69, in wrapper elements = func(*args, **kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\partition\text.py", line 190, in _partition_text element = element_from_text(ctext) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\partition\text.py", line 235, in element_from_text elif is_possible_narrative_text(text): File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\partition\text_type.py", line 88, in is_possible_narrative_text if "eng" in languages and (sentence_count(text, 3) < 2) and (not contains_verb(text)): File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\partition\text_type.py", line 190, in contains_verb pos_tags = pos_tag(text) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\nlp\tokenize.py", line 44, in pos_tag _download_nltk_package_if_not_present( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\unstructured\nlp\tokenize.py", line 21, in _download_nltk_package_if_not_present nltk.find(f"{package_category}/{package_name}") File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\nltk\data.py", line 555, in find return find(modified_name, paths) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\nltk\data.py", line 542, in find return ZipFilePathPointer(p, zipentry) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\nltk\compat.py", line 41, in _decorator return init_func(*args, **kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\nltk\data.py", line 394, in __init__ zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile)) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\nltk\compat.py", line 41, in _decorator return init_func(*args, **kwargs) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\nltk\data.py", line 935, in __init__ zipfile.ZipFile.__init__(self, filename) File "C:\Users\S3111\.conda\envs\chatglm\lib\zipfile.py", line 1269, in __init__ self._RealGetContents() File "C:\Users\S3111\.conda\envs\chatglm\lib\zipfile.py", line 1336, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file Traceback (most recent call last): File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\queueing.py", line 407, in call_prediction output = await route_utils.call_process_api( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\route_utils.py", line 226, in call_process_api output = await app.get_blocks().process_api( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\blocks.py", line 1550, in process_api result = await self.call_function( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\blocks.py", line 1199, in call_function prediction = await utils.async_iteration(iterator) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\utils.py", line 519, in async_iteration return await iterator.__anext__() File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\utils.py", line 512, in __anext__ return await anyio.to_thread.run_sync( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run result = context.run(func, *args) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\utils.py", line 495, in run_sync_iterator_async return next(iterator) File "C:\Users\S3111\.conda\envs\chatglm\lib\site-packages\gradio\utils.py", line 649, in gen_wrapper yield from f(*args, **kwargs) File "E:\ChatGLM\MachineLearningPractice-main\03_上传文档问答.py", line 99, in bot message = history[-1][0] IndexError: list index out of range