xref: /plugin/aichat/Model/Groq/ChatModel.php (revision 7775eee7bc2214cbd8bc6b5c95ff60d44e95c8c2)
1074b7701SAndreas Gohr<?php
2074b7701SAndreas Gohr
3074b7701SAndreas Gohrnamespace dokuwiki\plugin\aichat\Model\Groq;
4074b7701SAndreas Gohr
5074b7701SAndreas Gohr
6*7775eee7SAndreas Gohruse dokuwiki\plugin\aichat\Model\Generic\ChatModel as GenericChatModel;
7*7775eee7SAndreas Gohr
8*7775eee7SAndreas Gohrclass ChatModel extends GenericChatModel
9074b7701SAndreas Gohr{
10d72a84c5SAndreas Gohr    protected $apiurl = 'https://api.groq.com/openai/v1';
11074b7701SAndreas Gohr
12074b7701SAndreas Gohr    /** @inheritdoc */
132e22aefbSAndreas Gohr    function loadUnknownModelInfo(): array
14074b7701SAndreas Gohr    {
152e22aefbSAndreas Gohr        $info = parent::loadUnknownModelInfo();
16074b7701SAndreas Gohr
17d72a84c5SAndreas Gohr        $model = $this->sendAPIRequest('GET', $this->apiurl . '/models/' . $this->modelName, '');
182e22aefbSAndreas Gohr        if (isset($model['context_window'])) {
192e22aefbSAndreas Gohr            $info['inputTokens'] = $model['context_window'];
20074b7701SAndreas Gohr        }
212e22aefbSAndreas Gohr        return $info;
22074b7701SAndreas Gohr    }
23074b7701SAndreas Gohr}
24