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            'input' => $text,
15            'options' => [
16                'num_ctx' => $this->getMaxInputTokenLength() ?: 512,
17            ]
18        ];
19        $response = $this->request('embed', $data);
20        return $response['embeddings'][0] ?? [];
21    }
22}
23