From 2a701b276be09158f571418d296e6874a70a004f Mon Sep 17 00:00:00 2001 From: Patryk Kopycinski Date: Fri, 2 Aug 2024 17:31:28 +0200 Subject: [PATCH 1/4] Test --- .../lib/langchain/graphs/default_assistant_graph/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts index 4e64b38fc0b9f..40336561149e6 100644 --- a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts +++ b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts @@ -93,7 +93,7 @@ export const callAssistantGraph: AgentExecutor = async ({ const modelExists = await esStore.isModelInstalled(); // Create a chain that uses the ELSER backed ElasticsearchStore, override k=10 for esql query generation for now - const chain = RetrievalQAChain.fromLLM(llm, esStore.asRetriever(10)); + const chain = RetrievalQAChain.fromLLM(getLlmInstance(), esStore.asRetriever(10)); // Check if KB is available const isEnabledKnowledgeBase = (await dataClients?.kbDataClient?.isModelDeployed()) ?? false; From d61d8d3400811e9086ccad6b0acdf8630e1caec3 Mon Sep 17 00:00:00 2001 From: Patryk Kopycinski Date: Fri, 2 Aug 2024 18:06:20 +0200 Subject: [PATCH 2/4] test --- .../lib/langchain/graphs/default_assistant_graph/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts index a811cc77575e5..9f0ff1b7a51f8 100644 --- a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts +++ b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts @@ -28,7 +28,7 @@ export const geminiToolCallingAgentPrompt = ChatPromptTemplate.fromMessages([ [ 'system', 'You are a helpful assistant. ALWAYS use the provided tools. Use tools as often as possible, as they have access to the latest data and syntax.\n\n' + - `The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question, which is "{input}". The final response should never be empty.`, + "The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question. The final response should never be empty.", ], ['placeholder', '{chat_history}'], ['human', '{input}'], From 899b1c87082340f6c15e285b813ae24abc339b4c Mon Sep 17 00:00:00 2001 From: Andrew Macri Date: Fri, 2 Aug 2024 14:49:10 -0600 Subject: [PATCH 3/4] - reverts change to x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts --- .../lib/langchain/graphs/default_assistant_graph/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts index 9f0ff1b7a51f8..a811cc77575e5 100644 --- a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts +++ b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts @@ -28,7 +28,7 @@ export const geminiToolCallingAgentPrompt = ChatPromptTemplate.fromMessages([ [ 'system', 'You are a helpful assistant. ALWAYS use the provided tools. Use tools as often as possible, as they have access to the latest data and syntax.\n\n' + - "The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question. The final response should never be empty.", + `The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question, which is "{input}". The final response should never be empty.`, ], ['placeholder', '{chat_history}'], ['human', '{input}'], From 6b599e09fda0c635f34b37a1f8a3ec38c5c7caf1 Mon Sep 17 00:00:00 2001 From: Andrew Macri Date: Fri, 2 Aug 2024 16:14:59 -0600 Subject: [PATCH 4/4] - restores https://github.com/elastic/kibana/pull/189810/commits/d61d8d3400811e9086ccad6b0acdf8630e1caec3 --- .../lib/langchain/graphs/default_assistant_graph/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts index a811cc77575e5..9f0ff1b7a51f8 100644 --- a/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts +++ b/x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/prompts.ts @@ -28,7 +28,7 @@ export const geminiToolCallingAgentPrompt = ChatPromptTemplate.fromMessages([ [ 'system', 'You are a helpful assistant. ALWAYS use the provided tools. Use tools as often as possible, as they have access to the latest data and syntax.\n\n' + - `The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question, which is "{input}". The final response should never be empty.`, + "The final response will be the only output the user sees and should be a complete answer to the user's question, as if you were responding to the user's initial question. The final response should never be empty.", ], ['placeholder', '{chat_history}'], ['human', '{input}'],