Compare commits

...

19 Commits

Author SHA1 Message Date
claude[bot]
f9d21138e8 fix(blocks): add json_schema_extra for images field to prevent frontend crash
When clicking '+ Item' on the Images input field, the frontend was crashing with:
TypeError: Cannot read properties of undefined (reading 'type')

This was caused by the frontend not being able to determine what type of items
to add to the Optional[List[MediaFileType]] array. Added explicit JSON schema
with array type and string items with URI format to provide the frontend with
the necessary type information.

Co-authored-by: Bently <Bentlybro@users.noreply.github.com>
2025-09-04 14:51:02 +00:00
claude[bot]
4603565782 feat(blocks): use MediaFileType for image inputs in AI Image Customizer block
Convert image input from Optional[List[str]] to Optional[List[MediaFileType]]
to properly support data URIs, URLs, and local paths as required by platform.

- Changed schema to use MediaFileType instead of strings
- Added processing to convert MediaFiles to base64 for Replicate API
- Added required graph_exec_id and user_id parameters to run method
- Images are now properly processed through store_media_file()

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Toran Bruce Richards <Torantulino@users.noreply.github.com>
2025-09-04 14:31:29 +00:00
Toran Bruce Richards
ef7e66f97c Merge branch 'dev' into claude/issue-10815-20250902-1344 2025-09-03 11:13:43 +01:00
claude[bot]
9a81025745 fix: add JSON schema extra for images field to prevent frontend crash
Fixes frontend crash when clicking '+ Item' on the Images input field by adding proper JSON schema annotations that specify the array item type for the frontend UI.

Co-authored-by: Toran Bruce Richards <Torantulino@users.noreply.github.com>
2025-09-02 17:04:27 +00:00
claude[bot]
3c61b08ae0 fix: fix type annotations in AI Image Customizer block
- Add Dict and Any imports for proper typing
- Add explicit type annotation for input_params to fix pyright error
- Remove type incompatibility between List[str] and str

Co-authored-by: Toran Bruce Richards <Torantulino@users.noreply.github.com>
2025-09-02 16:20:16 +00:00
claude[bot]
f87e24883f fix: address review comments in AI Image Customizer block
- Change wait=False to wait=True to properly handle Replicate API response
- Remove trailing whitespace for linting compliance

Co-authored-by: Toran Bruce Richards <Torantulino@users.noreply.github.com>
2025-09-02 14:55:30 +00:00
Toran Bruce Richards
3133c83032 Merge branch 'dev' into claude/issue-10815-20250902-1344 2025-09-02 15:35:39 +01:00
Toran Bruce Richards
1afcc0e740 Merge branch 'dev' into claude/issue-10815-20250902-1344 2025-09-02 15:34:11 +01:00
claude[bot]
665694563c Replace block ID with unique UUID4 for AI Image Customizer block
Co-authored-by: Toran Bruce Richards <Torantulino@users.noreply.github.com>
2025-09-02 14:32:33 +00:00
claude[bot]
30ba56441a feat(blocks): add AI Image Customizer block using Google Gemini 2.5 Flash Image
Add new AutoGPT Platform Block that uses google/gemini-2.5-flash-image model via Replicate API.

Features:
- Text prompt input for image generation
- Optional list of image URLs as input
- Configurable output format (jpg/png, defaults to png)
- Single model option: google/gemini-2.5-flash-image
- Returns image_url output for generated images

Fixes #10815

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Toran Bruce Richards <Torantulino@users.noreply.github.com>
2025-09-02 13:47:24 +00:00
Swifty
82618aede0 Merge remote-tracking branch 'origin/dev' 2025-08-27 11:39:16 +02:00
Swifty
c4483fa6c7 Merge branch 'dev' 2025-08-20 15:22:08 +02:00
Swifty
c2af8c1a6a Reapply "Merge branch 'master' of https://github.com/Significant-Gravitas/AutoGPT into ntindle/secrt-1218-add-ability-to-reject-approved-agents-in-admin-dashboard"
This reverts commit 260dd526c9.
2025-08-20 15:13:46 +02:00
Nicholas Tindle
483c399812 Revert "feat(platform): add ability to reject approved agents in admin dashboard"
This reverts commit 92515b3683.
2025-08-19 00:49:30 -05:00
Nicholas Tindle
260dd526c9 Revert "Merge branch 'master' of https://github.com/Significant-Gravitas/AutoGPT into ntindle/secrt-1218-add-ability-to-reject-approved-agents-in-admin-dashboard"
This reverts commit 105d5dc7e9, reversing
changes made to 92515b3683.
2025-08-19 00:49:10 -05:00
Nicholas Tindle
75a159db01 Revert "style(frontend): format code and improve dialog titles in approve-reject buttons"
This reverts commit 62032e6584.
2025-08-19 00:48:22 -05:00
Nicholas Tindle
62032e6584 style(frontend): format code and improve dialog titles in approve-reject buttons 2025-08-18 23:32:43 -05:00
Nicholas Tindle
105d5dc7e9 Merge branch 'master' of https://github.com/Significant-Gravitas/AutoGPT into ntindle/secrt-1218-add-ability-to-reject-approved-agents-in-admin-dashboard 2025-08-18 22:59:27 -05:00
Nicholas Tindle
92515b3683 feat(platform): add ability to reject approved agents in admin dashboard
- Modified backend review_store_submission to handle rejecting approved agents
- Added logic to update StoreListing when rejecting approved agents
- Updated UI to show "Revoke" button for approved agents
- Only shows approve button for pending agents
- Updates dialog text appropriately for revoking vs rejecting

Fixes SECRT-1218

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 10:35:25 -05:00

View File

@@ -0,0 +1,170 @@
from enum import Enum
from typing import Any, Dict, List, Literal, Optional
from pydantic import SecretStr
from replicate.client import Client as ReplicateClient
from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import (
APIKeyCredentials,
CredentialsField,
CredentialsMetaInput,
SchemaField,
)
from backend.integrations.providers import ProviderName
from backend.util.file import MediaFileType, store_media_file
TEST_CREDENTIALS = APIKeyCredentials(
id="01234567-89ab-cdef-0123-456789abcdef",
provider="replicate",
api_key=SecretStr("mock-replicate-api-key"),
title="Mock Replicate API key",
expires_at=None,
)
TEST_CREDENTIALS_INPUT = {
"provider": TEST_CREDENTIALS.provider,
"id": TEST_CREDENTIALS.id,
"type": TEST_CREDENTIALS.type,
"title": TEST_CREDENTIALS.title,
}
class GeminiImageModel(str, Enum):
GEMINI_2_5_FLASH_IMAGE = "google/gemini-2.5-flash-image"
@property
def api_name(self) -> str:
return self.value
class OutputFormat(str, Enum):
JPG = "jpg"
PNG = "png"
class AIImageCustomizerBlock(Block):
class Input(BlockSchema):
credentials: CredentialsMetaInput[
Literal[ProviderName.REPLICATE], Literal["api_key"]
] = CredentialsField(
description="Replicate API key with permissions for Google Gemini models",
)
prompt: str = SchemaField(
description="Text description of the image you want to generate",
placeholder="e.g., 'A golden retriever, the Dalai Lama, and Taylor Swift ring the bell at the New York stock exchange for their new company'",
title="Prompt",
)
model: GeminiImageModel = SchemaField(
description="The AI model to use for image generation",
default=GeminiImageModel.GEMINI_2_5_FLASH_IMAGE,
title="Model",
)
images: Optional[List[MediaFileType]] = SchemaField(
description="List of input images (optional)",
default=None,
title="Images",
json_schema_extra={
"type": "array",
"items": {"type": "string", "format": "uri"},
},
)
output_format: OutputFormat = SchemaField(
description="Format of the output image",
default=OutputFormat.PNG,
title="Output Format",
)
class Output(BlockSchema):
image_url: str = SchemaField(description="URL of the generated image")
error: str = SchemaField(description="Error message if generation failed")
def __init__(self):
super().__init__(
id="8b3e9f2a-4d7c-4a1b-9e5f-6c8d2a9b3e7f",
description="Generate images using Google's Gemini 2.5 Flash Image model via Replicate API",
categories={BlockCategory.AI, BlockCategory.MULTIMEDIA},
input_schema=AIImageCustomizerBlock.Input,
output_schema=AIImageCustomizerBlock.Output,
test_input={
"prompt": "A golden retriever, the Dalai Lama, and Taylor Swift ring the bell at the New York stock exchange for their new company",
"model": GeminiImageModel.GEMINI_2_5_FLASH_IMAGE,
"images": None,
"output_format": OutputFormat.PNG,
"credentials": TEST_CREDENTIALS_INPUT,
},
test_output=[
("image_url", "https://replicate.delivery/generated-image.jpg"),
],
test_mock={
"run_model": lambda *args, **kwargs: "https://replicate.delivery/generated-image.jpg",
},
test_credentials=TEST_CREDENTIALS,
)
async def run(
self,
input_data: Input,
*,
credentials: APIKeyCredentials,
graph_exec_id: str,
user_id: str,
**kwargs,
) -> BlockOutput:
try:
# Process input images if provided
processed_images = None
if input_data.images:
processed_images = []
for image in input_data.images:
image_b64 = await store_media_file(
graph_exec_id=graph_exec_id,
file=image,
user_id=user_id,
return_content=True,
)
processed_images.append(image_b64)
result = await self.run_model(
api_key=credentials.api_key,
model_name=input_data.model.api_name,
prompt=input_data.prompt,
images=processed_images,
output_format=input_data.output_format.value,
)
yield "image_url", result
except Exception as e:
yield "error", str(e)
async def run_model(
self,
api_key: SecretStr,
model_name: str,
prompt: str,
images: Optional[List[str]],
output_format: str,
) -> str:
client = ReplicateClient(api_token=api_key.get_secret_value())
input_params: Dict[str, Any] = {
"prompt": prompt,
"output_format": output_format,
}
# Add images to input if provided
if images:
input_params["images"] = images
output = await client.async_run(
model_name,
input=input_params,
wait=True,
)
# Handle different output types
if isinstance(output, str):
return output
elif isinstance(output, list) and output:
return output[0] if isinstance(output[0], str) else str(output[0])
else:
raise ValueError("No valid output received from the model")