Skip to content

Commit

Permalink
Added handling for when prompt_eval_count is not in the response (it …
Browse files Browse the repository at this point in the history
…is often not) so it does not error out (#2)

Added handling for when prompt_eval_count is not in the response (it is often not) so it does not error out
  • Loading branch information
detain authored May 4, 2024
1 parent df6d306 commit 040ed08
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Client/Response/ChatResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public static function fromArray(array $data): self
createdAt: new DateTimeImmutable($data['created_at']),
message: Message::fromArray($data['message']),
done: $data['done'],
totalDuration: $data['total_duration'],
loadDuration: $data['load_duration'],
promptEvalCount: $data['prompt_eval_count'],
promptEvalDuration: $data['prompt_eval_duration'],
evalCount: $data['eval_count'],
totalDuration: $data['total_duration'] ?? null,
loadDuration: $data['load_duration'] ?? null,
promptEvalCount: $data['prompt_eval_count'] ?? null,
promptEvalDuration: $data['prompt_eval_duration'] ?? null,
evalCount: $data['eval_count'] ?? null,
);
}

Expand All @@ -27,11 +27,11 @@ public function __construct(
public readonly DateTimeImmutable $createdAt,
public readonly Message $message,
public readonly bool $done,
public readonly int $totalDuration,
public readonly int $loadDuration,
public readonly int $promptEvalCount,
public readonly int $promptEvalDuration,
public readonly int $evalCount,
public readonly ?int $totalDuration,
public readonly ?int $loadDuration,
public readonly ?int $promptEvalCount,
public readonly ?int $promptEvalDuration,
public readonly ?int $evalCount,
) {
}
}

0 comments on commit 040ed08

Please sign in to comment.