Skip to content

Commit ab82a03

Browse files
committed
Adds a filter to allow modifying the prompt programmatically
1 parent 9f21cd7 commit ab82a03

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

includes/classes/Feature/RAG.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,24 @@ public function get_ai_response( $search_term, $search_vectors = null ) {
279279
];
280280
}
281281

282-
$prompt = $this->get_prompt( $posts_representations );
282+
/**
283+
* Filters the AI prompt before it goes to the request.
284+
*
285+
* This filter allows developers to short-circuit the AI prompt set in the plugin settings.
286+
* Use this if you want to conditionally manipulate the prompt or implement more sophisticated logic.
287+
*
288+
* @param {string} $prompt The prompt as set in the plugin settings.
289+
* @param {array} $posts_representations The posts to be used as context.
290+
*
291+
* @return {string} TRhe prompt for the AI model.
292+
* @since 2.5.0
293+
* @hook ep_rag_prompt
294+
*/
295+
$prompt = apply_filters(
296+
'ep_rag_prompt',
297+
$this->get_prompt( $posts_representations ),
298+
$posts_representations
299+
);
283300
$response = $this->ai_api_request( $prompt, $search_term );
284301

285302
/**

0 commit comments

Comments
 (0)