Skip to content

Commit

Permalink
Add parameters to vector store list functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gehrisandro committed Jun 6, 2024
1 parent ebbc0e6 commit 667134c
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 24 deletions.
10 changes: 6 additions & 4 deletions src/Contracts/Resources/VectorStoresContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ public function create(array $parameters): VectorStoreResponse;
* Returns a list of vector stores.
*
* @see https://platform.openai.com/docs/api-reference/vector-stores/list
*
* @param array<string, mixed> $parameters
*/
public function list(): VectorStoreListResponse;
public function list(array $parameters = []): VectorStoreListResponse;

/**
* Retrieves a vector store.
*
* @see https://platform.openai.com/docs/api-reference/vector-stores/retrieve
*/
public function retrieve(string $vectorStore): VectorStoreResponse;
public function retrieve(string $vectorStoreId): VectorStoreResponse;

/**
* Modify a vector store
Expand All @@ -38,14 +40,14 @@ public function retrieve(string $vectorStore): VectorStoreResponse;
*
* @param array<string, mixed> $parameters
*/
public function modify(string $vectorStore, array $parameters): VectorStoreResponse;
public function modify(string $vectorStoreId, array $parameters): VectorStoreResponse;

/**
* Delete a vector store.
*
* https://platform.openai.com/docs/api-reference/vector-stores/delete
*/
public function delete(string $vectorStore): VectorStoreDeleteResponse;
public function delete(string $vectorStoreId): VectorStoreDeleteResponse;

/**
* Manage the files related to the vector store
Expand Down
4 changes: 3 additions & 1 deletion src/Contracts/Resources/VectorStoresFileBatchesContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function cancel(string $vectorStoreId, string $fileBatchId): VectorStoreF
* Lists the files within a file batch within a vector store
*
* @see https://platform.openai.com/docs/api-reference/vector-stores-file-batches/listBatchFiles
*
* @param array<string, mixed> $parameters
*/
public function listFiles(string $vectorStoreId, string $fileBatchId): VectorStoreFileListResponse;
public function listFiles(string $vectorStoreId, string $fileBatchId, array $parameters = []): VectorStoreFileListResponse;
}
4 changes: 3 additions & 1 deletion src/Contracts/Resources/VectorStoresFilesContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public function create(string $vectorStoreId, array $parameters): VectorStoreFil
* Returns a list of files within a vector store.
*
* @see https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles
*
* @param array<string, mixed> $parameters
*/
public function list(string $vectorStoreId): VectorStoreFileListResponse;
public function list(string $vectorStoreId, array $parameters = []): VectorStoreFileListResponse;

/**
* Retrieves a file within a vector store.
Expand Down
18 changes: 10 additions & 8 deletions src/Resources/VectorStores.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public function create(array $parameters): VectorStoreResponse
* Returns a list of vector stores.
*
* @see https://platform.openai.com/docs/api-reference/vector-stores/list
*
* @param array<string, mixed> $parameters
*/
public function list(): VectorStoreListResponse
public function list(array $parameters = []): VectorStoreListResponse
{
$payload = Payload::list('vector_stores');
$payload = Payload::list('vector_stores', $parameters);

/** @var Response<array{object: string, data: array<int, array{id: string, object: string, created_at: int, name: ?string, usage_bytes: int, file_counts: array{in_progress: int, completed: int, failed: int, cancelled: int, total: int}, status: string, expires_after: ?array{anchor: string, days: int}, expires_at: ?int, last_active_at: ?int, metadata: array<string, string>}>, first_id: ?string, last_id: ?string, has_more: bool}> $response */
$response = $this->transporter->requestObject($payload);
Expand All @@ -54,9 +56,9 @@ public function list(): VectorStoreListResponse
*
* @see https://platform.openai.com/docs/api-reference/vector-stores/retrieve
*/
public function retrieve(string $vectorStore): VectorStoreResponse
public function retrieve(string $vectorStoreId): VectorStoreResponse
{
$payload = Payload::retrieve('vector_stores', $vectorStore);
$payload = Payload::retrieve('vector_stores', $vectorStoreId);

/** @var Response<array{id: string, object: string, created_at: int, name: ?string, usage_bytes: int, file_counts: array{in_progress: int, completed: int, failed: int, cancelled: int, total: int}, status: string, expires_after: ?array{anchor: string, days: int}, expires_at: ?int, last_active_at: ?int, metadata: array<string, string>}> $response */
$response = $this->transporter->requestObject($payload);
Expand All @@ -71,9 +73,9 @@ public function retrieve(string $vectorStore): VectorStoreResponse
*
* @param array<string, mixed> $parameters
*/
public function modify(string $vectorStore, array $parameters): VectorStoreResponse
public function modify(string $vectorStoreId, array $parameters): VectorStoreResponse
{
$payload = Payload::modify('vector_stores', $vectorStore, $parameters);
$payload = Payload::modify('vector_stores', $vectorStoreId, $parameters);

/** @var Response<array{id: string, object: string, created_at: int, name: ?string, usage_bytes: int, file_counts: array{in_progress: int, completed: int, failed: int, cancelled: int, total: int}, status: string, expires_after: ?array{anchor: string, days: int}, expires_at: ?int, last_active_at: ?int, metadata: array<string, string>}> $response */
$response = $this->transporter->requestObject($payload);
Expand All @@ -86,9 +88,9 @@ public function modify(string $vectorStore, array $parameters): VectorStoreRespo
*
* https://platform.openai.com/docs/api-reference/vector-stores/delete
*/
public function delete(string $vectorStore): VectorStoreDeleteResponse
public function delete(string $vectorStoreId): VectorStoreDeleteResponse
{
$payload = Payload::delete('vector_stores', $vectorStore);
$payload = Payload::delete('vector_stores', $vectorStoreId);

/** @var Response<array{id: string, object: string, deleted: bool}> $response */
$response = $this->transporter->requestObject($payload);
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/VectorStoresFileBatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public function retrieve(string $vectorStoreId, string $fileBatchId): VectorStor
* Lists the files within a file batch within a vector store
*
* @see https://platform.openai.com/docs/api-reference/vector-stores-file-batches/listBatchFiles
*
* @param array<string, mixed> $parameters
*/
public function listFiles(string $vectorStoreId, string $fileBatchId): VectorStoreFileListResponse
public function listFiles(string $vectorStoreId, string $fileBatchId, array $parameters = []): VectorStoreFileListResponse
{
$payload = Payload::list("vector_stores/$vectorStoreId/file_batches/$fileBatchId/files");
$payload = Payload::list("vector_stores/$vectorStoreId/file_batches/$fileBatchId/files", $parameters);

/** @var Response<array{object: string, data: array<int, array{id: string, object: string, usage_bytes: int, created_at: int, vector_store_id: string, status: string, last_error: ?array{code: string, message: string}, chunking_strategy: array{type: 'static', static: array{max_chunk_size_tokens: int, chunk_overlap_tokens: int}}|array{type: 'other'}}>, first_id: ?string, last_id: ?string, has_more: bool}> $response */
$response = $this->transporter->requestObject($payload);
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/VectorStoresFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public function create(string $vectorStoreId, array $parameters): VectorStoreFil
* Returns a list of files within a vector store.
*
* @see https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles
*
* @param array<string, mixed> $parameters
*/
public function list(string $vectorStoreId): VectorStoreFileListResponse
public function list(string $vectorStoreId, array $parameters = []): VectorStoreFileListResponse
{
$payload = Payload::list("vector_stores/$vectorStoreId/files");
$payload = Payload::list("vector_stores/$vectorStoreId/files", $parameters);

/** @var Response<array{object: string, data: array<int, array{id: string, object: string, usage_bytes: int, created_at: int, vector_store_id: string, status: string, last_error: ?array{code: string, message: string}, chunking_strategy: array{type: 'static', static: array{max_chunk_size_tokens: int, chunk_overlap_tokens: int}}|array{type: 'other'}}>, first_id: ?string, last_id: ?string, has_more: bool}> $response */
$response = $this->transporter->requestObject($payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function create(string $vectorStoreId, array $parameters): VectorStoreFil
return $this->record(__FUNCTION__, func_get_args());
}

public function listFiles(string $vectorStoreId, string $fileBatchId): VectorStoreFileListResponse
public function listFiles(string $vectorStoreId, string $fileBatchId, array $parameters = []): VectorStoreFileListResponse
{
return $this->record(__FUNCTION__, func_get_args());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/Resources/VectorStoresFilesTestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function create(string $vectorStoreId, array $parameters): VectorStoreFil
return $this->record(__FUNCTION__, func_get_args());
}

public function list(string $vectorStoreId): VectorStoreFileListResponse
public function list(string $vectorStoreId, array $parameters = []): VectorStoreFileListResponse
{
return $this->record(__FUNCTION__, func_get_args());
}
Expand Down
8 changes: 4 additions & 4 deletions src/Testing/Resources/VectorStoresTestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public function resource(): string
return VectorStores::class;
}

public function modify(string $vectorStore, array $parameters): VectorStoreResponse
public function modify(string $vectorStoreId, array $parameters): VectorStoreResponse
{
return $this->record(__FUNCTION__, func_get_args());
}

public function retrieve(string $vectorStore): VectorStoreResponse
public function retrieve(string $vectorStoreId): VectorStoreResponse
{
return $this->record(__FUNCTION__, func_get_args());
}

public function delete(string $vectorStore): VectorStoreDeleteResponse
public function delete(string $vectorStoreId): VectorStoreDeleteResponse
{
return $this->record(__FUNCTION__, func_get_args());
}
Expand All @@ -40,7 +40,7 @@ public function create(array $parameters): VectorStoreResponse
return $this->record(__FUNCTION__, func_get_args());
}

public function list(): VectorStoreListResponse
public function list(array $parameters = []): VectorStoreListResponse
{
return $this->record(__FUNCTION__, func_get_args());
}
Expand Down

0 comments on commit 667134c

Please sign in to comment.