/**
* @inheritDoc
*/
- public function getAvailableTasks(): array {
+ public function getAvailableTaskClasses(): array {
$tasks = [];
foreach ($this->getProviders() as $provider) {
$tasks[FreePromptTask::class] = true;
* @inheritDoc
*/
public function getAvailableTaskTypes(): array {
- return array_map(fn ($taskClass) => $taskClass::TYPE, $this->getAvailableTasks());
+ return array_map(fn ($taskClass) => $taskClass::TYPE, $this->getAvailableTaskClasses());
}
public function canHandleTask(ILanguageModelTask $task): bool {
- return count(array_filter($this->getAvailableTasks(), fn ($class) => $task instanceof $class)) > 0;
+ return count(array_filter($this->getAvailableTaskClasses(), fn ($class) => $task instanceof $class)) > 0;
}
/**
public function testShouldNotHaveAnyProviders() {
$this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([]);
- $this->assertCount(0, $this->languageModelManager->getAvailableTasks());
+ $this->assertCount(0, $this->languageModelManager->getAvailableTaskClasses());
$this->assertCount(0, $this->languageModelManager->getAvailableTaskTypes());
$this->assertFalse($this->languageModelManager->hasProviders());
$this->expectException(PreConditionNotMetException::class);
$this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
new ServiceRegistration('test', TestVanillaLanguageModelProvider::class)
]);
- $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+ $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
$this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
$this->assertTrue($this->languageModelManager->hasProviders());
$this->assertEquals('Hello Free Prompt', $this->languageModelManager->runTask(new FreePromptTask('Hello', 'test', null)));
$this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
new ServiceRegistration('test', TestVanillaLanguageModelProvider::class)
]);
- $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+ $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
$this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
$this->assertTrue($this->languageModelManager->hasProviders());
new ServiceRegistration('test', TestVanillaLanguageModelProvider::class),
new ServiceRegistration('test', TestFullLanguageModelProvider::class),
]);
- $this->assertCount(3, $this->languageModelManager->getAvailableTasks());
+ $this->assertCount(3, $this->languageModelManager->getAvailableTaskClasses());
$this->assertCount(3, $this->languageModelManager->getAvailableTaskTypes());
$this->assertTrue($this->languageModelManager->hasProviders());
$this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
new ServiceRegistration('test', TestFailingLanguageModelProvider::class),
]);
- $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+ $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
$this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
$this->assertTrue($this->languageModelManager->hasProviders());
$this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
new ServiceRegistration('test', TestVanillaLanguageModelProvider::class)
]);
- $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+ $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
$this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
$this->assertTrue($this->languageModelManager->hasProviders());
$task = new FreePromptTask('Hello', 'test', null);