| 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 |
} |