Skip to content

Commit

Permalink
Merge pull request #55 from aydinfatih/main
Browse files Browse the repository at this point in the history
refactor: Make nullable uri variable in `CitationSource`
  • Loading branch information
aydinfatih authored Nov 6, 2024
2 parents b7e1378 + de6ecaa commit 11e7413
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Data/Candidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Data/CitationMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions src/Data/CitationSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ 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|null $uri URI that is attributed as a source for a portion of the text.
* @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,
public readonly int $endIndex,
public readonly string $uri,
public readonly ?string $uri,
public readonly ?string $license,
) {}

/**
* @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
{
return new self(
startIndex: $attributes['startIndex'],
endIndex: $attributes['endIndex'],
uri: $attributes['uri'],
uri: $attributes['uri'] ?? null,
license: $attributes['license'] ?? null,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/GenerativeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function countTokens(string|Blob|array|Content ...$parts): CountTokensRes
*/
public function generateContent(string|Blob|array|Content ...$parts): GenerateContentResponse
{
/** @var ResponseDTO<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 }, usageMetadata: array{ promptTokenCount: int, candidatesTokenCount: int, totalTokenCount: int, cachedContentTokenCount: ?int } }> $response */
/** @var ResponseDTO<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 }, usageMetadata: array{ promptTokenCount: int, candidatesTokenCount: int, totalTokenCount: int, cachedContentTokenCount: ?int } }> $response */
$response = $this->transporter->request(
request: new GenerateContentRequest(
model: $this->model,
Expand Down
2 changes: 1 addition & 1 deletion src/Responses/GenerativeModel/GenerateContentResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function text(): string
}

/**
* @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
{
Expand Down

0 comments on commit 11e7413

Please sign in to comment.