Lines Matching refs:history

163      * Ask a question with a chat history
166 * @param array[] $history The chat history [[user, ai], [user, ai], ...]
170 public function askChatQuestion($question, $history = [])
172 if ($history && $this->getConf('rephraseHistory') > 0) {
173 $contextQuestion = $this->rephraseChatQuestion($question, $history);
175 // Only use the rephrased question if it has more history than the chat history provides
182 return $this->askQuestion($question, $history, $contextQuestion);
189 * @param array $history [user, ai] of the previous question
194 public function askQuestion($question, $history = [], $contextQuestion = '')
210 $history = [];
216 $history,
230 * Rephrase a question into a standalone question based on the chat history
233 * @param array[] $history The chat history [[user, ai], [user, ai], ...]
237 public function rephraseChatQuestion($question, $history)
245 $history,
256 * @param array[] $history The chat history [[user, ai], [user, ai], ...]
257 * @param int $historySize The maximum number of messages to use from the history
263 array $history,
271 // FIXME we may want to also have an upper limit for the history and not always use the full context
273 $messages = $this->historyMessages($history, $remainingContext, $historySize);
282 * Create an array of OpenAI compatible messages from the given history
286 * @param array[] $history The chat history [[user, ai], [user, ai], ...]
291 protected function historyMessages(array $history, int $tokenLimit, int $sizeLimit): array
296 $history = array_reverse($history);
297 $history = array_slice($history, 0, $sizeLimit);
298 foreach ($history as $row) {