modules
3 years ago
admin.php
3 years ago
ai.php
3 years ago
answer.php
3 years ago
core.php
3 years ago
init.php
3 years ago
openai.php
3 years ago
query.php
3 years ago
queryimage.php
3 years ago
querytext.php
3 years ago
rest.php
3 years ago
ui.php
3 years ago
querytext.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_QueryText extends Meow_MWAI_Query { |
| 4 | public $maxTokens = 16; |
| 5 | public $temperature = 0.8; |
| 6 | public $stop = null; |
| 7 | |
| 8 | public function __construct( $prompt = '', $maxTokens = 16, $model = 'text-davinci-003' ) { |
| 9 | $this->prompt = $prompt; |
| 10 | $this->maxTokens = $maxTokens; |
| 11 | $this->model = $model; |
| 12 | $this->mode = "completion"; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * The maximum number of tokens to generate in the completion. |
| 17 | * The token count of your prompt plus max_tokens cannot exceed the model's context length. |
| 18 | * Most models have a context length of 2048 tokens (except for the newest models, which support 4096). |
| 19 | * @param float $prompt The maximum number of tokens. |
| 20 | */ |
| 21 | public function setMaxTokens( $maxTokens ) { |
| 22 | $this->maxTokens = $maxTokens; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Set the sampling temperature to use. Higher values means the model will take more risks. |
| 27 | * Try 0.9 for more creative applications, and 0 for ones with a well-defined answer. |
| 28 | * @param float $temperature The temperature. |
| 29 | */ |
| 30 | public function setTemperature( $temperature ) { |
| 31 | $temperature = floatval( $temperature ); |
| 32 | if ( $temperature > 1 ) { |
| 33 | $temperature = 1; |
| 34 | } |
| 35 | if ( $temperature < 0 ) { |
| 36 | $temperature = 0; |
| 37 | } |
| 38 | $this->temperature = $temperature; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Up to 4 sequences where the API will stop generating further tokens. |
| 43 | * The returned text will not contain the stop sequence. |
| 44 | * @param float $stop The stop. |
| 45 | */ |
| 46 | public function setStop( $stop ) { |
| 47 | if ( !empty( $stop ) ) { |
| 48 | $this->stop = $stop; |
| 49 | } |
| 50 | } |
| 51 | } |