modules
3 years ago
admin.php
3 years ago
ai.php
3 years ago
answer.php
3 years ago
api.php
3 years ago
core.php
3 years ago
init.php
3 years ago
openai.php
3 years ago
query.php
3 years ago
queryembed.php
3 years ago
queryimage.php
3 years ago
querytext.php
3 years ago
querytranscribe.php
3 years ago
rest.php
3 years ago
ui.php
3 years ago
query.php
87 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query { |
| 4 | public $env = ''; |
| 5 | public $prompt = ''; |
| 6 | public $model = ''; |
| 7 | public $mode = ''; |
| 8 | public $apiKey = null; |
| 9 | public $session = null; |
| 10 | public $maxResults = 1; |
| 11 | |
| 12 | public function __construct( $prompt = '' ) { |
| 13 | global $mwai_core; |
| 14 | $this->setPrompt( $prompt ); |
| 15 | $this->session = $mwai_core->get_session_id(); |
| 16 | } |
| 17 | |
| 18 | public function replace( $search, $replace ) { |
| 19 | $this->prompt = str_replace( $search, $replace, $this->prompt ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * The environment, like "chatbot", "imagesbot", "chatbot-007", "textwriter", etc... |
| 24 | * Used for statistics, mainly. |
| 25 | * @param string $env The environment. |
| 26 | */ |
| 27 | public function setEnv( $env ) { |
| 28 | $this->env = $env; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * ID of the model to use. |
| 33 | * @param string $model ID of the model to use. |
| 34 | */ |
| 35 | public function setModel( $model ) { |
| 36 | $this->model = $model; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * The mode |
| 41 | * @param string $model ID of the model to use. |
| 42 | */ |
| 43 | public function setMode( $mode ) { |
| 44 | $this->mode = $mode; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Given a prompt, the model will return one or more predicted completions. |
| 49 | * It can also return the probabilities of alternative tokens at each position. |
| 50 | * @param string $prompt The prompt to generate completions. |
| 51 | */ |
| 52 | public function setPrompt( $prompt ) { |
| 53 | $this->prompt = $prompt; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * The API key to use. |
| 58 | * @param string $apiKey The API key. |
| 59 | */ |
| 60 | public function setApiKey( $apiKey ) { |
| 61 | $this->apiKey = $apiKey; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * The session ID to use. |
| 66 | * @param string $session The session ID. |
| 67 | */ |
| 68 | public function setSession( $session ) { |
| 69 | $this->session = $session; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * How many completions to generate for each prompt. |
| 74 | * Because this parameter generates many completions, it can quickly consume your token quota. |
| 75 | * Use carefully and ensure that you have reasonable settings for max_tokens and stop. |
| 76 | * @param float $maxResults Number of completions. |
| 77 | */ |
| 78 | public function setMaxResults( $maxResults ) { |
| 79 | $this->maxResults = intval( $maxResults ); |
| 80 | } |
| 81 | |
| 82 | // ** |
| 83 | // * Check if everything is correct, otherwise fix it (like the max number of tokens). |
| 84 | // */ |
| 85 | public function checkFix() { |
| 86 | } |
| 87 | } |