Errors on content generation, including image

Created on 26 April 2023, over 1 year ago
Updated 20 May 2023, over 1 year ago

Upon filling out the content generation form, including image generation, and submitting, an error results that appears to be saying that open_ai is calling a nonexistent method in the OpenAI APi Client.

This is already mentioned in a closed issue comments, https://www.drupal.org/project/openai/issues/3342260#comment-14926601 πŸ’¬ 'open_ai' config related errors Fixed , but the comment there seems different than the issue that was closed - it is this issue.

I tried to find something that looked like a deprecation or some other way to get the information, but haven't found it.

ResponseText: The website encountered an unexpected error. Please try again later.Error: Call to undefined method OpenAI\Client::getImageUrl() in Drupal\openai_api\Controller\GenerationController->getImageUrlResponseBodyData() (line 119 of modules/contrib/openai/modules/openai_api/src/Controller/GenerationController.php). Drupal\openai_api\GenerationService->generate_image(Array) (Line: 37)
Drupal\openai_api\GenerationService::generate(Array, Object, Array) (Line: 295)
_batch_process() (Line: 137)
_batch_do() (Line: 93)
_batch_page(Object) (Line: 55)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)

I changed \Drupal\openai_api\Controller\GenerationController::getImageUrlResponseBodyData and this seems to help, but there are other errors that also indicate use of deprecated methods:
public function getImageUrlResponseBodyData(
$prompt,
$size,
): string {
$imgCall = $this->client->images()->create(
['prompt' => $prompt,
'n' => 1,
'size' => $size,]
);

if ($imgCall) {
$return = $imgCall['data'][0]['url'];
}
else {
$return = '';
}

return $return;
}

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bob.hinrichs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024