xref: /plugin/aichat/Model/ChatInterface.php (revision 34a1c47875552330ce367360d99f2c3f9f69af94)
1294a9eafSAndreas Gohr<?php
2294a9eafSAndreas Gohr
3294a9eafSAndreas Gohrnamespace dokuwiki\plugin\aichat\Model;
4294a9eafSAndreas Gohr
5294a9eafSAndreas Gohr/**
6294a9eafSAndreas Gohr * Defines a chat completion model
7294a9eafSAndreas Gohr */
84373d2bfSAndreas Gohrinterface ChatInterface extends ModelInterface
9294a9eafSAndreas Gohr{
10294a9eafSAndreas Gohr    /**
11*34a1c478SAndreas Gohr     * Maximum number of tokens the model can output as an answer
12294a9eafSAndreas Gohr     */
13*34a1c478SAndreas Gohr    public function getMaxOutputTokenLength(): int;
14294a9eafSAndreas Gohr
15294a9eafSAndreas Gohr    /**
16*34a1c478SAndreas Gohr     * The price for 1,000,000 output tokens in USD
17294a9eafSAndreas Gohr     */
18*34a1c478SAndreas Gohr    public function getOutputTokenPrice(): float;
19294a9eafSAndreas Gohr
20294a9eafSAndreas Gohr    /**
21294a9eafSAndreas Gohr     * Answer a given question.
22294a9eafSAndreas Gohr     *
23294a9eafSAndreas Gohr     * Any prompt, chat history, context etc. will already be included in the $messages array.
24294a9eafSAndreas Gohr     *
25294a9eafSAndreas Gohr     * @param array $messages Messages in OpenAI format (with role and content)
26294a9eafSAndreas Gohr     * @return string The answer
27294a9eafSAndreas Gohr     * @throws \Exception
28294a9eafSAndreas Gohr     */
29*34a1c478SAndreas Gohr    public function getAnswer($messages): string;
30294a9eafSAndreas Gohr}
31