Skip to main content

llama-index tools text_to_image integration

Project description

Text to Image Tool

This tool allows Agents to use the OpenAI Image endpoint to generate and create variations of images.

Usage

This tool has more extensive example usage documented in a Jupyter notebook here

Another example showcases retrieval augmentation over a knowledge corpus with text-to-image. Notebook.

from llama_index.tools.text_to_image import TextToImageToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

openai.api_key = "sk-your-key"
tool_spec = TextToImageToolSpec()
# OR
tool_spec = TextToImageToolSpec(api_key="sk-your-key")

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

# Context to store chat history
from llama_index.core.workflow import Context

ctx = Context(agent)


print(
    await agent.run(
        "show 2 images of a beautiful beach with a palm tree at sunset",
        ctx=ctx,
    )
)
print(await agent.run("make the second image higher quality", ctx=ctx))

generate_images: Generate images from a prompt, specifying the number of images and resolution show_images: Show the images using matplot, useful for Jupyter notebooks generate_image_variation: Generate a variation of an image given a URL.

This loader is designed to be used as a way to load data as a Tool in a Agent.

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

llama_index_tools_text_to_image-0.5.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_tools_text_to_image-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_text_to_image-0.5.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_text_to_image-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b40b91a071b7520d969c38892a0e58830cc036007c7fbef447f20dc2cf4e7ed2
MD5 5bc9bb1f645eedbf9c2cb9babdba8bec
BLAKE2b-256 f67b395a547d030dde5179e814f17396e6af1ede2c0961f6656997557907c7d7

See more details on using hashes here.

File details

Details for the file llama_index_tools_text_to_image-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_tools_text_to_image-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_text_to_image-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b63bf5b463ec4d405812416f62082422e9f1e666894346c6a6f0af58ee3029fa
MD5 788628e6f663b2d703c0178fd72f150f
BLAKE2b-256 7bf32e2738ae2877d2ba60aa03184bfc77ab474e8bd47b0867c7a64b91689c75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page