Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
23c1a47
Gemini prompts
viduni94 Jun 11, 2025
3e159ba
Add new prompt with conditions
viduni94 Jun 16, 2025
8679aa6
Update prompt based on deployment
viduni94 Jun 16, 2025
f5aae43
Remove unnecessary new line
viduni94 Jun 16, 2025
6c6ea27
Alerts function
viduni94 Jun 16, 2025
9569a46
Elasticsearch function prompt tweaks
viduni94 Jun 16, 2025
07904a1
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jun 19, 2025
42d77c4
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jun 24, 2025
f81358f
Improve system prompt for generating ES|QL
SrdjanLL Jun 25, 2025
4015d54
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jun 25, 2025
38f247f
Merge branch 'main' into improve-prompts-for-gemini-models
SrdjanLL Jun 26, 2025
59b9f68
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jun 27, 2025
18f3c1e
Prompt tunning for APM scenarios
SrdjanLL Jun 27, 2025
d5c2906
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jun 30, 2025
ebe6a7f
Re-factor system prompt
viduni94 Jun 30, 2025
5dcbe60
Set "context" tool as non-internal in order to fix knowledge base ret…
SrdjanLL Jul 1, 2025
eac2764
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 2, 2025
5de47ff
Additional system prompt changes
SrdjanLL Jul 2, 2025
8b614a4
Make context tool internal again and use its function name from "comm…
SrdjanLL Jul 2, 2025
4b9ebd7
A few more refactors
viduni94 Jul 2, 2025
21e641d
Remove *query tools from the system prompt
SrdjanLL Jul 2, 2025
e8d73af
Improve KB retrieval
viduni94 Jul 2, 2025
55735ff
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 2, 2025
72d032f
Update tool name
viduni94 Jul 2, 2025
266979f
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 4, 2025
e7dd784
Add instructions to the NL-ES|QL system prompt specific to the query …
SrdjanLL Jul 4, 2025
02ca4a4
Move documentation tool instruction to the system prompt to fix instr…
viduni94 Jul 4, 2025
a2d9067
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 7, 2025
6000089
Update prompt for get_apm_downstream_dependancies to not enforce time…
viduni94 Jul 7, 2025
5eec8e1
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 8, 2025
a1db93c
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 8, 2025
66f77d1
Fix import
viduni94 Jul 8, 2025
9f8b85c
Fix import
viduni94 Jul 8, 2025
fa05b5f
Fix import
viduni94 Jul 8, 2025
41775e0
Fix import
viduni94 Jul 8, 2025
8dfe250
Fix import
viduni94 Jul 9, 2025
8a257af
System message updates for the NL-ESQL task
SrdjanLL Jul 9, 2025
ce7f83e
Append and emphasize available tools to the additional system instruc…
SrdjanLL Jul 9, 2025
83b918c
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 10, 2025
bcc053b
Fix import
viduni94 Jul 10, 2025
d828edf
Update tests
viduni94 Jul 10, 2025
fba0980
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 12, 2025
a6574e3
Fix import
viduni94 Jul 12, 2025
77abce8
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 14, 2025
050b37b
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 14, 2025
167bc1b
Dial down the eagerness for query execution in example scenarios
SrdjanLL Jul 11, 2025
be1138c
Refactor system prompt to reorder function usage guideliness for gett…
SrdjanLL Jul 16, 2025
18f91f1
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 16, 2025
f1f1b91
System prompt updates: remove hardcoded numbered list of core princip…
SrdjanLL Jul 17, 2025
065eba5
Fix index patern for trace duration ES|QL evaluation scenario as disc…
SrdjanLL Jul 17, 2025
4ed3281
Update system prompt with clearer query requirements. Update tool des…
SrdjanLL Jul 17, 2025
bcb9f3a
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 18, 2025
82eda46
Fix search prompt to inlcude tool instructions
viduni94 Jul 18, 2025
952ef2d
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 21, 2025
7dda9c7
Use tags in the system prompt instead of markdown section titles
viduni94 Jul 21, 2025
f4e7497
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 22, 2025
1f46084
Fix test
viduni94 Jul 22, 2025
2710076
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 22, 2025
cca3105
Improve documentation scenario criteria
viduni94 Jul 23, 2025
f996a7a
Change APM scenario back to success rate
viduni94 Jul 23, 2025
70dbd9e
Update formatting of the system prompt
viduni94 Jul 23, 2025
a3892d0
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 23, 2025
749f315
Tweak the system promot for better discoverability of the index name
viduni94 Jul 23, 2025
85d24e2
Update ES|QL instructions
viduni94 Jul 24, 2025
930ba2e
Improve instructions for time range handling and alerts
viduni94 Jul 24, 2025
4ebc616
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 24, 2025
179e8a1
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 25, 2025
d46b55a
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 28, 2025
a71c1d9
Improve instructions for the ES tool to disallow some actions
viduni94 Jul 28, 2025
b682dfb
Add snapshot tests
viduni94 Jul 28, 2025
2366166
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 30, 2025
0122059
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Jul 31, 2025
218351e
Fix i18n
viduni94 Jul 31, 2025
d008e38
Fix typo
viduni94 Jul 31, 2025
8437ff6
Update snapshots
viduni94 Jul 31, 2025
c918222
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Aug 4, 2025
daaa0f1
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Aug 6, 2025
a03ef08
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Aug 6, 2025
5e2f90d
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Aug 7, 2025
57a44b2
Small prompt tweak for time range handling
viduni94 Aug 8, 2025
61c0732
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Aug 8, 2025
1db394b
Update prompt snapshots
viduni94 Aug 8, 2025
8edf472
Merge branch 'main' into improve-prompts-for-gemini-models
viduni94 Aug 11, 2025
13bc13f
Fix merge conflict
viduni94 Aug 11, 2025
51e38ff
Remove extra ES tool instruction from merging main
viduni94 Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

import { Message } from '@kbn/observability-ai-assistant-plugin/common';
import { CONTEXT_FUNCTION_NAME } from '@kbn/observability-ai-assistant-plugin/server/functions/context/context';
import { CONTEXT_FUNCTION_NAME, Message } from '@kbn/observability-ai-assistant-plugin/common';
import { reverseToLastUserMessage } from './chat_body';

describe('<ChatBody>', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { ChatState, Message, MessageRole } from '@kbn/observability-ai-assistant-plugin/public';
import { createMockChatService } from './create_mock_chat_service';
import { KibanaContextProvider } from '@kbn/triggers-actions-ui-plugin/public/common/lib/kibana';
import { CONTEXT_FUNCTION_NAME } from '@kbn/observability-ai-assistant-plugin/server/functions/context/context';
import { CONTEXT_FUNCTION_NAME } from '@kbn/observability-ai-assistant-plugin/common';

const mockChatService = createMockChatService();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// Context tools
export const CONTEXT_FUNCTION_NAME = 'context';
export const GET_DATA_ON_SCREEN_FUNCTION_NAME = 'get_data_on_screen';

// Alerts tools
export const GET_ALERTS_DATASET_INFO_FUNCTION_NAME = 'get_alerts_dataset_info';
export const ALERTS_FUNCTION_NAME = 'alerts';

// Query tools
export const QUERY_FUNCTION_NAME = 'query';
export const EXECUTE_QUERY_FUNCTION_NAME = 'execute_query';
export const VISUALIZE_QUERY_FUNCTION_NAME = 'visualize_query';

// Dataset tools
export const GET_DATASET_INFO_FUNCTION_NAME = 'get_dataset_info';
export const SELECT_RELEVANT_FIELDS_NAME = 'select_relevant_fields';

export const ELASTICSEARCH_FUNCTION_NAME = 'elasticsearch';

export const EXECUTE_CONNECTOR_FUNCTION_NAME = 'execute_connector';

export const KIBANA_FUNCTION_NAME = 'kibana';

export const SUMMARIZE_FUNCTION_NAME = 'summarize';

export const CHANGES_FUNCTION_NAME = 'changes';

export const RETRIEVE_ELASTIC_DOC_FUNCTION_NAME = 'retrieve_elastic_doc';

// APM tools
export const GET_APM_DATASET_INFO_FUNCTION_NAME = 'get_apm_dataset_info';
export const GET_APM_DOWNSTREAM_DEPENDENCIES_FUNCTION_NAME = 'get_apm_downstream_dependencies';
export const GET_APM_SERVICES_LIST_FUNCTION_NAME = 'get_apm_services_list';

// Deprecated tools
export const GET_APM_TIMESERIES_FUNCTION_NAME = 'get_apm_timeseries';
export const LENS_FUNCTION_NAME = 'lens';
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,26 @@ export {
E5_LARGE_IN_EIS_INFERENCE_ID,
EIS_PRECONFIGURED_INFERENCE_IDS,
} from './preconfigured_inference_ids';

export {
GET_ALERTS_DATASET_INFO_FUNCTION_NAME,
ALERTS_FUNCTION_NAME,
QUERY_FUNCTION_NAME,
EXECUTE_QUERY_FUNCTION_NAME,
GET_DATA_ON_SCREEN_FUNCTION_NAME,
CONTEXT_FUNCTION_NAME,
ELASTICSEARCH_FUNCTION_NAME,
EXECUTE_CONNECTOR_FUNCTION_NAME,
GET_DATASET_INFO_FUNCTION_NAME,
SELECT_RELEVANT_FIELDS_NAME,
KIBANA_FUNCTION_NAME,
SUMMARIZE_FUNCTION_NAME,
VISUALIZE_QUERY_FUNCTION_NAME,
CHANGES_FUNCTION_NAME,
RETRIEVE_ELASTIC_DOC_FUNCTION_NAME,
GET_APM_DATASET_INFO_FUNCTION_NAME,
GET_APM_DOWNSTREAM_DEPENDENCIES_FUNCTION_NAME,
GET_APM_SERVICES_LIST_FUNCTION_NAME,
GET_APM_TIMESERIES_FUNCTION_NAME,
LENS_FUNCTION_NAME,
} from './function_names';
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"security",
"taskManager",
"dataViews",
"inference"
"inference",
"llmTasks"
],
"optionalPlugins": ["cloud", "serverless"],
"requiredBundles": ["kibanaReact", "kibanaUtils"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
*/

import { last } from 'lodash';
import { Message, MessageRole } from '../../../common';
import { CONTEXT_FUNCTION_NAME, Message, MessageRole } from '../../../common';
import { removeContextToolRequest } from './context';

const CONTEXT_FUNCTION_NAME = 'context';

describe('removeContextToolRequest', () => {
const baseMessages: Message[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import { encode } from 'gpt-tokenizer';
import { compact, last } from 'lodash';
import { Observable } from 'rxjs';
import { FunctionRegistrationParameters } from '..';
import { CONTEXT_FUNCTION_NAME } from '../../../common';
import { MessageAddEvent } from '../../../common/conversation_complete';
import { Message } from '../../../common/types';
import { createFunctionResponseMessage } from '../../../common/utils/create_function_response_message';
import { recallAndScore } from './utils/recall_and_score';

const MAX_TOKEN_COUNT_FOR_DATA_ON_SCREEN = 1000;

export const CONTEXT_FUNCTION_NAME = 'context';

export function registerContextFunction({
client,
functions,
Expand All @@ -39,8 +38,8 @@ export function registerContextFunction({
const screenDescription = compact(
screenContexts.map((context) => context.screenDescription)
).join('\n\n');
// any data that falls within the token limit, send it automatically

// any data that falls within the token limit, send it automatically
const dataWithinTokenLimit = compact(
screenContexts.flatMap((context) => context.data)
).filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/

import type { FunctionRegistrationParameters } from '.';

export const ELASTICSEARCH_FUNCTION_NAME = 'elasticsearch';
import { ELASTICSEARCH_FUNCTION_NAME } from '..';

export function registerElasticsearchFunction({
functions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/

import { FunctionRegistrationParameters } from '.';

export const EXECUTE_CONNECTOR_FUNCTION_NAME = 'execute_connector';
import { EXECUTE_CONNECTOR_FUNCTION_NAME } from '..';

export function registerExecuteConnectorFunction({
functions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { compact } from 'lodash';
import dedent from 'dedent';
import { ObservabilityAIAssistantScreenContextRequest } from '../../common/types';
import { ChatFunctionClient } from '../service/chat_function_client';

export const GET_DATA_ON_SCREEN_FUNCTION_NAME = 'get_data_on_screen';
import { GET_DATA_ON_SCREEN_FUNCTION_NAME, CONTEXT_FUNCTION_NAME } from '../../common';

export function registerGetDataOnScreenFunction(
functions: ChatFunctionClient,
Expand Down Expand Up @@ -49,11 +48,19 @@ export function registerGetDataOnScreenFunction(
}
);

functions.registerInstruction(({ availableFunctionNames }) =>
availableFunctionNames.includes(GET_DATA_ON_SCREEN_FUNCTION_NAME)
? `The ${GET_DATA_ON_SCREEN_FUNCTION_NAME} function will retrieve specific content from the user's screen by specifying a data key. Use this tool to provide context-aware responses. Available data: ${dedent(
functions.registerInstruction(({ availableFunctionNames }) => {
Comment thread
viduni94 marked this conversation as resolved.
if (availableFunctionNames.includes(GET_DATA_ON_SCREEN_FUNCTION_NAME)) {
return `You have access to data on the screen by calling the "${GET_DATA_ON_SCREEN_FUNCTION_NAME}" tool.
Use it to help the user understand what they are looking at.

This tool will retrieve specific content from the user's screen by specifying a data key. Use this tool to provide context-aware responses. Available data: ${dedent(
allData.map((data) => `${data.name}: ${data.description}`).join('\n')
)}`
: undefined
);
)}

A short summary of what they are looking at is available in the return of the "${CONTEXT_FUNCTION_NAME}" function.
Data that is compact enough automatically gets included in the response for the "${CONTEXT_FUNCTION_NAME}" function.`;
}

return undefined;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import type { ElasticsearchClient, SavedObjectsClientContract } from '@kbn/core/
import type { DataViewsServerPluginStart } from '@kbn/data-views-plugin/server';
import { castArray, chunk, groupBy, uniq } from 'lodash';
import { lastValueFrom } from 'rxjs';
import { MessageRole, ShortIdTable, type Message } from '../../../common';
import {
MessageRole,
ShortIdTable,
type Message,
SELECT_RELEVANT_FIELDS_NAME,
} from '../../../common';
import { concatenateChatCompletionChunks } from '../../../common/utils/concatenate_chat_completion_chunks';
import { FunctionCallChatFunction } from '../../service/types';

export const SELECT_RELEVANT_FIELDS_NAME = 'select_relevant_fields';
export const GET_RELEVANT_FIELD_NAMES_SYSTEM_MESSAGE = `You are a helpful assistant for Elastic Observability.
Your task is to determine which fields are relevant to the conversation by selecting only the field IDs from the provided list.
The list in the user message consists of JSON objects that map a human-readable field "name" to its unique "id".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
*/

import { IScopedClusterClient, Logger } from '@kbn/core/server';
import { Message } from '../../../common';
import { GET_DATASET_INFO_FUNCTION_NAME, Message } from '../../../common';
import { FunctionRegistrationParameters } from '..';
import { FunctionCallChatFunction, RespondFunctionResources } from '../../service/types';
import { getRelevantFieldNames } from './get_relevant_field_names';

export const GET_DATASET_INFO_FUNCTION_NAME = 'get_dataset_info';

export function registerGetDatasetInfoFunction({
resources,
functions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
* 2.0.
*/

import dedent from 'dedent';
import { KnowledgeBaseState } from '../../common';
import { CONTEXT_FUNCTION_NAME, registerContextFunction } from './context/context';
import { registerSummarizationFunction, SUMMARIZE_FUNCTION_NAME } from './summarize';
import { registerContextFunction } from './context/context';
import { registerSummarizationFunction } from './summarize';
import type { RegistrationCallback } from '../service/types';
import { registerElasticsearchFunction } from './elasticsearch';
import { GET_DATASET_INFO_FUNCTION_NAME, registerGetDatasetInfoFunction } from './get_dataset_info';
import { registerGetDatasetInfoFunction } from './get_dataset_info';
import { registerKibanaFunction } from './kibana';
import { registerExecuteConnectorFunction } from './execute_connector';
import { GET_DATA_ON_SCREEN_FUNCTION_NAME } from './get_data_on_screen';

// cannot be imported from x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/functions/query/index.ts due to circular dependency
export const QUERY_FUNCTION_NAME = 'query';
import { getObservabilitySystemPrompt } from '../prompts/system_prompt';

export type FunctionRegistrationParameters = Omit<
Parameters<RegistrationCallback>[0],
'registerContext' | 'hasFunction'
'registerContext' | 'hasFunction' | 'pluginsStart'
>;

export const registerFunctions: RegistrationCallback = async ({
Expand All @@ -30,6 +26,7 @@ export const registerFunctions: RegistrationCallback = async ({
resources,
signal,
scopes,
pluginsStart,
}) => {
const registrationParameters: FunctionRegistrationParameters = {
client,
Expand All @@ -44,102 +41,38 @@ export const registerFunctions: RegistrationCallback = async ({
const isObservabilityDeployment = scopes.includes('observability');
const isGenericDeployment = scopes.length === 0 || (scopes.length === 1 && scopes[0] === 'all');

if (isObservabilityDeployment || isGenericDeployment) {
functions.registerInstruction(`
${
isObservabilityDeployment
? `You are a helpful assistant for Elastic Observability. Your goal is to help the Elastic Observability users to quickly assess what is happening in their observed systems. You can help them visualise and analyze data, investigate their systems, perform root cause analysis or identify optimisation opportunities.`
: `You are a helpful assistant for Elasticsearch. Your goal is to help Elasticsearch users accomplish tasks using Kibana and Elasticsearch. You can help them construct queries, index data, search data, use Elasticsearch APIs, generate sample data, visualise and analyze data.`
}
It's very important to not assume what the user means. Ask them for clarification if needed.

If you are unsure about which function should be used and with what arguments, ask the user for clarification or confirmation.

In KQL ("kqlFilter")) escaping happens with double quotes, not single quotes. Some characters that need escaping are: ':()\\\
/\". Always put a field value in double quotes. Best: service.name:\"opbeans-go\". Wrong: service.name:opbeans-go. This is very important!

You can use Github-flavored Markdown in your responses. If a function returns an array, consider using a Markdown table to format the response.

${
isObservabilityDeployment
? 'Note that ES|QL (the Elasticsearch Query Language which is a new piped language) is the preferred query language.'
: ''
}

If you want to call a function or tool, only call it a single time per message. Wait until the function has been executed and its results
returned to you, before executing the same tool or another tool again if needed.


${
isObservabilityDeployment
? 'DO NOT UNDER ANY CIRCUMSTANCES USE ES|QL syntax (`service.name == "foo"`) with "kqlFilter" (`service.name:"foo"`).'
: ''
}

The user is able to change the language which they want you to reply in on the settings page of the AI Assistant for Observability and Search, which can be found in the ${
isServerless ? `Project settings.` : `Stack Management app under the option AI Assistants`
}.
If the user asks how to change the language, reply in the same language the user asked in.`);
}

const { kbState } = await client.getKnowledgeBaseStatus();
const isKnowledgeBaseReady = kbState === KnowledgeBaseState.READY;

functions.registerInstruction(({ availableFunctionNames }) => {
const instructions: string[] = [];

if (
availableFunctionNames.includes(QUERY_FUNCTION_NAME) &&
availableFunctionNames.includes(GET_DATASET_INFO_FUNCTION_NAME)
) {
instructions.push(`You MUST use the "${GET_DATASET_INFO_FUNCTION_NAME}" ${
functions.hasFunction('get_apm_dataset_info') ? 'or the get_apm_dataset_info' : ''
} function before calling the "${QUERY_FUNCTION_NAME}" or the "changes" functions.

If a function requires an index, you MUST use the results from the dataset info functions.`);
}
// determine if product documentation is installed
const llmTasks = pluginsStart?.llmTasks;
const isProductDocsAvailable = llmTasks ? await llmTasks.retrieveDocumentationAvailable() : false;

if (availableFunctionNames.includes(GET_DATA_ON_SCREEN_FUNCTION_NAME)) {
instructions.push(`You have access to data on the screen by calling the "${GET_DATA_ON_SCREEN_FUNCTION_NAME}" function.
Use it to help the user understand what they are looking at. A short summary of what they are looking at is available in the return of the "${CONTEXT_FUNCTION_NAME}" function.
Data that is compact enough automatically gets included in the response for the "${CONTEXT_FUNCTION_NAME}" function.`);
}

if (isKnowledgeBaseReady) {
if (availableFunctionNames.includes(SUMMARIZE_FUNCTION_NAME)) {
instructions.push(`You can use the "${SUMMARIZE_FUNCTION_NAME}" function to store new information you have learned in a knowledge database.
If the user asks to remember or store some information, always use this function.
All summaries MUST be created in English, even if the conversation was carried out in a different language.`);
}

if (availableFunctionNames.includes(CONTEXT_FUNCTION_NAME)) {
instructions.push(
`You can use the "${CONTEXT_FUNCTION_NAME}" function to retrieve relevant information from the knowledge database. The response will include a "learnings" field containing information
from the knowledge base that is most relevant to the user's current query. You should incorporate these learnings into your responses when answering the user's questions.
The information in the "learnings" field contains up-to-date information that you should consider when formulating your responses. DO NOT add disclaimers about the currency or certainty of this information.
Present this information directly without qualifiers like "I don't have specific, up-to-date information" or "I can't be completely certain".

Stick strictly to the information provided in the "learnings" field. DO NOT assume, infer, or add any details that are not explicitly stated in the response.
If the user asks for information that is not covered in the "learnings" field, acknowledge the gap and ask for clarification rather than making assumptions or offering suggestions that aren't based on the provided knowledge.`
);
}
} else {
instructions.push(
`You do not have a working memory. If the user expects you to remember the previous conversations, tell them they can set up the knowledge base.`
);
}
return instructions.map((instruction) => dedent(instruction));
});
if (isObservabilityDeployment || isGenericDeployment) {
functions.registerInstruction(({ availableFunctionNames }) =>
getObservabilitySystemPrompt({
availableFunctionNames,
isServerless,
isKnowledgeBaseReady,
isObservabilityDeployment,
isProductDocsAvailable,
})
);
}

if (isKnowledgeBaseReady) {
registerSummarizationFunction(registrationParameters);
} else {
functions.registerInstruction(
`You do not have a working memory. If the user expects you to remember the previous conversations, tell them they can set up the knowledge base.`
Comment thread
viduni94 marked this conversation as resolved.
Outdated
);
}

registerContextFunction({ ...registrationParameters, isKnowledgeBaseReady });

registerElasticsearchFunction(registrationParameters);
const request = registrationParameters.resources.request;

const request = registrationParameters.resources.request;
if ('id' in request) {
registerKibanaFunction({
...registrationParameters,
Expand All @@ -149,6 +82,7 @@ ${
},
});
}

registerGetDatasetInfoFunction(registrationParameters);

registerExecuteConnectorFunction(registrationParameters);
Expand Down
Loading