assistant.php
1 year ago
assistfeedback.php
1 year ago
base.php
1 year ago
droppedfile.php
1 year ago
embed.php
1 year ago
feedback.php
1 year ago
function.php
1 year ago
image.php
1 year ago
parameter.php
2 years ago
text.php
1 year ago
transcribe.php
1 year ago
feedback.php
76 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query_Feedback extends Meow_MWAI_Query_Text implements JsonSerializable { |
| 4 | |
| 5 | public $lastReply = null; |
| 6 | public $originalQuery = null; |
| 7 | public array $blocks; |
| 8 | |
| 9 | #region Constructors, Serialization |
| 10 | |
| 11 | public function __construct( Meow_MWAI_Reply $reply, Meow_MWAI_Query_Text $query ) { |
| 12 | parent::__construct( $query->message ); |
| 13 | |
| 14 | $this->lastReply = $reply; |
| 15 | $this->originalQuery = $query; |
| 16 | |
| 17 | if ( !empty( $query->model ) ) { |
| 18 | $this->set_model( $query->model ); |
| 19 | } |
| 20 | if ( !empty( $query->maxTokens ) ) { |
| 21 | $this->set_max_tokens( $query->maxTokens ); |
| 22 | } |
| 23 | if ( !empty( $query->temperature ) ) { |
| 24 | $this->set_temperature( $query->temperature ); |
| 25 | } |
| 26 | if ( !empty( $query->scope ) ) { |
| 27 | $this->set_scope( $query->scope ); |
| 28 | } |
| 29 | if ( !empty( $query->session ) ) { |
| 30 | $this->set_session( $query->session ); |
| 31 | } |
| 32 | if ( !empty( $query->botId ) ) { |
| 33 | $this->set_bot_id( $query->botId ); |
| 34 | } |
| 35 | if ( !empty( $query->envId ) ) { |
| 36 | $this->set_env_id( $query->envId ); |
| 37 | } |
| 38 | if ( !empty( $query->functions ) ) { |
| 39 | $this->set_functions( $query->functions ); |
| 40 | } |
| 41 | if ( !empty( $query->instructions ) ) { |
| 42 | $this->set_instructions( $query->instructions ); |
| 43 | } |
| 44 | if ( !empty( $query->messages ) ) { |
| 45 | $this->set_messages( $query->messages ); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | public function add_feedback_block( $block ) { |
| 50 | $this->blocks[] = $block; |
| 51 | } |
| 52 | |
| 53 | #[\ReturnTypeWillChange] |
| 54 | public function jsonSerialize(): array { |
| 55 | $json = [ |
| 56 | 'message' => $this->message, |
| 57 | 'blocks' => $this->blocks, |
| 58 | |
| 59 | 'ai' => [ |
| 60 | 'model' => $this->model, |
| 61 | 'feature' => $this->feature, |
| 62 | ], |
| 63 | |
| 64 | 'system' => [ |
| 65 | 'class' => get_class( $this ), |
| 66 | 'envId' => $this->envId, |
| 67 | 'scope' => $this->scope, |
| 68 | 'session' => $this->session, |
| 69 | ] |
| 70 | ]; |
| 71 | |
| 72 | return $json; |
| 73 | } |
| 74 | |
| 75 | #endregion |
| 76 | } |