xref: /plugin/aichat/Model/ModelInterface.php (revision b446155b16a3c10edb48cb0dd79d0f47fb865445)
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    /**
13dce0dee5SAndreas Gohr     * Initialize the model
14dce0dee5SAndreas Gohr     *
15dce0dee5SAndreas Gohr     * @param string $name The name of the model as used by the LLM provider
16dce0dee5SAndreas Gohr     * @param array $config The plugin configuration
17dce0dee5SAndreas Gohr     * @throws \Exception when the model cannot be initialized
18dce0dee5SAndreas Gohr     */
19dce0dee5SAndreas Gohr    public function __construct(string $name, array $config);
20dce0dee5SAndreas Gohr
21dce0dee5SAndreas Gohr    /**
22*b446155bSAndreas Gohr     * Get the full model name as used in the configuration
23*b446155bSAndreas Gohr     */
24*b446155bSAndreas Gohr    public function __toString(): string;
25*b446155bSAndreas Gohr
26*b446155bSAndreas Gohr    /**
274373d2bfSAndreas Gohr     * The name as used by the LLM provider
284373d2bfSAndreas Gohr     *
294373d2bfSAndreas Gohr     * @return string
304373d2bfSAndreas Gohr     */
314373d2bfSAndreas Gohr    public function getModelName();
324373d2bfSAndreas Gohr
334373d2bfSAndreas Gohr    /**
344373d2bfSAndreas Gohr     * Reset the usage statistics
354373d2bfSAndreas Gohr     *
364373d2bfSAndreas Gohr     * Usually not needed when only handling one operation per request, but useful in CLI
374373d2bfSAndreas Gohr     */
384373d2bfSAndreas Gohr    public function resetUsageStats();
394373d2bfSAndreas Gohr
404373d2bfSAndreas Gohr    /**
414373d2bfSAndreas Gohr     * Get the usage statistics for this instance
424373d2bfSAndreas Gohr     *
434373d2bfSAndreas Gohr     * @return string[]
444373d2bfSAndreas Gohr     */
454373d2bfSAndreas Gohr    public function getUsageStats();
46dce0dee5SAndreas Gohr
47dce0dee5SAndreas Gohr    /**
48dce0dee5SAndreas Gohr     * Maximum number of tokens the model can handle as input.
49dce0dee5SAndreas Gohr     *
50dce0dee5SAndreas Gohr     * This is the absolute limit, including any context, prompts, questions etc.
51dce0dee5SAndreas Gohr     */
52dce0dee5SAndreas Gohr    public function getMaxInputTokenLength(): int;
53dce0dee5SAndreas Gohr
54dce0dee5SAndreas Gohr    /**
55dce0dee5SAndreas Gohr     * The price for 1,000,000 input tokens in USD
56dce0dee5SAndreas Gohr     */
57dce0dee5SAndreas Gohr    public function getInputTokenPrice(): float;
584373d2bfSAndreas Gohr}
59