Unstructured-IO / unstructured

Open source libraries and APIs to build custom preprocessing pipelines for labeling, training, or production machine learning pipelines.
https://www.unstructured.io/
Apache License 2.0
9.21k stars 764 forks source link

bug/<short-name> #3772

Open Minh7-byte opened 2 weeks ago

Minh7-byte commented 2 weeks ago

Describe the bug A clear and concise description of what the bug is. { "name": "ServerError", "message": "{\"detail\":\"API key is invalid, please provide a valid API key in the header.\"}", "stack": "--------------------------------------------------------------------------- ServerError Traceback (most recent call last) Cell In[3], line 10 3 loader = UnstructuredLoader( 4 file_path=file_path, 5 strategy=\"hi_res\", 6 partition_via_api=True, 7 coordinates=True, 8 ) 9 docs = [] ---> 10 for doc in loader.lazy_load(): 11 docs.append(doc)

File c:\Users\AppData\Local\Programs\Python\Python312\Lib\site-packages\langchain_unstructured\document_loaders.py:178, in UnstructuredLoader.lazy_load(self) 175 return 177 # Call _UnstructuredBaseLoader normally since file and file_path are not lists --> 178 yield from load_file(f=self.file, f_path=self.file_path)

File c:\Users\AppData\Local\Programs\Python\Python312\Lib\site-packages\langchain_unstructured\document_loaders.py:212, in _SingleDocumentLoader.lazy_load(self) 207 def lazy_load(self) -> Iterator[Document]: 208 \"\"\"Load file.\"\"\" 209 elements_json = ( 210 self._post_process_elements_json(self._elements_json) 211 if self.post_processors --> 212 else self._elements_json 213 ) 214 for element in elements_json: 215 metadata = self._get_metadata()

File c:\Users\AppData\Local\Programs\Python\Python312\Lib\site-packages\langchain_unstructured\document_loaders.py:229, in _SingleDocumentLoader._elements_json(self) 227 \"\"\"Get elements as a list of dictionaries from local partition or via API.\"\"\" 228 if self.partition_via_api: --> 229 return self._elements_via_api 231 return self._convert_elements_to_dicts(self._elements_via_local)

File c:\Users\AppData\Local\Programs\Python\Python312\Lib\site-packages\langchain_unstructured\document_loaders.py:258, in _SingleDocumentLoader._elements_via_api(self) 256 client = self.client 257 req = self._sdk_partition_request --> 258 response = client.general.partition(req) # type: ignore 259 if response.status_code == 200: 260 return json.loads(response.raw_response.text)

File c:\Users\AppData\Local\Programs\Python\Python312\Lib\site-packages\unstructured_client\general.py:107, in General.partition(self, request, retries) 105 if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
106 out = utils.unmarshal_json(http_res.text, errors.ServerError) --> 107 raise out 108 else: 109 content_type = http_res.headers.get('Content-Type')

ServerError: {\"detail\":\"API key is invalid, please provide a valid API key in the header.\"}" } To Reproduce Provide a code snippet that reproduces the issue.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment Info Please run python scripts/collect_env.py and paste the output here. This will help us understand more about the environment in which the bug occurred.

Additional context Add any other context about the problem here.