Backup #1493

ID1493
Dateipfad/var/www/dev.campus.systemische-tools.de/src/UseCases/Chat/GetChatSessionUseCase.php
Version1
Typ modified
Größe2.9 KB
Hash21fc1fc7a211879f2f4f4b9340e3196b5433f892f3dff702020bb7a79221dfb5
Datum2025-12-25 17:31:28
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?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 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;
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

← Zurück zur Übersicht