llama-index tools openai_image_generation integration
Project description
OpenAI Image Generation Tool
This tool allows Agents to generate images using OpenAI's DALL-E model. To see more and get started, visit https://openai.com/blog/dall-e/
Usage
This tool has a more extensive example usage documented in a Jupyter notebook here
Usage with Agent
from llama_index.tools.openai.image_generation import (
OpenAIImageGenerationToolSpec,
)
image_generation_tool = OpenAIImageGenerationToolSpec(
api_key=os.environ["OPENAI_API_KEY"]
)
agent = OpenAIAgent.from_tools(
[*image_generation_tool.to_tool_list()],
verbose=True,
)
response = agent.query(
"A pink and blue llama in a black background with the output"
)
print(response)
Usage directly
from llama_index.tools.openai.image_generation import (
OpenAIImageGenerationToolSpec,
)
image_generation_tool = OpenAIImageGenerationToolSpec(
api_key=os.environ["OPENAI_API_KEY"]
)
image_data = image_generation_tool.image_generation(
text="A pink and blue llama with a black background",
response_format="b64_json",
)
image_bytes = base64.b64decode(image_data)
img = Image.open(BytesIO(image_bytes))
display(img)
image_generation
: Takes an text input and generates an image
This loader is designed to be used as a way to load data as a Tool in a Agent. See here for examples.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for llama_index_tools_openai_image_generation-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab9b34774136d37caa8b6b0f8da4eb8c4eea31b7b190e0a57c2d339b6e4c2c6 |
|
MD5 | b6931f3b10fba8da641f7506ea25af7f |
|
BLAKE2b-256 | 344e8781d43b12128ecba8227436d79db1c59219fcd1378c3d76869e57b5e10a |
Close
Hashes for llama_index_tools_openai_image_generation-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 961129630fd5190f2a9f0c20b9f99eb9507d34cd68999de02f363da6a3acb298 |
|
MD5 | c7446a4d2a00d9c752412fbacfe21ca9 |
|
BLAKE2b-256 | ab3c2a843e030666e08f0bba55aa626930ff74af23a9b7d8e4ef90c96a80283c |