add system prompt and chunks index views and edit
This commit is contained in:
38
src/Repository/SystemPromptRepository.php
Normal file
38
src/Repository/SystemPromptRepository.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// src/Repository/SystemPromptRepository.php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\SystemPrompt;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class SystemPromptRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, SystemPrompt::class);
|
||||
}
|
||||
|
||||
public function findActive(): ?SystemPrompt
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.active = true')
|
||||
->orderBy('p.version', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function getNextVersion(): int
|
||||
{
|
||||
$max = $this->createQueryBuilder('p')
|
||||
->select('MAX(p.version)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
|
||||
return ((int)$max) + 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user