-
-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add chunking strategy on VectorStoreFileResponse
- Loading branch information
1 parent
728a944
commit 640a251
Showing
8 changed files
with
136 additions
and
9 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
52 changes: 52 additions & 0 deletions
52
src/Responses/VectorStores/Files/VectorStoreFileResponseChunkingStrategyOther.php
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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenAI\Responses\VectorStores\Files; | ||
|
||
use OpenAI\Contracts\ResponseContract; | ||
use OpenAI\Responses\Concerns\ArrayAccessible; | ||
use OpenAI\Testing\Responses\Concerns\Fakeable; | ||
|
||
/** | ||
* @implements ResponseContract<array{type: 'other'}> | ||
*/ | ||
final class VectorStoreFileResponseChunkingStrategyOther implements ResponseContract | ||
{ | ||
/** | ||
* @use ArrayAccessible<array{type: 'other'}> | ||
*/ | ||
use ArrayAccessible; | ||
|
||
use Fakeable; | ||
|
||
/** | ||
* @param 'other' $type | ||
*/ | ||
private function __construct( | ||
public readonly string $type, | ||
) { | ||
} | ||
|
||
/** | ||
* Acts as static factory, and returns a new Response instance. | ||
* | ||
* @param array{type: 'other'} $attributes | ||
*/ | ||
public static function from(array $attributes): self | ||
{ | ||
return new self( | ||
$attributes['type'], | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'type' => $this->type, | ||
]; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/Responses/VectorStores/Files/VectorStoreFileResponseChunkingStrategyStatic.php
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenAI\Responses\VectorStores\Files; | ||
|
||
use OpenAI\Contracts\ResponseContract; | ||
use OpenAI\Responses\Concerns\ArrayAccessible; | ||
use OpenAI\Testing\Responses\Concerns\Fakeable; | ||
|
||
/** | ||
* @implements ResponseContract<array{type: 'static', static: array{max_chunk_size_tokens: int, chunk_overlap_tokens: int}}> | ||
*/ | ||
final class VectorStoreFileResponseChunkingStrategyStatic implements ResponseContract | ||
{ | ||
/** | ||
* @use ArrayAccessible<array{type: 'static', static: array{max_chunk_size_tokens: int, chunk_overlap_tokens: int}}> | ||
*/ | ||
use ArrayAccessible; | ||
|
||
use Fakeable; | ||
|
||
/** | ||
* @param 'static' $type | ||
*/ | ||
private function __construct( | ||
public readonly string $type, | ||
public readonly int $maxChunkSizeTokens, | ||
public readonly int $chunkOverlapTokens, | ||
) { | ||
} | ||
|
||
/** | ||
* Acts as static factory, and returns a new Response instance. | ||
* | ||
* @param array{type: 'static', static: array{max_chunk_size_tokens: int, chunk_overlap_tokens: int}} $attributes | ||
*/ | ||
public static function from(array $attributes): self | ||
{ | ||
return new self( | ||
$attributes['type'], | ||
$attributes['static']['max_chunk_size_tokens'], | ||
$attributes['static']['chunk_overlap_tokens'], | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'type' => $this->type, | ||
'static' => [ | ||
'max_chunk_size_tokens' => $this->maxChunkSizeTokens, | ||
'chunk_overlap_tokens' => $this->chunkOverlapTokens, | ||
], | ||
]; | ||
} | ||
} |
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