xref: /plugin/aichat/Model/Gemini/EmbeddingModel.php (revision 10789c175b44bee75b54261fbdf3bb1e6d176759)
1*10789c17SAndreas Gohr<?php
2*10789c17SAndreas Gohr
3*10789c17SAndreas Gohrnamespace dokuwiki\plugin\aichat\Model\Gemini;
4*10789c17SAndreas Gohr
5*10789c17SAndreas Gohruse dokuwiki\plugin\aichat\Model\EmbeddingInterface;
6*10789c17SAndreas Gohr
7*10789c17SAndreas Gohrclass EmbeddingModel extends AbstractGeminiModel implements EmbeddingInterface
8*10789c17SAndreas Gohr{
9*10789c17SAndreas Gohr
10*10789c17SAndreas Gohr    public function getEmbedding($text): array
11*10789c17SAndreas Gohr    {
12*10789c17SAndreas Gohr
13*10789c17SAndreas Gohr        $data = [
14*10789c17SAndreas Gohr            'model' => $this->getModelName(),
15*10789c17SAndreas Gohr            'content' => [
16*10789c17SAndreas Gohr                'parts' => [
17*10789c17SAndreas Gohr                    ['text' => $text]
18*10789c17SAndreas Gohr                ]
19*10789c17SAndreas Gohr            ]
20*10789c17SAndreas Gohr        ];
21*10789c17SAndreas Gohr
22*10789c17SAndreas Gohr        $response = $this->request($this->getModelName(), 'embedContent', $data);
23*10789c17SAndreas Gohr
24*10789c17SAndreas Gohr        return $response['embedding']['values'];
25*10789c17SAndreas Gohr    }
26*10789c17SAndreas Gohr}
27