griptape-ai / griptape

Modular Python framework for AI agents and workflows with chain-of-thought reasoning, tools, and memory.
https://www.griptape.ai
Apache License 2.0
2.02k stars 170 forks source link

PromptImageGenerationTool no longer saves files with extension #1307

Closed shhlife closed 5 days ago

shhlife commented 2 weeks ago

Describe the bug I have an agent I can chat with that will generate an image. In Griptape 0.31 it would save images with a file extension. Now, it generates the images but no longer includes the extension.

import os

from dotenv import load_dotenv
from griptape.drivers import OpenAiImageGenerationDriver
from griptape.engines import PromptImageGenerationEngine
from griptape.structures import Agent
from griptape.tools import PromptImageGenerationTool

load_dotenv()

API_KEY = os.getenv("OPENAI_API_KEY")

# Create an image generation engine with the Leonardo API
engine = PromptImageGenerationEngine(
    image_generation_driver=OpenAiImageGenerationDriver(
        model="dall-e-3", type="png", api_key=API_KEY
    )
)

# Create an image tool to give the agent
image_tool = PromptImageGenerationTool(
    engine=engine, output_dir="images", off_prompt=True, type="png"
)

# Create the agent with the image tool, andd File manager so it can save images
agent = Agent(
    tools=[
        image_tool,
    ],
    stream=True,
)

agent.run("a pic of a cat")

this now saves a file in images as afd1a1eaf72a4c1f9855f63c7e5ba557. If I add .png to the end of the file, I can see it's an image... but Griptape no longer uses the image extension.

vachillo commented 5 days ago

closed with #1324