[9.0] fix: Product Documentation function not available error (#212676) (#213230)

# 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)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Arturo
Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2025-03-05T11:43:16Z","message":"fix:
Product Documentation function not available error (#212676)\n\n##
Summary\nCloses
[#212655](https://github.com/elastic/kibana/issues/212655)\nFIX:\nWhen a
user asks a question about the Elastic stack, we expect the LLM\nto
request the `retrieve_elastic_doc` function. However, due to the\nlimit
of number of functions we can register, it errors out because
the\nfunction is not
available.\n\n\n![Image](https://github.com/user-attachments/assets/585ee05d-f10b-4a03-b40b-a07b2148d11b)","sha":"cb4e2023b4a7041aa3173b4135debc96ef8fb9c8","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:prev-minor","backport:prev-major","Team:Obs
AI Assistant","ci:project-deploy-observability","v9.1.0"],"title":"fix:
Product Documentation function not available
error","number":212676,"url":"https://github.com/elastic/kibana/pull/212676","mergeCommit":{"message":"fix:
Product Documentation function not available error (#212676)\n\n##
Summary\nCloses
[#212655](https://github.com/elastic/kibana/issues/212655)\nFIX:\nWhen a
user asks a question about the Elastic stack, we expect the LLM\nto
request the `retrieve_elastic_doc` function. However, due to the\nlimit
of number of functions we can register, it errors out because
the\nfunction is not
available.\n\n\n![Image](https://github.com/user-attachments/assets/585ee05d-f10b-4a03-b40b-a07b2148d11b)","sha":"cb4e2023b4a7041aa3173b4135debc96ef8fb9c8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212676","number":212676,"mergeCommit":{"message":"fix:
Product Documentation function not available error (#212676)\n\n##
Summary\nCloses
[#212655](https://github.com/elastic/kibana/issues/212655)\nFIX:\nWhen a
user asks a question about the Elastic stack, we expect the LLM\nto
request the `retrieve_elastic_doc` function. However, due to the\nlimit
of number of functions we can register, it errors out because
the\nfunction is not
available.\n\n\n![Image](https://github.com/user-attachments/assets/585ee05d-f10b-4a03-b40b-a07b2148d11b)","sha":"cb4e2023b4a7041aa3173b4135debc96ef8fb9c8"}}]}]
BACKPORT-->

Co-authored-by: Arturo Lidueña <arturo.liduena@elastic.co>
This commit is contained in:
Kibana Machine 2025-03-06 00:25:10 +11:00 committed by GitHub
parent c6c2ceac4f
commit 4fbbea96bc
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(
{