1<?php
2
3namespace dokuwiki\plugin\aichat\RemoteResponse;
4
5use dokuwiki\plugin\aichat\RemoteResponse\Chunk as ChunkResponse;
6use dokuwiki\Remote\Response\ApiResponse;
7
8class LlmReply extends ApiResponse
9{
10    /** @var string The question as asked */
11    public $question;
12    /** @var string The answer provided by the LLM */
13    public $answer;
14    /** @var ChunkResponse[] The sources provided to the model to answer the questions */
15    public $sources = [];
16
17    public function __construct($data)
18    {
19        $this->question = $data['question'];
20        $this->answer = $data['answer'];
21
22        foreach ($data['sources'] as $source) {
23            $this->sources[] = new ChunkResponse($source);
24        }
25    }
26
27    public function __toString()
28    {
29        return $this->question;
30    }
31}
32