Metadata-Version: 2.4
Name: pic_prompt
Version: 1.8.0
Summary: A library for building image prompts for OpenAI. Made for integration with LiteLLM.
Project-URL: Homepage, https://github.com/paulbaranowski/pic-prompt
Project-URL: Bug Tracker, https://github.com/paulbaranowski/pic-prompt/issues
Author-email: Paul Baranowski <paulbaranowski@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: asyncio
Requires-Dist: boto3>=1.26.0
Requires-Dist: litellm>=1.64.1
Requires-Dist: pillow>=10.4.0
Requires-Dist: pytest-env>=1.1.5
Requires-Dist: requests>=2.28.0
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.20.0; extra == 'test'
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
Requires-Dist: pytest>=7.0; extra == 'test'
Description-Content-Type: text/markdown

# pic-prompt

A Python library that provides a simple and flexible way to build image-based prompts for 
OpenAI. Initially it was developed to generate the prompt for different providers, but
then we discovered LiteLLM (https://www.litellm.ai/) which will translate between OpenAI
and other providers. 

It focuses on the following problems:
- Downloading images from different sources, either synchronously or asynchronously
- Encoding images 
- Handling media types (e.g. image/jpeg, image/png, etc.)
- Handling oversized images by resizing them to lower quality
- Inserting image data into prompts

It supports adding images from (Image Sources):
- URLs
- Local files
- S3 files

It is easy to add support for other providers and other image sources.

## Installation

```bash
pip install pic-prompt
```
or:

```bash
uv add pic-prompt
```

## Usage
To use the example scripts, set the OPENAI_API_KEY in your environment, typically in a `.env` file. These examples will do two queries each.

You do not need to set the OPENAI_API_KEY to actually use this library.

Example: `examples/example1.py`
This example fetches a local image and runs a LLM query on it,
and the fetches a URL and runs an LLM query on it.

Run it using: 

```
python -m examples.example1
```

/Users/paul/dev/pic-prompt/examples/example2-image-cache.pyExample: `examples/example2-image-cache.py`
This example illustrates how to pre-fetch the images before creating the prompt.
Run it using: 

```
python -m examples.example2-image-cache
```
