1<?php
2
3namespace dokuwiki\plugin\aichat\RemoteResponse;
4
5use dokuwiki\plugin\aichat\Chunk as BaseChunk;
6use dokuwiki\Remote\Response\ApiResponse;
7
8class Chunk extends ApiResponse
9{
10    /** @var string The page id of the source */
11    public $page;
12    /** @var string The title of the source page */
13    public $title;
14    /** @var string The chunk id of the source (pages are split into chunks) */
15    public $id;
16    /** @var float The similarity score of this source to the query (between 0 and 1) */
17    public $score;
18    /** @var string The language of the source */
19    public $lang;
20
21    public function __construct(BaseChunk $originalChunk)
22    {
23        $this->page = $originalChunk->getPage();
24        $this->id = $originalChunk->getId();
25        $this->score = $originalChunk->getScore();
26        $this->lang = $originalChunk->getLanguage();
27        $this->title = p_get_first_heading($this->page);
28    }
29
30    public function __toString()
31    {
32        return $this->page . '--' . $this->id;
33    }
34}
35