Skip to content
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

Add default system_fingerprint to completion create response fixture #310

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Responses/Completions/CreateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private function __construct(
public readonly string $object,
public readonly int $created,
public readonly string $model,
public readonly ?string $systemFingerprint,
public readonly array $choices,
public readonly CreateResponseUsage $usage,
private readonly MetaInformation $meta,
Expand All @@ -41,7 +42,7 @@ private function __construct(
/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{id: string, object: string, created: int, model: string, choices: array<int, array{text: string, index: int, logprobs: array{tokens: array<int, string>, token_logprobs: array<int, float>, top_logprobs: array<int, string>|null, text_offset: array<int, int>}|null, finish_reason: string}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}} $attributes
* @param array{id: string, object: string, created: int, model: string, system_fingerprint?: string, choices: array<int, array{text: string, index: int, logprobs: array{tokens: array<int, string>, token_logprobs: array<int, float>, top_logprobs: array<int, string>|null, text_offset: array<int, int>}|null, finish_reason: string}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}} $attributes
*/
public static function from(array $attributes, MetaInformation $meta): self
{
Expand All @@ -54,6 +55,7 @@ public static function from(array $attributes, MetaInformation $meta): self
$attributes['object'],
$attributes['created'],
$attributes['model'],
$attributes['system_fingerprint'] ?? null,
$choices,
CreateResponseUsage::from($attributes['usage']),
$meta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ final class CreateResponseFixture
'object' => 'text_completion',
'created' => 1_589_478_378,
'model' => 'gpt-3.5-turbo-instruct',
'system_fingerprint' => null,
'choices' => [
[
'text' => "\n\nThis is a fake completion response.",
Expand Down
2 changes: 2 additions & 0 deletions tests/Responses/Completions/CreateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
'text' => 'awesome!',
],
],
'system_fingerprint' => 'fp_44709d6fcb',
]);

expect($response)
->id->toBe('cmpl-1234')
->systemFingerprint->toBe('fp_44709d6fcb')
->and($response->choices[0])
->text->toBe('awesome!')
->index->toBe(0);
Expand Down