View Source LangChain.Images (LangChain v0.3.0-rc.0)

Functions for working with LangChain.GeneratedImage files.

Summary

Functions

Save a list of %GeneratedImage{} images.

Save the generated image file to a local directory. If the GeneratedFile is an URL, it is first downloaded then saved. If the is a Base64 encoded image, it is decoded and saved.

Functions

Link to this function

save_images(images, path, filename_prefix)

View Source
@spec save_images(
  [LangChain.Images.GeneratedImage.t()],
  path :: String.t(),
  filename_prefix :: String.t()
) :: {:ok, [String.t()]} | {:error, String.t()}

Save a list of %GeneratedImage{} images.

Pipe friendly for handling the result a LangChain.Images.OpenAIImage.call/1 where it handles a success or passes the error result through.

Link to this function

save_to_file(image, target_path)

View Source
@spec save_to_file(LangChain.Images.GeneratedImage.t(), String.t()) ::
  :ok | {:error, String.t()}

Save the generated image file to a local directory. If the GeneratedFile is an URL, it is first downloaded then saved. If the is a Base64 encoded image, it is decoded and saved.