add system prompt and chunks index views and edit

This commit is contained in:
team2
2026-02-15 21:33:31 +01:00
parent 59e48242b5
commit 3416678cf4
12 changed files with 743 additions and 7 deletions

View File

@@ -5,14 +5,14 @@ declare(strict_types=1);
namespace App\Agent;
use App\Context\ContextService;
use App\Context\UrlAnalyzer;
use App\Repository\SystemPromptRepository;
use DateTimeImmutable;
final class PromptBuilder
final readonly class PromptBuilder
{
public function __construct(
private readonly ContextService $contextService,
private readonly UrlAnalyzer $urlAnalyzer,
private ContextService $contextService,
private SystemPromptRepository $systemPromptRepository,
)
{
}
@@ -25,6 +25,7 @@ final class PromptBuilder
* @param string $urlContent
* @param string[] $knowledgeChunks
* @param bool $fullContext
* @return string
*/
public function build(
string $prompt,
@@ -39,7 +40,8 @@ final class PromptBuilder
// ------------------------------------------------------------
// 1) SYSTEM INSTRUCTIONS
// ------------------------------------------------------------
$systemLines = [
//ToDO: remove old systemLines
/*$systemLines = [
'You are a conversational AI assistant.',
'Respond clearly, precisely, and in context of the ongoing conversation.',
'The conversation context is authoritative and must be respected.',
@@ -66,7 +68,15 @@ final class PromptBuilder
'- Answer directly and confidently using always correct canonical terminology.'
];
$systemBlock = "SYSTEM:\n" . implode("\n", $systemLines);
$systemBlock = "SYSTEM:\n" . implode("\n", $systemLines);*/
$activePrompt = $this->systemPromptRepository->findActive();
if (!$activePrompt) {
throw new \RuntimeException('No active system prompt configured.');
}
$systemBlock = "SYSTEM:\n" . $activePrompt->getContent();
// ------------------------------------------------------------
// 2) CONVERSATION CONTEXT (AUTHORITATIVE)