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