From 4fbbea96bc9109ddb1086642bd77ab4efc944055 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 6 Mar 2025 00:25:10 +1100 Subject: [PATCH] [9.0] fix: Product Documentation function not available error (#212676) (#213230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `9.0`: - [fix: Product Documentation function not available error (#212676)](https://github.com/elastic/kibana/pull/212676) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Arturo Lidueña --- .../server/functions/documentation.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/functions/documentation.ts b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/functions/documentation.ts index 2360784a22674..cf407a9c9832c 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/functions/documentation.ts +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/functions/documentation.ts @@ -18,13 +18,15 @@ export async function registerDocumentationFunction({ }: FunctionRegistrationParameters) { const isProductDocAvailable = (await llmTasks.retrieveDocumentationAvailable()) ?? false; - functions.registerInstruction(({ availableFunctionNames }) => { - return availableFunctionNames.includes(RETRIEVE_DOCUMENTATION_NAME) - ? `When asked questions about the Elastic stack or products, You should use the ${RETRIEVE_DOCUMENTATION_NAME} function before answering, + if (isProductDocAvailable) { + functions.registerInstruction(({ availableFunctionNames }) => { + return availableFunctionNames.includes(RETRIEVE_DOCUMENTATION_NAME) + ? `When asked questions about the Elastic stack or products, You should use the ${RETRIEVE_DOCUMENTATION_NAME} function before answering, to retrieve documentation related to the question. Consider that the documentation returned by the function is always more up to date and accurate than any own internal knowledge you might have.` - : undefined; - }); + : undefined; + }); + } functions.registerFunction( {