-
-
Notifications
You must be signed in to change notification settings - Fork 80
feat: implement Gemini File Search APIs (Stores & Documents) #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
jfradj
wants to merge
15
commits into
google-gemini-php:main
from
jfradj:feature/add-file-search-api
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4224134
feat: implement Gemini File Search APIs (Stores & Documents)
jfradj 9c8a1fa
docs: Update README.md with File Search APIs documentation
jfradj 24e6f94
Update src/Resources/FileSearchStores.php
jfradj f44877c
Update src/Responses/FileSearchStores/UploadResponse.php
jfradj eb0fb54
Update README.md
jfradj 6429503
Update src/Requests/FileSearchStores/UploadRequest.php
jfradj 4645154
Update src/Requests/FileSearchStores/UploadRequest.php
jfradj da3d1ea
Update README.md
jfradj ce5456e
Update README.md
jfradj a4e837c
Update README.md
jfradj b049f0b
Update src/Contracts/Resources/FileSearchStoresContract.php
jfradj 8979ef2
Update src/Requests/FileSearchStores/DeleteRequest.php
jfradj f8d2ae9
Update README.md
jfradj bdb0951
Update README.md
jfradj 195da56
fix: README
jfradj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,70 @@ | ||
| <?php | ||
jfradj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Gemini\Contracts\Resources; | ||
|
|
||
| use Gemini\Enums\MimeType; | ||
| use Gemini\Responses\FileSearchStores\Documents\DocumentResponse; | ||
| use Gemini\Responses\FileSearchStores\Documents\ListResponse as DocumentListResponse; | ||
| use Gemini\Responses\FileSearchStores\FileSearchStoreResponse; | ||
| use Gemini\Responses\FileSearchStores\ListResponse; | ||
| use Gemini\Responses\FileSearchStores\UploadResponse; | ||
|
|
||
| interface FileSearchStoresContract | ||
| { | ||
| /** | ||
| * Create a file search store. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/file-search-stores#method:-fileSearchStores.create | ||
| */ | ||
| public function create(?string $displayName = null): FileSearchStoreResponse; | ||
|
|
||
| /** | ||
| * Get a file search store. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/file-search-stores#method:-fileSearchStores.get | ||
| */ | ||
| public function get(string $name): FileSearchStoreResponse; | ||
|
|
||
| /** | ||
| * List file search stores. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/file-search-stores#method:-fileSearchStores.list | ||
| */ | ||
| public function list(?int $pageSize = null, ?string $nextPageToken = null): ListResponse; | ||
|
|
||
| /** | ||
| * Delete a file search store. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/file-search-stores#method:-fileSearchStores.delete | ||
| */ | ||
| public function delete(string $name, bool $force = false): void; | ||
|
|
||
| /** | ||
| * Upload a file to a file search store. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/file-search-stores#method:-media.uploadtofilesearchstore | ||
| */ | ||
| public function upload(string $storeName, string $filename, ?MimeType $mimeType = null, ?string $displayName = null): UploadResponse; | ||
|
|
||
| /** | ||
| * List documents in a file search store. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/documents#method:-fileSearchStores.documents.list | ||
| */ | ||
| public function listDocuments(string $storeName, ?int $pageSize = null, ?string $nextPageToken = null): DocumentListResponse; | ||
|
|
||
| /** | ||
| * Get a document. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/documents#method:-fileSearchStores.documents.get | ||
| */ | ||
| public function getDocument(string $name): DocumentResponse; | ||
|
|
||
| /** | ||
| * Delete a document. | ||
| * | ||
| * @see https://ai.google.dev/api/file-search/documents#method:-fileSearchStores.documents.delete | ||
| */ | ||
| public function deleteDocument(string $name, bool $force = false): void; | ||
| } | ||
This file contains hidden or 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,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Gemini\Requests\FileSearchStores; | ||
|
|
||
| use Gemini\Enums\Method; | ||
| use Gemini\Foundation\Request; | ||
| use Gemini\Requests\Concerns\HasJsonBody; | ||
|
|
||
| /** | ||
| * @link https://ai.google.dev/api/file-search/file-search-stores#method:-fileSearchStores.create | ||
| */ | ||
| class CreateRequest extends Request | ||
| { | ||
| use HasJsonBody; | ||
|
|
||
| protected Method $method = Method::POST; | ||
|
|
||
| public function __construct( | ||
| public ?string $displayName = null, | ||
| ) {} | ||
|
|
||
| public function resolveEndpoint(): string | ||
| { | ||
| return 'fileSearchStores'; | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function defaultBody(): array | ||
| { | ||
| $body = []; | ||
|
|
||
| if ($this->displayName !== null) { | ||
| $body['displayName'] = $this->displayName; | ||
| } | ||
|
|
||
| return $body; | ||
| } | ||
| } |
This file contains hidden or 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,34 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Gemini\Requests\FileSearchStores; | ||
|
|
||
| use Gemini\Enums\Method; | ||
| use Gemini\Foundation\Request; | ||
|
|
||
| /** | ||
| * @link https://ai.google.dev/api/file-search/file-search-stores#method:-fileSearchStores.delete | ||
| */ | ||
| class DeleteRequest extends Request | ||
| { | ||
| protected Method $method = Method::DELETE; | ||
|
|
||
| public function __construct( | ||
| protected readonly string $name, | ||
| protected readonly bool $force = false, | ||
| ) {} | ||
|
|
||
| public function resolveEndpoint(): string | ||
| { | ||
| return $this->name; | ||
| } | ||
|
|
||
jfradj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function defaultQuery(): array | ||
| { | ||
| return $this->force ? ['force' => 'true'] : []; | ||
| } | ||
| } | ||
This file contains hidden or 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,34 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Gemini\Requests\FileSearchStores\Documents; | ||
|
|
||
| use Gemini\Enums\Method; | ||
| use Gemini\Foundation\Request; | ||
|
|
||
| /** | ||
| * @link https://ai.google.dev/api/file-search/documents#method:-fileSearchStores.documents.delete | ||
| */ | ||
| class DeleteRequest extends Request | ||
| { | ||
| protected Method $method = Method::DELETE; | ||
|
|
||
| public function __construct( | ||
| protected readonly string $name, | ||
| protected readonly bool $force = false, | ||
| ) {} | ||
|
|
||
| public function resolveEndpoint(): string | ||
| { | ||
| return $this->name; | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function defaultQuery(): array | ||
| { | ||
| return $this->force ? ['force' => 'true'] : []; | ||
| } | ||
| } |
This file contains hidden or 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,25 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Gemini\Requests\FileSearchStores\Documents; | ||
|
|
||
| use Gemini\Enums\Method; | ||
| use Gemini\Foundation\Request; | ||
|
|
||
| /** | ||
| * @link https://ai.google.dev/api/file-search/documents#method:-fileSearchStores.documents.get | ||
| */ | ||
| class GetRequest extends Request | ||
| { | ||
| protected Method $method = Method::GET; | ||
|
|
||
| public function __construct( | ||
| protected readonly string $name, | ||
| ) {} | ||
|
|
||
| public function resolveEndpoint(): string | ||
| { | ||
| return $this->name; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.