Problem/Motivation
I've been testing some ECA models using the openai_eca sub-module and, every time I use the OpenAI/ChatGPT Chat template for my model, I see lots of PHP errors like the following in the logs:
Error: Call to a member function getTokenData() on null in Drupal\openai_eca\Plugin\Action\Chat->execute() (line 102 of /var/www/html/web/modules/contrib/openai/modules/openai_eca/src/Plugin/Action/Chat.php)
These errors are accompanied by the following PHP warning:
Warning: Undefined property: Drupal\openai_eca\Plugin\Action\Chat::$tokenServices in Drupal\openai_eca\Plugin\Action\Chat->execute() (line 102 of /var/www/html/web/modules/contrib/openai/modules/openai_eca/src/Plugin/Action/Chat.php)
I've found that the $tokenServices property used in openai_eca module's Action Plugins doesn't exist, whereas $tokenService can be found in the base class \Drupal\eca\Plugin\Action\ActionBase all these plugins extend from.
Steps to reproduce
Enable the openai_eca sub-module and add an ECA flow with any chatGPT action from the list:
- OpenAI/ChatGPT Chat
- OpenAI/ChatGPT Completion
- OpenAI/ChatGPT Embedding
- OpenAI/ChatGPT Moderation
- OpenAI/ChatGPT Speech to Text
- OpenAI/ChatGPT Text to Speech
When the ECA model runs and the chatGPT action is triggered, the errors mentioned above occur.
Proposed resolution
Replacing tokenServices with tokenService seems to resolve the issue.
Issue fork openai-3450380
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
ioanmar commentedComment #4
mmlmitchell commentedI am also getting the same PHP errors using the OpenAI ECA sub-module (v1.0.0-beta6). Using the "proposed resolution" above (i.e., replace tokenServices with tokenService), I was able to resolve the errors and make use of the sub-module.
Comment #5
thejimbirch commentedI was getting a WSOD on a node save that used an ECA. The MR fixes and allows for the ECA to fire. Marking as RTBC.