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