|
13 | 13 |
|
14 | 14 | if TYPE_CHECKING: |
15 | 15 | from unstructured_client import UnstructuredClient |
| 16 | + from unstructured_client.models.operations import PartitionRequest |
16 | 17 | from unstructured_client.models.shared import PartitionParameters |
17 | 18 |
|
18 | 19 |
|
@@ -153,7 +154,7 @@ class FileDataSourceMetadata(DataSourceMetadata): |
153 | 154 | ) |
154 | 155 | return self.postprocess(elements=elements_to_dicts(elements)) |
155 | 156 |
|
156 | | - async def call_api(self, client: "UnstructuredClient", request: "PartitionParameters"): |
| 157 | + async def call_api(self, client: "UnstructuredClient", request: "PartitionRequest"): |
157 | 158 | # TODO when client supports async, run without using run_in_executor |
158 | 159 | # isolate the IO heavy call |
159 | 160 | loop = asyncio.get_event_loop() |
@@ -189,14 +190,16 @@ async def partition_via_api( |
189 | 190 | self, filename: Path, metadata: Optional[dict] = None, **kwargs |
190 | 191 | ) -> list[dict]: |
191 | 192 | from unstructured_client import UnstructuredClient |
| 193 | + from unstructured_client.models.operations import PartitionRequest |
192 | 194 |
|
193 | 195 | logger.debug(f"partitioning file {filename} with metadata: {metadata}") |
194 | 196 | client = UnstructuredClient( |
195 | 197 | server_url=self.config.partition_endpoint, |
196 | 198 | api_key_auth=self.config.api_key.get_secret_value(), |
197 | 199 | ) |
198 | 200 | partition_params = self.create_partition_parameters(filename=filename) |
199 | | - resp = await self.call_api(client=client, request=partition_params) |
| 201 | + partition_request = PartitionRequest(partition_params) |
| 202 | + resp = await self.call_api(client=client, request=partition_request) |
200 | 203 | elements = resp.elements or [] |
201 | 204 | # Append the data source metadata the auto partition does for you |
202 | 205 | for element in elements: |
|
0 commit comments