Files
nc-talk-ai/tests/unit/Service/ToolIntentServiceTest.php
Pascal Kienast 0739d3da6a Initial open-source release of Talk AI
Talk AI is a multi-bot AI assistant manager for Nextcloud Talk:
per-bot prompts and models, agentic tool calling (MCP + built-in
tools), RAG over Nextcloud files, room-document search, vision and
speech-to-text attachments, persistent bot wikis, approval workflows,
rate limiting, and multi-provider LLM support (any OpenAI-compatible
endpoint).

Developed within EDUC - the European Digital UniverCity
(https://educalliance.eu), where it runs as the 'EDUC AI' assistant on
the alliance-wide Nextcloud portal. This public repository is the
upstream point of truth; deployment-specific tools plug in via the
tool-provider extension point (docs/TOOL_PROVIDERS.md).

License: AGPL-3.0-or-later.
2026-07-08 21:13:13 +02:00

56 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\EducAI\Tests\Unit\Service;
use OCA\EducAI\Db\Bot;
use OCA\EducAI\Db\Tool;
use OCA\EducAI\Service\ToolIntentService;
use PHPUnit\Framework\TestCase;
class ToolIntentServiceTest extends TestCase {
public function testExistingForceToolKeywordsStillForceToolUse(): void {
$service = new ToolIntentService();
$bot = $this->bot('@assistant');
$this->assertTrue($service->shouldForceToolCall($bot, 'Bitte nutze das tool', null, []));
$this->assertTrue($service->shouldForceToolCall($bot, 'Bitte suche im internet', null, []));
}
public function testSearchMentionAddsGenericSearchKeywords(): void {
$service = new ToolIntentService();
$this->assertTrue($service->shouldForceToolCall($this->bot('@webbot'), 'Was ist der Stand?', null, []));
$this->assertFalse($service->shouldForceToolCall($this->bot('@assistant'), 'Was ist der Stand?', null, []));
}
public function testSearchToolDescriptionAddsGenericSearchKeywords(): void {
$service = new ToolIntentService();
$tool = new Tool();
$tool->setName('Knowledge helper');
$tool->setDescription('Performs internet search for a query');
$this->assertTrue($service->shouldForceToolCall($this->bot('@assistant'), 'heute bitte', null, [
['tool' => $tool, 'config' => []],
]));
}
public function testWikiWritePromptDoesNotChangeCurrentForceToolBehavior(): void {
$service = new ToolIntentService();
$this->assertFalse($service->shouldForceToolCall(
$this->bot('@assistant'),
'Please write this into the wiki.',
null,
[]
));
}
private function bot(string $mention): Bot {
$bot = new Bot();
$bot->setMentionName($mention);
return $bot;
}
}