Metadata-Version: 2.1
Name: text-generation
Version: 0.1.0
Summary: Hugging Face Text Generation Python Client
Home-page: https://github.com/huggingface/text-generation-inference
License: Apache-2.0
Author: Olivier Dehaene
Author-email: olivier@huggingface.co
Maintainer: Olivier Dehaene
Maintainer-email: olivier@huggingface.co
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: aiohttp (>=3.8.4,<4.0.0)
Requires-Dist: huggingface-hub (>=0.12.1,<0.13.0)
Requires-Dist: pydantic (>=1.10.5,<2.0.0)
Project-URL: Repository, https://github.com/huggingface/text-generation-inference
Description-Content-Type: text/markdown

# Text Generation

The Hugging Face Text Generation Python library provides a convenient way of interfacing with a
`text-generation-inference` instance running on your own infrastructure or on the Hugging Face Hub.

## Get Started

### Install

```shell
pip install text-generation
```

### Usage

```python
from text_generation import InferenceAPIClient

client = InferenceAPIClient("bigscience/bloomz")
text = client.generate("Why is the sky blue?").generated_text
print(text)
# ' Rayleigh scattering'

# Token Streaming
text = ""
for response in client.generate_stream("Why is the sky blue?"):
    if not response.token.special:
        text += response.token.text

print(text)
# ' Rayleigh scattering'
```

or with the asynchronous client:

```python
from text_generation import InferenceAPIAsyncClient

client = InferenceAPIAsyncClient("bigscience/bloomz")
response = await client.generate("Why is the sky blue?")
print(response.generated_text)
# ' Rayleigh scattering'

# Token Streaming
text = ""
async for response in client.generate_stream("Why is the sky blue?"):
    if not response.token.special:
        text += response.token.text

print(text)
# ' Rayleigh scattering'
```

