-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beta' into main-beta-conflict
- Loading branch information
Showing
37 changed files
with
245 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gemini\Data; | ||
|
||
enum DataFormat: string | ||
{ | ||
// for Number | ||
case FLOAT = 'float'; | ||
case DOUBLE = 'double'; | ||
|
||
// for Integer | ||
case INT32 = 'int32'; | ||
case INT64 = 'int64'; | ||
|
||
// for String | ||
case ENUM = 'enum'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gemini\Data; | ||
|
||
use Gemini\Contracts\Arrayable; | ||
use Gemini\Enums\DataType; | ||
|
||
/** | ||
* https://ai.google.dev/api/caching#Schema | ||
* | ||
* The Schema object allows the definition of input and output data types. | ||
*/ | ||
class Schema implements Arrayable | ||
{ | ||
/** | ||
* The Schema object allows the definition of input and output data types. | ||
* | ||
* @param DataType $type Data type. | ||
* @param DataFormat|null $format The format of the data. This is used only for primitive datatypes. | ||
* @param string|null $description A brief description of the parameter. | ||
* @param bool|null $nullable Indicates if the value may be null. | ||
* @param array<string>|null $enum Possible values of the element of Type.STRING with enum format. | ||
* @param string|null $maxItems Maximum number of the elements for Type.ARRAY. | ||
* @param string|null $minItems Minimum number of the elements for Type.ARRAY. | ||
* @param array<string, Schema>|null $properties Properties of Type.OBJECT. | ||
* @param array<string>|null $required Required properties of Type.OBJECT. | ||
* @param Schema|null $items Schema of the elements of Type.ARRAY. | ||
*/ | ||
public function __construct( | ||
public readonly DataType $type, | ||
public readonly ?DataFormat $format = null, | ||
public readonly ?string $description = null, | ||
public readonly ?bool $nullable = null, | ||
public readonly ?array $enum = null, | ||
public readonly ?string $maxItems = null, | ||
public readonly ?string $minItems = null, | ||
public readonly ?array $properties = null, | ||
public readonly ?array $required = null, | ||
public readonly ?Schema $items = null | ||
) {} | ||
|
||
public function toArray(): array | ||
{ | ||
return array_filter( | ||
array: [ | ||
'type' => $this->type->value, | ||
'format' => $this->format, | ||
'description' => $this->description, | ||
'nullable' => $this->nullable, | ||
'enum' => $this->enum, | ||
'maxItems' => $this->maxItems, | ||
'minItems' => $this->minItems, | ||
'properties' => array_map(fn ($property) => $property->toArray(), $this->properties ?? []), | ||
'required' => $this->required, | ||
'items' => $this->items?->toArray(), | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,4 @@ public function toArray(): array | |
'cachedContentTokenCount' => $this->cachedContentTokenCount, | ||
]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gemini\Enums; | ||
|
||
/** | ||
* Type contains the list of OpenAPI data types as defined by https://spec.openapis.org/oas/v3.0.3#data-types | ||
* | ||
* https://ai.google.dev/api/caching#Type | ||
*/ | ||
enum DataType: string | ||
{ | ||
case TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'; | ||
case STRING = 'STRING'; | ||
case NUMBER = 'NUMBER'; | ||
case INTEGER = 'INTEGER'; | ||
case BOOLEAN = 'BOOLEAN'; | ||
case ARRAY = 'ARRAY'; | ||
case OBJECT = 'OBJECT'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.