xref: /plugin/aichat/Model/ChatInterface.php (revision 294a9eaf76b94a3f99dceca7f1750a7898de3dd9)
1<?php
2
3namespace dokuwiki\plugin\aichat\Model;
4
5/**
6 * Defines a chat completion model
7 */
8interface ChatInterface
9{
10    /**
11     * Maximum number of tokens to use when creating context info. Should be smaller than the absolute
12     * token limit of the model, so that prompts and questions can be added.
13     *
14     * @return int
15     */
16    public function getMaxContextTokenLength();
17
18    /**
19     * Maximum number of tokens to use as context when rephrasing a question. Should be smaller than the
20     * absolute token limit of the model, so that prompts and questions can be added.
21     *
22     * @return int
23     */
24    public function getMaxRephrasingTokenLength();
25
26    /**
27     * Maximum size of chunks to be created for this model
28     *
29     * Should be a size small enough to fit at least a few chunks into the context token limit.
30     *
31     * @return int
32     */
33    public function getMaxEmbeddingTokenLength();
34
35    /**
36     * Answer a given question.
37     *
38     * Any prompt, chat history, context etc. will already be included in the $messages array.
39     *
40     * @param array $messages Messages in OpenAI format (with role and content)
41     * @return string The answer
42     * @throws \Exception
43     */
44    public function getAnswer($messages);
45}
46