xref: /plugin/aichat/Model/Ollama/ChatModel.php (revision 074b7701298bfc2f8fb181bdb361a02be5a51191)
1*074b7701SAndreas Gohr<?php
2*074b7701SAndreas Gohr
3*074b7701SAndreas Gohrnamespace dokuwiki\plugin\aichat\Model\Ollama;
4*074b7701SAndreas Gohr
5*074b7701SAndreas Gohruse dokuwiki\plugin\aichat\Model\ChatInterface;
6*074b7701SAndreas Gohr
7*074b7701SAndreas Gohrclass ChatModel extends AbstractOllama implements ChatInterface
8*074b7701SAndreas Gohr{
9*074b7701SAndreas Gohr    /** @inheritdoc */
10*074b7701SAndreas Gohr    public function getAnswer(array $messages): string
11*074b7701SAndreas Gohr    {
12*074b7701SAndreas Gohr        $data = [
13*074b7701SAndreas Gohr            'messages' => $messages,
14*074b7701SAndreas Gohr            'model' => $this->getModelName(),
15*074b7701SAndreas Gohr            'stream' => false,
16*074b7701SAndreas Gohr        ];
17*074b7701SAndreas Gohr        $response = $this->request('chat', $data);
18*074b7701SAndreas Gohr        return $response['message']['content'];
19*074b7701SAndreas Gohr    }
20*074b7701SAndreas Gohr}
21