diff --git a/README.md b/README.md index 9eac779..3a6518c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ To complete this quickstart, make sure that your development environment meets t - Requires [PHP 8.1+](https://php.net/releases/) + ## Setup ### Installation @@ -49,6 +50,14 @@ First, install Gemini via the [Composer](https://getcomposer.org/) package manag composer require google-gemini-php/client ``` +If you want to use beta features you should install beta branch: + +```bash +composer require google-gemini-php/client:1.0.4-beta +``` + +For beta documentation: https://github.com/google-gemini-php/client/tree/beta + Ensure that the `php-http/discovery` composer plugin is allowed to run or install a client manually if your project does not already have a PSR-18 client integrated. ```bash composer require guzzlehttp/guzzle diff --git a/src/Data/Candidate.php b/src/Data/Candidate.php index bd12817..93af1f6 100644 --- a/src/Data/Candidate.php +++ b/src/Data/Candidate.php @@ -34,7 +34,7 @@ public function __construct( ) {} /** - * @param array{ content: ?array{ parts: array{ array{ text: ?string, inlineData: array{ mimeType: string, data: string } } }, role: string }, finishReason: ?string, safetyRatings: ?array{ array{ category: string, probability: string, blocked: ?bool } }, citationMetadata: ?array{ citationSources: array{ array{ startIndex: int, endIndex: int, uri: string, license: string} } }, index: ?int, tokenCount: ?int, avgLogprobs: ?float } $attributes + * @param array{ content: ?array{ parts: array{ array{ text: ?string, inlineData: array{ mimeType: string, data: string } } }, role: string }, finishReason: ?string, safetyRatings: ?array{ array{ category: string, probability: string, blocked: ?bool } }, citationMetadata: ?array{ citationSources: array{ array{ startIndex: int, endIndex: int, uri: string, license: ?string} } }, index: ?int, tokenCount: ?int, avgLogprobs: ?float } $attributes */ public static function from(array $attributes): self { diff --git a/src/Data/CitationMetadata.php b/src/Data/CitationMetadata.php index 962f0c9..7b7a11b 100644 --- a/src/Data/CitationMetadata.php +++ b/src/Data/CitationMetadata.php @@ -21,7 +21,7 @@ public function __construct( ) {} /** - * @param array{ citationSources: array{ array{ startIndex: int, endIndex: int, uri: string, license: string } } } $attributes + * @param array{ citationSources: array{ array{ startIndex: int, endIndex: int, uri: string, license: ?string } } } $attributes */ public static function from(array $attributes): self { diff --git a/src/Data/CitationSource.php b/src/Data/CitationSource.php index 7f245de..5f23919 100644 --- a/src/Data/CitationSource.php +++ b/src/Data/CitationSource.php @@ -17,7 +17,7 @@ final class CitationSource implements Arrayable * @param int $startIndex Start of segment of the response that is attributed to this source. Index indicates the start of the segment, measured in bytes. * @param int $endIndex End of the attributed segment, exclusive. * @param string $uri URI that is attributed as a source for a portion of the text. - * @param string $license License for the GitHub project that is attributed as a source for segment. License info is required for code citations. + * @param string|null $license License for the GitHub project that is attributed as a source for segment. License info is required for code citations. */ public function __construct( public readonly int $startIndex, @@ -27,7 +27,7 @@ public function __construct( ) {} /** - * @param array{ startIndex: int, endIndex: int, uri: string, license: string} $attributes + * @param array{ startIndex: int, endIndex: int, uri: string, license: ?string} $attributes */ public static function from(array $attributes): self { @@ -35,7 +35,7 @@ public static function from(array $attributes): self startIndex: $attributes['startIndex'], endIndex: $attributes['endIndex'], uri: $attributes['uri'], - license: $attributes['license'], + license: $attributes['license'] ?? null, ); } diff --git a/src/Resources/GenerativeModel.php b/src/Resources/GenerativeModel.php index c995465..b132701 100644 --- a/src/Resources/GenerativeModel.php +++ b/src/Resources/GenerativeModel.php @@ -84,7 +84,7 @@ public function countTokens(string|Blob|array|Content ...$parts): CountTokensRes */ public function generateContent(string|Blob|array|Content ...$parts): GenerateContentResponse { - /** @var ResponseDTO $response */ + /** @var ResponseDTO $response */ $response = $this->transporter->request( request: new GenerateContentRequest( model: $this->model, diff --git a/src/Responses/GenerativeModel/GenerateContentResponse.php b/src/Responses/GenerativeModel/GenerateContentResponse.php index 9eaf705..79b89cc 100644 --- a/src/Responses/GenerativeModel/GenerateContentResponse.php +++ b/src/Responses/GenerativeModel/GenerateContentResponse.php @@ -96,7 +96,7 @@ public function json(): mixed } /** - * @param array{ candidates: ?array{ array{ content: array{ parts: array{ array{ text: ?string, inlineData: array{ mimeType: string, data: string } } }, role: string }, finishReason: string, safetyRatings: array{ array{ category: string, probability: string, blocked: ?bool } }, citationMetadata: ?array{ citationSources: array{ array{ startIndex: int, endIndex: int, uri: string, license: string} } }, index: int, tokenCount: ?int, avgLogprobs: ?float } }, promptFeedback: ?array{ safetyRatings: array{ array{ category: string, probability: string, blocked: ?bool } }, blockReason: ?string }, usageMetadata: array{ promptTokenCount: int, candidatesTokenCount: int, totalTokenCount: int, cachedContentTokenCount: ?int } } $attributes + * @param array{ candidates: ?array{ array{ content: array{ parts: array{ array{ text: ?string, inlineData: array{ mimeType: string, data: string } } }, role: string }, finishReason: string, safetyRatings: array{ array{ category: string, probability: string, blocked: ?bool } }, citationMetadata: ?array{ citationSources: array{ array{ startIndex: int, endIndex: int, uri: string, license: ?string} } }, index: int, tokenCount: ?int, avgLogprobs: ?float } }, promptFeedback: ?array{ safetyRatings: array{ array{ category: string, probability: string, blocked: ?bool } }, blockReason: ?string }, usageMetadata: array{ promptTokenCount: int, candidatesTokenCount: int, totalTokenCount: int, cachedContentTokenCount: ?int } } $attributes */ public static function from(array $attributes): self {