fix: Product Documentation function not available error (#212676)

## Summary
Closes [#212655](https://github.com/elastic/kibana/issues/212655)
FIX:
When a user asks a question about the Elastic stack, we expect the LLM
to request the `retrieve_elastic_doc` function. However, due to the
limit of number of functions we can register, it errors out because the
function is not available.


![Image](https://github.com/user-attachments/assets/585ee05d-f10b-4a03-b40b-a07b2148d11b)
This commit is contained in:
Arturo Lidueña 2025-03-05 12:43:16 +01:00 committed by GitHub
parent 85555042be
commit cb4e2023b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(
{