- Issue created by @srees
- First commit to issue fork.
- 🇬🇧United Kingdom MrDaleSmith
I suspect there is something wrong with your set up as the provider should never be null: your work around is probably not going to be something we'd want in the module unless there's a more generic bug to be addressed. Can you recreate this issue on a clean install on a D10 test site?
I don't think your change is ideal as the $response variable isn't created when there's an error, which may cause other errors.
- 🇺🇸United States srees
I concur that this does not address whatever the root of the problem is, only a symptom.
I added these changes to my local ddev instance and it now passes that point in the code and errors at another, as suggested by mrdalesmith in #7:
Warning: Undefined variable $response
...
Error: Call to a member function getText() on null in Drupal\ai_content_suggestions\AiContentSuggestionsPluginBase->sendChat() (line 320 of /var/www/html/web/modules/contrib/ai/modules/ai_content_suggestions/src/AiContentSuggestionsPluginBase.php)
#0 /var/www/html/web/modules/contrib/ai/modules/ai_content_suggestions/src/Plugin/AiContentSuggestions/Summarise.php(104): Drupal\ai_content_suggestions\AiContentSuggestionsPluginBase->sendChat('Create a detail...')
#1 /var/www/html/web/modules/contrib/ai/modules/ai_content_suggestions/src/AiContentSuggestionsFormAlter.php(64): Drupal\ai_content_suggestions\Plugin\AiContentSuggestions\Summarise->updateFormWithResponse(Array, Object(Drupal\Core\Form\FormState))
#2 [internal function]: Drupal\ai_content_suggestions\AiContentSuggestionsFormAlter::getPluginResponse(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
#3 /var/www/html/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
#4 /var/www/html/web/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(112): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
#5 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#6 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#7 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(239): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')
#8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)
#9 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#22 {main}I'm lost as to why provider is null.
- 🇺🇸United States srees
It seems tied to line 283:
$provider = $this->providerPluginManager->loadProviderFromSimpleOption($preferred_model);If I change this line:
301: $provider_config = $this->getSetProvider($this->operationType(), $this->config->get('plugins')[$this->getPluginId()]);to:
$provider_config = $this->getSetProvider($this->operationType(), null);Then everything functions using the default model for chat.
- 🇺🇸United States srees
Didn't realize Drupal is moving to forks instead of patches. Already did this one and have to run to a meeting.
I consider this a functional workaround, but does not solve the root issue of the preferred provider not working.
- 🇺🇸United States srees
I've determined that the problem is actually with the Azure provider, which is incorrectly evaluating the isUsable() function.
No need to apply this patch, I'll open a ticket in that project. Please close this one.