Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Data/GenerationConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class GenerationConfig implements Arrayable
* @param SpeechConfig|null $speechConfig Optional. The speech generation config.
* @param ThinkingConfig|null $thinkingConfig Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.
* @param MediaResolution|null $mediaResolution Optional. If specified, the media resolution specified will be used.
* @param ImageConfig|null $imageConfig Optional. Config for image generation features.
*/
public function __construct(
public readonly int $candidateCount = 1,
Expand All @@ -55,6 +56,7 @@ public function __construct(
public readonly ?SpeechConfig $speechConfig = null,
public readonly ?ThinkingConfig $thinkingConfig = null,
public readonly ?MediaResolution $mediaResolution = null,
public readonly ?ImageConfig $imageConfig = null,
) {}

public function toArray(): array
Expand Down Expand Up @@ -82,6 +84,7 @@ public function toArray(): array
'speechConfig' => $this->speechConfig?->toArray(),
'thinkingConfig' => $this->thinkingConfig?->toArray(),
'mediaResolution' => $this->mediaResolution?->value,
'imageConfig' => $this->imageConfig?->toArray(),
]
);
}
Expand Down
39 changes: 39 additions & 0 deletions src/Data/ImageConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Gemini\Data;

use Gemini\Contracts\Arrayable;

/**
* Config for image generation features.
*
* https://ai.google.dev/api/generate-content#ImageConfig
*/
final class ImageConfig implements Arrayable
{
/**
* @param string $aspectRatio The aspect ratio of the image to generate. Supported aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9. If not specified, the model will choose a default aspect ratio based on any reference images provided.
*/
public function __construct(
public readonly string $aspectRatio,
) {}

/**
* @param array{ aspectRatio: string } $attributes
*/
public static function from(array $attributes): self
{
return new self(
aspectRatio: $attributes['aspectRatio'],
);
}

public function toArray(): array
{
return [
'aspectRatio' => $this->aspectRatio,
];
}
}
20 changes: 20 additions & 0 deletions src/Enums/FinishReason.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ enum FinishReason: string
*/
case IMAGE_SAFETY = 'IMAGE_SAFETY';

/**
* Image generation stopped because generated images has other prohibited content.
*/
case IMAGE_PROHIBITED_CONTENT = 'IMAGE_PROHIBITED_CONTENT';

/**
* Image generation stopped because of other miscellaneous issue.
*/
case IMAGE_OTHER = 'IMAGE_OTHER';

/**
* The model was expected to generate an image, but none was generated.
*/
case NO_IMAGE = 'NO_IMAGE';

/**
* Image generation stopped due to recitation.
*/
case IMAGE_RECITATION = 'IMAGE_RECITATION';

/**
* Model generated a tool call but no tools were enabled in the request.
*/
Expand Down