Skip to content

Error when calling InferenceClient.conversational #2023

@philipp-zettl

Description

@philipp-zettl

Describe the bug

Calling InferenceClient.conversational according to the docs results in a 400 Client Error.

Reproduction

from huggingface_hub import InferenceClient
InferenceClient().conversational('test')

Logs

Traceback (most recent call last):
  File "~/.venv/lib/python3.11/site-packages/huggingface_hub/utils/_errors.py", line 270, in hf_raise_for_status
    response.raise_for_status()
  File "~/.venv/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.venv/lib/python3.11/site-packages/huggingface_hub/inference/_client.py", line 396, in conversational
    response = self.post(json=payload, model=model, task="conversational")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.venv/lib/python3.11/site-packages/huggingface_hub/inference/_client.py", line 240, in post
    hf_raise_for_status(response)
  File "~/.venv/lib/python3.11/site-packages/huggingface_hub/utils/_errors.py", line 326, in hf_raise_for_status
    raise BadRequestError(message, response=response) from e
huggingface_hub.utils._errors.BadRequestError:  (Request ID: EmFefRo_g2_zE3De0TRwJ)

Bad request:
`args[0]`: {'text': 'test'} have the wrong format. The should be either of type `str` or type `list`

System info

- huggingface_hub version: 0.19.4
- Platform: Linux-6.1.71-1-MANJARO-x86_64-with-glibc2.38
- Python version: 3.11.6
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: ~/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: philipp-zettl
- Configured git credential helpers: 
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- Pydot: N/A
- Pillow: 10.2.0
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: N/A
- pydantic: N/A
- aiohttp: 3.9.1
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: ~/.cache/huggingface/hub
- HF_ASSETS_CACHE: ~/.cache/huggingface/assets
- HF_TOKEN_PATH: ~/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions