GetChatSessionUseCase.php
- Pfad:
src/UseCases/Chat/GetChatSessionUseCase.php - Namespace: UseCases\Chat
- Zeilen: 120 | Größe: 3,427 Bytes
- Geändert: 2025-12-25 17:31:28 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 94
- Dependencies: 90 (25%)
- LOC: 100 (20%)
- Methods: 80 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 11
- implements UseCases\Chat\GetChatSessionUseCaseInterface
- constructor Domain\Repository\ChatSessionRepositoryInterface
- constructor Domain\Repository\ChatMessageRepositoryInterface
- constructor Domain\Repository\ContentConfigRepositoryInterface
- constructor Domain\Repository\CollectionRepositoryInterface
- use Domain\Entity\ChatMessage
- use Domain\Entity\ChatSession
- use Domain\Repository\ChatMessageRepositoryInterface
- use Domain\Repository\ChatSessionRepositoryInterface
- use Domain\Repository\CollectionRepositoryInterface
- use Domain\Repository\ContentConfigRepositoryInterface
Klassen 1
-
GetChatSessionUseCaseclass Zeile 16
Funktionen 12
-
__construct()public Zeile 20 -
getSession()public Zeile 28 -
getAllSessions()public Zeile 36 -
getAllSessionsWithStats()public Zeile 44 -
getMessages()public Zeile 52 -
getAuthorProfiles()public Zeile 57 -
getSystemPrompts()public Zeile 62 -
getOutputStructures()public Zeile 67 -
getStructure()public Zeile 72 -
getAvailableCollections()public Zeile 77 -
getSystemPromptById()public Zeile 92 -
getDefaultSystemPrompt()public Zeile 107
Verwendet von 1
Versionen 1
-
v1
2025-12-25 17:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace UseCases\Chat;
// @responsibility: Retrieves chat session data
use Domain\Entity\ChatMessage;
use Domain\Entity\ChatSession;
use Domain\Repository\ChatMessageRepositoryInterface;
use Domain\Repository\ChatSessionRepositoryInterface;
use Domain\Repository\CollectionRepositoryInterface;
use Domain\Repository\ContentConfigRepositoryInterface;
final class GetChatSessionUseCase implements GetChatSessionUseCaseInterface
{
private ?array $collectionsCache = null;
public function __construct(
private ChatSessionRepositoryInterface $sessionRepo,
private ChatMessageRepositoryInterface $messageRepo,
private ContentConfigRepositoryInterface $configRepo,
private CollectionRepositoryInterface $collectionRepo
) {
}
public function getSession(string $uuid): ?ChatSession
{
return $this->sessionRepo->findByUuid($uuid);
}
/**
* @return array<int, ChatSession>
*/
public function getAllSessions(int $limit = 50): array
{
return $this->sessionRepo->findAll($limit);
}
/**
* @return array<int, array<string, mixed>>
*/
public function getAllSessionsWithStats(int $limit = 50): array
{
return $this->sessionRepo->findAllWithStats($limit);
}
/**
* @return array<int, ChatMessage>
*/
public function getMessages(int $sessionId): array
{
return $this->messageRepo->findBySessionId($sessionId);
}
public function getAuthorProfiles(): array
{
return $this->configRepo->getAuthorProfiles();
}
public function getSystemPrompts(): array
{
return $this->configRepo->getSystemPrompts();
}
public function getOutputStructures(): array
{
return $this->configRepo->getStructures();
}
public function getStructure(int $id): ?array
{
return $this->configRepo->getStructure($id);
}
public function getAvailableCollections(): array
{
if ($this->collectionsCache === null) {
$this->collectionsCache = $this->collectionRepo->getSearchable();
if ($this->collectionsCache === []) {
$this->collectionsCache = [
['collection_id' => 'documents', 'display_name' => 'Dokumente', 'points_count' => 0, 'vector_size' => 1024],
];
}
}
return $this->collectionsCache;
}
public function getSystemPromptById(?int $id): string
{
if ($id === null) {
return $this->getDefaultSystemPrompt();
}
$prompts = $this->getSystemPrompts();
foreach ($prompts as $prompt) {
if (($prompt['id'] ?? null) === $id) {
return $prompt['content'] ?? $this->getDefaultSystemPrompt();
}
}
return $this->getDefaultSystemPrompt();
}
public function getDefaultSystemPrompt(): string
{
return <<<'PROMPT'
Du bist ein hilfreicher Assistent für Fragen zu systemischem Teamcoaching und Teamentwicklung.
Beantworte die Frage des Nutzers basierend auf dem bereitgestellten Kontext.
- Antworte auf Deutsch
- Sei präzise und hilfreich
- Wenn der Kontext die Frage nicht beantwortet, sage das ehrlich
- Verweise auf die Quellen wenn passend
PROMPT;
}
}