Metadata-Version: 2.3
Name: mime-bytes-py
Version: 0.1.1
Summary: A wrapper for in-memory bytes with mime types, providing conversion between local files (support hardlinks and symlinks), base64 and data urls.
Author: yueyinqiu
Author-email: yueyinqiu <yueyinqiu@outlook.com>
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# MimeBytes

## Installation

```
pip install mime-bytes-py
```

## Usage

```python
from mime_bytes import MimeBytes

this_script: MimeBytes = MimeBytes.from_file(__file__)
print(this_script)  # <MimeBytes text/x-python (... bytes)>
print(this_script.to_base64())  # ZnJvbSBtaW1lX2J5dGVzIGltcG9ydCBNaW1lQnl0ZXMNC...
print(this_script.to_file("hardlink", guess_suffix=True, link_mode="hardlink_only"))  # ...\hardlink.py
```

```python
from mime_bytes import MimeBytes
import openai

image: MimeBytes = MimeBytes.from_file("my_image.png")
openai.chat.completions.create(
    model="gpt-4o",
    messages=[
        {
            "role": "user", 
            "content": [
                { "type": "image_url", "image_url": { "url": image.to_data_url() } },
                { "type": "text", "text": "Please describe the image." }
            ]
        }
    ]
)
```