Skip to content

Commit

Permalink
Merge branch 'main' into v0.24-release
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin committed Jul 18, 2024
2 parents 7fe286b + 1f9dbf8 commit 83b5d7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/huggingface_hub/inference/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,12 @@ def text_generation(
if stream:
return _stream_text_generation_response(bytes_output, details) # type: ignore

data = _bytes_to_dict(bytes_output)[0] # type: ignore[arg-type]
data = _bytes_to_dict(bytes_output) # type: ignore[arg-type]

# Data can be a single element (dict) or an iterable of dicts where we select the first element of.
if isinstance(data, list):
data = data[0]

return TextGenerationOutput.parse_obj_as_instance(data) if details else data["generated_text"]

def text_to_image(
Expand Down
7 changes: 6 additions & 1 deletion src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,12 @@ async def text_generation(
if stream:
return _async_stream_text_generation_response(bytes_output, details) # type: ignore

data = _bytes_to_dict(bytes_output)[0] # type: ignore[arg-type]
data = _bytes_to_dict(bytes_output) # type: ignore[arg-type]

# Data can be a single element (dict) or an iterable of dicts where we select the first element of.
if isinstance(data, list):
data = data[0]

return TextGenerationOutput.parse_obj_as_instance(data) if details else data["generated_text"]

async def text_to_image(
Expand Down

0 comments on commit 83b5d7f

Please sign in to comment.