Skip to content

Commit

Permalink
Merge pull request #17 from yalesites-org/YSP-756-fix-null-request
Browse files Browse the repository at this point in the history
YSP-756: Fix bad request NULL error
  • Loading branch information
dblanken-yale authored Nov 26, 2024
2 parents 73e81b1 + 64f13d0 commit c09f3c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions modules/ai_engine_embedding/src/Service/EntityUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,22 @@ public function delete(EntityInterface $entity) {
* a cleanup routine to find and delete out of date chunks.
*/
public function addAllDocuments() {
$docTypes = ['node' => 'text', 'media' => 'media'];
$docType = "text";
$config = $this->configFactory->get('ai_engine_embedding.settings');

// Loop through entityTypesToSend and send.
foreach (self::ALLOWED_ENTITIES as $entityType) {
$data = $this->getData("upsert", $config, ['entityType' => $entityType], "", $docTypes[$entityType]);
$data = $this->getData("upsert", $config, ['entityType' => $entityType], "", $docType);
$endpoint = $config->get('azure_embedding_service_url') . '/api/upsert';
$response = $this->sendJsonPost($endpoint, $data);

if (!$response) {
$this->logger->notice(
'Unable to upsert to vector database. Response not successful. Check the Azure embedding service URL.',
);
return NULL;
}

if ($response->getStatusCode() === 200) {
$responseData = json_decode($response->getBody()->getContents(), TRUE);
$this->logger->notice(
Expand Down Expand Up @@ -241,7 +248,7 @@ public function upsertDocument(EntityInterface $entity) {

if ($response === NULL) {
$this->logger->notice(
'Unable to upsert node @id to vector database. Response not successful',
'Unable to upsert node @id to vector database. Response not successful. Check the Azure embedding service URL.',
['@id' => $entity->id()]
);
return NULL;
Expand Down Expand Up @@ -422,6 +429,8 @@ public function isIndexingEnabled(EntityInterface $entity) {
* An array of route parameters.
* @param string $data
* The data to send to the AI Embedding service.
* @param string $doctype
* The type of document being sent to the AI Embedding service.
*
* @return array
* An array of data to send to the AI Embedding service.
Expand Down

0 comments on commit c09f3c5

Please sign in to comment.