xref: /plugin/aichat/Model/Ollama/EmbeddingModel.php (revision 4dd0657e5ac7e828b159f619391769caa2e5332f)
1<?php
2
3namespace dokuwiki\plugin\aichat\Model\Ollama;
4
5use dokuwiki\plugin\aichat\Model\EmbeddingInterface;
6
7class EmbeddingModel extends AbstractOllama implements EmbeddingInterface
8{
9    /** @inheritdoc */
10    public function getEmbedding($text): array
11    {
12        $data = [
13            'model' => $this->getModelName(),
14            'prompt' => $text,
15            'options' => [
16                'num_ctx' => $this->getMaxInputTokenLength()
17            ]
18        ];
19        $response = $this->request('embeddings', $data);
20
21        return $response['embedding'];
22    }
23}
24