xref: /plugin/aichat/Model/ModelInterface.php (revision dce0dee5ef27bcbbc5570fc278f3e75f426c19c5)
14373d2bfSAndreas Gohr<?php
24373d2bfSAndreas Gohr
34373d2bfSAndreas Gohrnamespace dokuwiki\plugin\aichat\Model;
44373d2bfSAndreas Gohr
54373d2bfSAndreas Gohr/**
64373d2bfSAndreas Gohr * Interface for all models
74373d2bfSAndreas Gohr *
84373d2bfSAndreas Gohr * Model classes should inherit from AbstractModel, to avoid handling the statistics themselves.
94373d2bfSAndreas Gohr */
104373d2bfSAndreas Gohrinterface ModelInterface
114373d2bfSAndreas Gohr{
124373d2bfSAndreas Gohr    /**
13*dce0dee5SAndreas Gohr     * Initialize the model
14*dce0dee5SAndreas Gohr     *
15*dce0dee5SAndreas Gohr     * @param string $name The name of the model as used by the LLM provider
16*dce0dee5SAndreas Gohr     * @param array $config The plugin configuration
17*dce0dee5SAndreas Gohr     * @throws \Exception when the model cannot be initialized
18*dce0dee5SAndreas Gohr     */
19*dce0dee5SAndreas Gohr    public function __construct(string $name, array $config);
20*dce0dee5SAndreas Gohr
21*dce0dee5SAndreas Gohr    /**
224373d2bfSAndreas Gohr     * The name as used by the LLM provider
234373d2bfSAndreas Gohr     *
244373d2bfSAndreas Gohr     * @return string
254373d2bfSAndreas Gohr     */
264373d2bfSAndreas Gohr    public function getModelName();
274373d2bfSAndreas Gohr
284373d2bfSAndreas Gohr    /**
294373d2bfSAndreas Gohr     * Reset the usage statistics
304373d2bfSAndreas Gohr     *
314373d2bfSAndreas Gohr     * Usually not needed when only handling one operation per request, but useful in CLI
324373d2bfSAndreas Gohr     */
334373d2bfSAndreas Gohr    public function resetUsageStats();
344373d2bfSAndreas Gohr
354373d2bfSAndreas Gohr    /**
364373d2bfSAndreas Gohr     * Get the usage statistics for this instance
374373d2bfSAndreas Gohr     *
384373d2bfSAndreas Gohr     * @return string[]
394373d2bfSAndreas Gohr     */
404373d2bfSAndreas Gohr    public function getUsageStats();
41*dce0dee5SAndreas Gohr
42*dce0dee5SAndreas Gohr    /**
43*dce0dee5SAndreas Gohr     * Maximum number of tokens the model can handle as input.
44*dce0dee5SAndreas Gohr     *
45*dce0dee5SAndreas Gohr     * This is the absolute limit, including any context, prompts, questions etc.
46*dce0dee5SAndreas Gohr     */
47*dce0dee5SAndreas Gohr    public function getMaxInputTokenLength(): int;
48*dce0dee5SAndreas Gohr
49*dce0dee5SAndreas Gohr    /**
50*dce0dee5SAndreas Gohr     * The price for 1,000,000 input tokens in USD
51*dce0dee5SAndreas Gohr     */
52*dce0dee5SAndreas Gohr    public function getInputTokenPrice(): float;
53*dce0dee5SAndreas Gohr
544373d2bfSAndreas Gohr}
55