1*dce0dee5SAndreas Gohr<?php 2*dce0dee5SAndreas Gohr 3*dce0dee5SAndreas Gohrnamespace dokuwiki\plugin\aichat\Model\OpenAI; 4*dce0dee5SAndreas Gohr 5*dce0dee5SAndreas Gohruse dokuwiki\plugin\aichat\Model\ChatInterface; 6*dce0dee5SAndreas Gohr 7*dce0dee5SAndreas Gohrclass ChatModel extends AbstractOpenAIModel implements ChatInterface 8*dce0dee5SAndreas Gohr{ 9*dce0dee5SAndreas Gohr /** @inheritdoc */ 10*dce0dee5SAndreas Gohr public function getAnswer(array $messages): string 11*dce0dee5SAndreas Gohr { 12*dce0dee5SAndreas Gohr $data = [ 13*dce0dee5SAndreas Gohr 'messages' => $messages, 14*dce0dee5SAndreas Gohr 'model' => $this->getModelName(), 15*dce0dee5SAndreas Gohr 'max_tokens' => null, 16*dce0dee5SAndreas Gohr 'stream' => false, 17*dce0dee5SAndreas Gohr 'n' => 1, // number of completions 18*dce0dee5SAndreas Gohr 'temperature' => 0.0, 19*dce0dee5SAndreas Gohr ]; 20*dce0dee5SAndreas Gohr $response = $this->request('chat/completions', $data); 21*dce0dee5SAndreas Gohr return $response['choices'][0]['message']['content']; 22*dce0dee5SAndreas Gohr } 23*dce0dee5SAndreas Gohr} 24