CreateChatSessionUseCase.php

Code Hygiene Score: 100

Keine Issues gefunden.

Dependencies 5

Klassen 1

Funktionen 2

Verwendet von 1

Code

<?php

declare(strict_types=1);

namespace UseCases\Chat;

// @responsibility: Creates new chat sessions with default settings

use Domain\Repository\ChatSessionRepositoryInterface;
use Domain\Service\ModelRegistryInterface;

final class CreateChatSessionUseCase implements CreateChatSessionUseCaseInterface
{
    public function __construct(
        private ChatSessionRepositoryInterface $sessionRepo,
        private ModelRegistryInterface $modelRegistry
    ) {
    }

    public function createSession(): string
    {
        $uuid = $this->sessionRepo->generateUuid();
        $defaultModel = $this->modelRegistry->getDefaultChatModel();

        $this->sessionRepo->create(
            uuid: $uuid,
            model: $defaultModel,
            collections: '["documents"]',
            contextLimit: 5
        );

        return $uuid;
    }
}
← Übersicht Graph