aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/LanguageModel/HeadlineTask.php
blob: 1f3680b31166112445ed7ef7962bbcb66ff8922b (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

namespace OCP\LanguageModel;

/**
 * This LanguageModel Task represents headline generation
 * which generates a headline for the passed text
 * @since 28.0.0
 * @template-extends AbstractLanguageModelTask<IHeadlineProvider>
 */
final class HeadlineTask extends AbstractLanguageModelTask {
	/**
	 * @since 28.0.0
	 */
	public const TYPE = 'headline';

	/**
	 * @inheritDoc
	 * @since 28.0.0
	 */
	public function visitProvider($provider): string {
		if (!$this->canUseProvider($provider)) {
			throw new \RuntimeException('HeadlineTask#visitProvider expects IHeadlineProvider');
		}
		return $provider->findHeadline($this->getInput());
	}

	/**
	 * @inheritDoc
	 * @since 28.0.0
	 */
	public function canUseProvider($provider): bool {
		return $provider instanceof IHeadlineProvider;
	}

	/**
	 * @inheritDoc
	 * @since 28.0.0
	 */
	public function getType(): string {
		return self::TYPE;
	}
}