From af40249abf7ec998e8c6c23f2e859f5d148aab0b Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Tue, 13 Feb 2024 10:10:21 +0100 Subject: [PATCH] TASK: Only offer assistants in data source that are from the current organization --- Classes/DataSources/AssistantIdDataSource.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Classes/DataSources/AssistantIdDataSource.php b/Classes/DataSources/AssistantIdDataSource.php index fa6fa8f..024befc 100644 --- a/Classes/DataSources/AssistantIdDataSource.php +++ b/Classes/DataSources/AssistantIdDataSource.php @@ -8,6 +8,7 @@ use Neos\ContentRepository\Domain\Model\NodeInterface; use Neos\Neos\Service\DataSource\AbstractDataSource; use OpenAI\Responses\Assistants\AssistantResponse; +use Sitegeist\Chatterbox\Domain\AssistantRecord; use Sitegeist\Chatterbox\Domain\OrganizationRepository; class AssistantIdDataSource extends AbstractDataSource @@ -32,8 +33,11 @@ public function getData(NodeInterface $node = null, array $arguments = []) } $organization = $this->organizationRepository->findById($organizationId); + $assistants = $organization->assistantDepartment->findAllRecords(); - $list = $organization->client->assistants()->list(['limit' => 100]); - return array_map(fn(AssistantResponse $item) => ['value' => $item->id, 'label' => $item->name], $list->data); + return array_map( + fn(AssistantRecord $item) => ['value' => $item->id, 'label' => $item->name], + iterator_to_array($assistants->getIterator()) + ); } }