xref: /plugin/aichat/Model/Ollama/EmbeddingModel.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\EmbeddingInterface;
6*074b7701SAndreas Gohr
7*074b7701SAndreas Gohrclass EmbeddingModel extends AbstractOllama implements EmbeddingInterface
8*074b7701SAndreas Gohr{
9*074b7701SAndreas Gohr    /** @inheritdoc */
10*074b7701SAndreas Gohr    public function getEmbedding($text): array
11*074b7701SAndreas Gohr    {
12*074b7701SAndreas Gohr        $data = [
13*074b7701SAndreas Gohr            'model' => $this->getModelName(),
14*074b7701SAndreas Gohr            'prompt' => $text,
15*074b7701SAndreas Gohr        ];
16*074b7701SAndreas Gohr        $response = $this->request('embeddings', $data);
17*074b7701SAndreas Gohr
18*074b7701SAndreas Gohr        return $response['embedding'];
19*074b7701SAndreas Gohr    }
20*074b7701SAndreas Gohr}
21