aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/LanguageModel/FreePromptTask.php
blob: ff7fa7fffedb5ba44399def67f4ccf75013c6d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

namespace OCP\LanguageModel;

use RuntimeException;

class FreePromptTask extends AbstractLanguageModelTask {

	/**
	 * @param ILanguageModelProvider $provider
	 * @throws RuntimeException
	 * @return string
	 */
	public function visitProvider(ILanguageModelProvider $provider): string {
		$this->setStatus(self::STATUS_RUNNING);
		try {
			$output = $provider->prompt($this->getInput());
		} catch (RuntimeException $e) {
			$this->setStatus(self::STATUS_FAILED);
			throw $e;
		}
		$this->setStatus(self::STATUS_SUCCESSFUL);
		return $output;
	}
}