pub struct GenerateImageToolBox { /* private fields */ }Expand description
ToolBox that lets an agent generate and edit images with an ImageGenerator.
Tools:
generate_image: draws an image from a prompt.edit_image: changes stored images the model names by ID. It needs a storage (with_storage) and a provider that can edit; without them the model gets an error.
Both take a name from the model (for example lighthouse), set as
Media::name and so passed to
MediaSave; the storage chooses the ID and may use it.
With a storage every image is saved and the model gets its ID. What else the model gets
is set with with_output.
let storage = MemoryStorage::new();
let images = GenerateImageToolBox::new(ImageGenerator::new("openai::gpt-image-1")?)
.with_storage(storage.clone());Implementations§
Source§impl GenerateImageToolBox
impl GenerateImageToolBox
Sourcepub fn new(generator: ImageGenerator) -> Self
pub fn new(generator: ImageGenerator) -> Self
Creates the toolbox. A storage set on generator is used to save the images, but
edit_image needs one set with with_storage.
Sourcepub fn with_storage(self, storage: impl MediaStorage) -> Self
pub fn with_storage(self, storage: impl MediaStorage) -> Self
Saves every image in storage and loads the images to edit from it.
Sourcepub fn with_output(self, output: ImageToolOutput) -> Self
pub fn with_output(self, output: ImageToolOutput) -> Self
Sets what the model gets back, see ImageToolOutput.
Trait Implementations§
Source§impl ToolBox for GenerateImageToolBox
impl ToolBox for GenerateImageToolBox
Auto Trait Implementations§
impl !RefUnwindSafe for GenerateImageToolBox
impl !UnwindSafe for GenerateImageToolBox
impl Freeze for GenerateImageToolBox
impl Send for GenerateImageToolBox
impl Sync for GenerateImageToolBox
impl Unpin for GenerateImageToolBox
impl UnsafeUnpin for GenerateImageToolBox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more