mirror of
https://github.com/crowetic/nc-talk-ai.git
synced 2026-09-07 07:32:31 +00:00
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.
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\EducAI\Tests\Unit\Service;
|
|
|
|
use OCA\EducAI\Service\ToolResultFallbackService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ToolResultFallbackServiceTest extends TestCase {
|
|
public function testDocumentToolTraceProducesDocumentFallback(): void {
|
|
$service = new ToolResultFallbackService();
|
|
|
|
$result = $service->generateFromTrace([
|
|
[
|
|
'tool' => 'rag_search_documents',
|
|
'status' => 'ok',
|
|
'response' => "Found 1 relevant document chunk(s)\n\nSource 1\n\nContent",
|
|
],
|
|
]);
|
|
|
|
$this->assertStringStartsWith("Based on the documents found:\n\n", $result);
|
|
$this->assertStringContainsString('Source 1', $result);
|
|
}
|
|
|
|
public function testDocumentFallbackUsesFirstResultAndTruncatesAtExistingLimit(): void {
|
|
$service = new ToolResultFallbackService();
|
|
$first = 'Found first result ' . str_repeat('a', 3100);
|
|
|
|
$result = $service->generateFromTrace([
|
|
[
|
|
'tool' => 'rag_search_documents',
|
|
'status' => 'ok',
|
|
'response' => $first,
|
|
],
|
|
[
|
|
'tool' => 'room_search_documents',
|
|
'status' => 'ok',
|
|
'response' => 'Found second result',
|
|
],
|
|
]);
|
|
|
|
$this->assertStringContainsString('Found first result', $result);
|
|
$this->assertStringNotContainsString('Found second result', $result);
|
|
$this->assertStringEndsWith("... (more results available)", $result);
|
|
}
|
|
}
|