Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
rajentrivedi authored and github-actions[bot] committed Dec 5, 2023
1 parent 6c95db5 commit 8f13bdc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/TokenCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public function gpt_utf8_encode(string $str): string
for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
switch (true) {
case $str[$i] < "\x80": $str[$j] = $str[$i];
break;
break;
case $str[$i] < "\xC0": $str[$j] = "\xC2";
$str[++$j] = $str[$i];
break;
$str[++$j] = $str[$i];
break;
default: $str[$j] = "\xC3";
$str[++$j] = \chr(\ord($str[$i]) - 64);
break;
$str[++$j] = \chr(\ord($str[$i]) - 64);
break;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/TokenizerX.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class TokenizerX
{
public static function tokens($prompt, $model = null): array
{
if($model != null)
{
if ($model != null) {
$provider = new EncoderProvider();
$encoder = $provider->getForModel($model);
$tokens = $encoder->encode($prompt);

return $tokens;
}
$calculator = new TokenCalculator();
Expand All @@ -22,11 +22,11 @@ public static function tokens($prompt, $model = null): array

public static function count($prompt, $model = null): int
{
if($model != null)
{
if ($model != null) {
$provider = new EncoderProvider();
$encoder = $provider->getForModel($model);
$tokens = $encoder->encode($prompt);

return count($tokens);
}
$calculator = new TokenCalculator();
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/TokenizerXTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
});

it('counts special character tokens', function () {
$count = TokenizerX::count('@');
$this->assertSame(1, $count);
$count = TokenizerX::count('@');
$this->assertSame(1, $count);
});

0 comments on commit 8f13bdc

Please sign in to comment.