base.php
2 years ago
embed.php
2 years ago
function.php
2 years ago
image.php
2 years ago
parameter.php
2 years ago
text.php
2 years ago
transcribe.php
2 years ago
embed.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query_Embed extends Meow_MWAI_Query_Base { |
| 4 | |
| 5 | public function __construct( $promptOrQuery = null, ?string $model = 'text-embedding-ada-002' ) { |
| 6 | |
| 7 | if ( is_a( $promptOrQuery, 'Meow_MWAI_Query_Text' ) ) { |
| 8 | $lastMessage = $promptOrQuery->getLastMessage(); |
| 9 | if ( !empty( $lastMessage ) ) { |
| 10 | $this->setPrompt( $lastMessage ); |
| 11 | } |
| 12 | $this->setModel( $model ); |
| 13 | $this->mode = 'embedding'; |
| 14 | $this->session = $promptOrQuery->session; |
| 15 | $this->env = $promptOrQuery->env; |
| 16 | $this->apiKey = $promptOrQuery->apiKey; |
| 17 | $this->service = $promptOrQuery->service; |
| 18 | $this->botId = $promptOrQuery->botId; |
| 19 | } |
| 20 | else { |
| 21 | parent::__construct( $promptOrQuery ? $promptOrQuery : '' ); |
| 22 | $this->setModel( $model ); |
| 23 | $this->mode = 'embedding'; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | public function injectParams( $params ) { |
| 28 | if ( !empty( $params['prompt'] ) ) { |
| 29 | $this->setPrompt( $params['prompt'] ); |
| 30 | } |
| 31 | if ( !empty( $params['apiKey'] ) ) { |
| 32 | $this->setApiKey( $params['apiKey'] ); |
| 33 | } |
| 34 | if ( !empty( $params['env'] ) ) { |
| 35 | $this->setEnv( $params['env'] ); |
| 36 | } |
| 37 | if ( !empty( $params['session'] ) ) { |
| 38 | $this->setSession( $params['session'] ); |
| 39 | } |
| 40 | if ( !empty( $params['service'] ) ) { |
| 41 | $this->setService( $params['service'] ); |
| 42 | } |
| 43 | if ( !empty( $params['api_key'] ) ) { |
| 44 | $this->setApiKey( $params['apiKey'] ); |
| 45 | } |
| 46 | if ( !empty( $params['apiKey'] ) ) { |
| 47 | $this->setApiKey( $params['apiKey'] ); |
| 48 | } |
| 49 | if ( !empty( $params['botId'] ) ) { |
| 50 | $this->setBotId( $params['botId'] ); |
| 51 | } |
| 52 | } |
| 53 | } |