Allow hooks(like) functionality e.g. "hook_prompt_alter"

Created on 10 June 2024, 7 months ago
Updated 4 July 2024, 6 months ago

Problem/Motivation

I want to override/change
1. the predefined tones of voice (could be with a form alter, but a openai_alter would be nice too).
2. the prompts used in some of these features.
Example of this: openai_content_entity_suggest_taxonomy lets openai randomy generate terms.
If I have a existing tree, I want openai to suggest from my existing tags, to reduce the risk of duplicates.
I dont want to remake these features, I just want to plug into this module.

Proposed resolution

Allow hooking like funcionality
Just before passing the text into the ajaxcommand.

\Drupal::moduleHandler()->invokeAll('openai_alter_tov_options', [&$tov_options]);
// hook openai_alter_tov_options for altering the provided options for tone of voice

\Drupal::moduleHandler()->invokeAll('openai_prompt_alter_tone', [&$tone_instruction]);
// hook openai_prompt_alter_tone for changing the tone of voice prompt.

\Drupal::moduleHandler()->invokeAll('openai_prompt_alter_summary', [&$summary_instruction]);
// hook openai_prompt_alter_summary for changing the summary sugggestion prompt.

\Drupal::moduleHandler()->invokeAll('openai_prompt_alter_title', [&$title_instruction]);
// hook openai_prompt_alter_title for changing the title suggestion prompt.

\Drupal::moduleHandler()->invokeAll('openai_prompt_alter_terms', [&$terms_instruction]);
// hook openai_prompt_alter_terms for changing the terms suggestion prompt.

so that
-> tones of voices can be fetched from multiple modules
-> prompts can be appended or changed by modules.

User interface changes

No user interface changes required.

API changes

It would add the possibility to extend the module a bit.

Data model changes

No data model changes needed for this change.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇧🇪Belgium wouters_f Leuven

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024