Skip to content

Commit

Permalink
TASK: Only offer assistants in data source that are from the current …
Browse files Browse the repository at this point in the history
…organization
  • Loading branch information
mficzel committed Feb 13, 2024
1 parent 8eb8010 commit af40249
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Classes/DataSources/AssistantIdDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
);
}
}

0 comments on commit af40249

Please sign in to comment.