semvec/pypi-packages huggingface dataset:
txtgenai 0.1.0
A Python package for advanced text generation
Requires Python: >=3.6


# textgen
=======
# TextGen

A Python package for advanced text generation capabilities. TextGen provides simple, intuitive access to state-of-the-art language models.

## Installation

```bash
pip install textgen
```

Or install from source:

```bash
git clone https://github.com/Sohail-Shaikh-07/txtgenai.git
cd txtgenai
pip install -e .
```

## Features

- Simple API for text generation
- Advanced chat capabilities
- Access to top-tier language models
- Streaming responses
- Comprehensive error handling
- No API key required - everything works out of the box!

## Usage Examples

### Generate text with a single line

```python
import textgen

response = textgen.generate_text("Write a short poem about nature.")
print(response['content'])
```

### Chat conversations

```python
response = textgen.generate_chat([
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Explain quantum computing in simple terms."}
])

print(response['content'])
```

### Advanced options

```python
from textgen import client

response = client.chat.generate(
    messages=[
        {"role": "user", "content": "Write a creative story about space exploration."}
    ],
    temperature=0.8,
    max_tokens=1000
)

print(response['content'])
```

### Access full response data

```python
response = textgen.generate_text("Suggest three book titles.")
print(f"Generated by model: {response['model_used']}")
print(response['content'])

# Access the complete API response if needed
full_data = response['full_response']
```

## Error Handling

The package provides helpful error classes:

- `TextGenError`: Base exception class
- `APIError`: Raised for API response errors with status codes

```python
from textgen.exceptions import TextGenError

try:
    response = textgen.generate_text("Write a story.")
except TextGenError as e:
    print(f"Error: {str(e)}")
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the LICENSE file for details.