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
api.php
21 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_API { |
| 4 | |
| 5 | public function simpleTextQuery( $prompt, $options = array() ) { |
| 6 | global $mwai_core; |
| 7 | $query = new Meow_MWAI_QueryText( $prompt ); |
| 8 | $query->injectParams( $options ); |
| 9 | $answer = $mwai_core->ai->run( $query ); |
| 10 | return $answer->result; |
| 11 | } |
| 12 | |
| 13 | public function moderationCheck( $text ) { |
| 14 | global $mwai_core; |
| 15 | $openai = new Meow_MWAI_OpenAI( $mwai_core ); |
| 16 | $res = $openai->moderate( $text ); |
| 17 | if ( !empty( $res ) && !empty( $res['results'] ) ) { |
| 18 | return (bool)$res['results'][0]['flagged']; |
| 19 | } |
| 20 | } |
| 21 | } |