1*dce0dee5SAndreas Gohr<?php 2*dce0dee5SAndreas Gohr 3*dce0dee5SAndreas Gohrnamespace dokuwiki\plugin\aichat\Model\OpenAI; 4*dce0dee5SAndreas Gohr 5*dce0dee5SAndreas Gohruse dokuwiki\plugin\aichat\Model\EmbeddingInterface; 6*dce0dee5SAndreas Gohr 7*dce0dee5SAndreas Gohrclass EmbeddingModel extends AbstractOpenAIModel implements EmbeddingInterface 8*dce0dee5SAndreas Gohr{ 9*dce0dee5SAndreas Gohr /** @inheritdoc */ 10*dce0dee5SAndreas Gohr public function getEmbedding($text): array 11*dce0dee5SAndreas Gohr { 12*dce0dee5SAndreas Gohr $data = [ 13*dce0dee5SAndreas Gohr 'model' => $this->getModelName(), 14*dce0dee5SAndreas Gohr 'input' => [$text], 15*dce0dee5SAndreas Gohr ]; 16*dce0dee5SAndreas Gohr $response = $this->request('embeddings', $data); 17*dce0dee5SAndreas Gohr 18*dce0dee5SAndreas Gohr return $response['data'][0]['embedding']; 19*dce0dee5SAndreas Gohr } 20*dce0dee5SAndreas Gohr} 21