1074b7701SAndreas Gohr<?php 2074b7701SAndreas Gohr 3074b7701SAndreas Gohrnamespace dokuwiki\plugin\aichat\Model\Ollama; 4074b7701SAndreas Gohr 5074b7701SAndreas Gohruse dokuwiki\plugin\aichat\Model\EmbeddingInterface; 6074b7701SAndreas Gohr 7074b7701SAndreas Gohrclass EmbeddingModel extends AbstractOllama implements EmbeddingInterface 8074b7701SAndreas Gohr{ 9074b7701SAndreas Gohr /** @inheritdoc */ 10074b7701SAndreas Gohr public function getEmbedding($text): array 11074b7701SAndreas Gohr { 12074b7701SAndreas Gohr $data = [ 1394b5d70eSMax Theisen 'model' => $this->getModelName(), 14d2192bbaSMax Theisen 'input' => $text, 154dd0657eSAndreas Gohr 'options' => [ 164dd0657eSAndreas Gohr 'num_ctx' => $this->getMaxInputTokenLength() 174dd0657eSAndreas Gohr ] 18074b7701SAndreas Gohr ]; 19*cc7172ceSAndreas Gohr $response = $this->request('embed', $data); 20d2192bbaSMax Theisen return $response['embeddings'][0] ?? []; 21d2192bbaSMax Theisen } 22074b7701SAndreas Gohr} 23