Skip to content

Commit

Permalink
[9.0] fix: Product Documentation function not available error (#212676)…
Browse files Browse the repository at this point in the history
… (#213230)

# Backport

This will backport the following commits from `main` to `9.0`:
- [fix: Product Documentation function not available error
(#212676)](#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>
  • Loading branch information
kibanamachine and arturoliduena authored Mar 5, 2025
1 parent c6c2cea commit 4fbbea9
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 4fbbea9

Please sign in to comment.