Skip to content

Commit

Permalink
Merge pull request #11 from GeraudBourdin/main
Browse files Browse the repository at this point in the history
Add params:  best_of / ignore_eos / use_beam_search / skip_special_tokens for vllm self inference support.
  • Loading branch information
GeraudBourdin authored Apr 2, 2024
2 parents e2fe445 + 94bde29 commit 581eaf2
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/MistralClient.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace Partitech\PhpMistral;

ini_set('default_socket_timeout', '-1');

use Generator;
Expand Down Expand Up @@ -121,6 +122,12 @@ protected function makeChatCompletionRequest(Messages $messages, array $params,
$return['top_p'] = $params['top_p'];
}


if (isset($params['top_k']) && is_int($params['top_k'])) {
$return['top_k'] = $params['top_k'];
}


if (isset($params['random_seed']) && is_int($params['random_seed'])) {
$return['random_seed'] = $params['random_seed'];
}
Expand Down Expand Up @@ -153,12 +160,28 @@ protected function makeChatCompletionRequest(Messages $messages, array $params,
$return['n'] = $params['n'];
}

if (isset($params['presence_penalty']) && is_int($params['presence_penalty']) && $params['presence_penalty'] >= -2 && $params['presence_penalty'] <= 2) {
$return['presence_penalty'] = $params['presence_penalty'];
if (isset($params['presence_penalty']) && is_numeric($params['presence_penalty']) && $params['presence_penalty'] >= -2 && $params['presence_penalty'] <= 2) {
$return['presence_penalty'] = (float) $params['presence_penalty'];
}

if (isset($params['frequency_penalty']) && is_numeric($params['frequency_penalty'])) {
$return['frequency_penalty'] = (float) $params['frequency_penalty'];
}

if (isset($params['best_of']) && is_int($params['best_of'])) {
$return['best_of'] = $params['best_of'];
}

if (isset($params['ignore_eos']) && is_bool($params['ignore_eos'])) {
$return['ignore_eos'] = $params['ignore_eos'];
}

if (isset($params['use_beam_search']) && is_bool($params['use_beam_search'])) {
$return['use_beam_search'] = $params['use_beam_search'];
}

if (isset($params['frequency_penalty']) && is_int($params['frequency_penalty'])) {
$return['frequency_penalty'] = $params['frequency_penalty'];
if (isset($params['skip_special_tokens']) && is_bool($params['skip_special_tokens'])) {
$return['skip_special_tokens'] = $params['skip_special_tokens'];
}


Expand Down

0 comments on commit 581eaf2

Please sign in to comment.