Skip to content

AsyncDatalabClient unable to process multi-form data #6

@qingw-dev

Description

@qingw-dev

My code snippet is of the following (with file_path: str pointing to a local pdf file):

async with AsyncDatalabClient(api_key=os.getenv("DATALAB_API_KEY")) as client:
    options: ConvertOptions = ConvertOptions(
        output_format="markdown",
        paginate=paginate,
        use_llm=True,
        max_pages=None,
    )
    result.conversion_result = await client.convert(
        file_path,
        options=options,
        save_output=workspace / "/markdown",
    )

Traceback:

File ".../.venv/lib/python3.13/site-packages/aiohttp/client_reqrep.py", line 1070, in raise_for_status
  raise ClientResponseError(
  ...<5 lines>...
  )
aiohttp.client_exceptions.ClientResponseError: 422, message=\'Unprocessable Entity\', url=URL(\'https://www.datalab.to/api/v1/marker\')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../document/service.py", line 52, in convert_document_to_markdown
  result.conversion_result = await client.convert(
                             ^^^^^^^^^^^^^^^^^^^^^
  ...<3 lines>...
  )
  ^
File ".../.venv/lib/python3.13/site-packages/datalab_sdk/client.py", line 181, in convert
  initial_data = await self._make_request(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
      "POST", "/api/v1/marker", data=self.get_form_params(file_path, options)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  )
  ^
File ".../.venv/lib/python3.13/site-packages/datalab_sdk/client.py", line 103, in _make_request
  raise DatalabAPIError(
  ...<3 lines>...
  )
datalab_sdk.exceptions.DatalabAPIError: 422, message=\'Unprocessable Entity\', url=URL(\'https://www.datalab.to/api/v1/marker\')
', "422, message='Unprocessable Entity', url=URL('https://www.datalab.to/api/v1/marker')

I use python=3.13, datalab-python-sdk==0.1.4.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions