diff --git a/holmes/plugins/prompts/__init__.py b/holmes/plugins/prompts/__init__.py index 6a818a4cf2..24c683b9f1 100644 --- a/holmes/plugins/prompts/__init__.py +++ b/holmes/plugins/prompts/__init__.py @@ -2,6 +2,7 @@ import os.path from typing import Optional from jinja2 import Environment, FileSystemLoader +from datetime import datetime, timezone THIS_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -35,9 +36,13 @@ def load_and_render_prompt(prompt: str, context: Optional[dict] = None) -> str: env = Environment( loader=FileSystemLoader(THIS_DIR), ) + template = env.from_string(prompt_as_str) if context is None: context = {} + now = datetime.now(timezone.utc) + context.update({"now": f"{now}", "now_timestamp_seconds": int(now.timestamp())}) + return template.render(**context) diff --git a/holmes/plugins/prompts/generic_ask_conversation.jinja2 b/holmes/plugins/prompts/generic_ask_conversation.jinja2 index 6753fb6fb2..ca5f17a6cb 100644 --- a/holmes/plugins/prompts/generic_ask_conversation.jinja2 +++ b/holmes/plugins/prompts/generic_ask_conversation.jinja2 @@ -3,6 +3,7 @@ Whenever possible you MUST first use tools to investigate then answer the questi Do not say 'based on the tool output' or explicitly refer to tools at all. If you output an answer and then realize you need to call more tools or there are possible next steps, you may do so by calling tools at that point in time. If you have a good and concrete suggestion for how the user can fix something, tell them even if not asked explicitly +When querying tools, always query for the relevant time period. The current UTC date and time are {{ now }}. The current UTC timestamp in seconds is {{ now_timestamp_seconds }}. Use conversation history to maintain continuity when appropriate, ensuring efficiency in your responses. diff --git a/holmes/plugins/prompts/generic_ask_for_issue_conversation.jinja2 b/holmes/plugins/prompts/generic_ask_for_issue_conversation.jinja2 index 8a67401d5b..42b0c19abb 100644 --- a/holmes/plugins/prompts/generic_ask_for_issue_conversation.jinja2 +++ b/holmes/plugins/prompts/generic_ask_for_issue_conversation.jinja2 @@ -2,6 +2,7 @@ You are a tool-calling AI assist provided with common devops and IT tools that y Whenever possible you MUST first use tools to investigate then answer the question. Do not say 'based on the tool output' or explicitly refer to tools at all. If you output an answer and then realize you need to call more tools or there are possible next steps, you may do so by calling tools at that point in time. +When querying tools, always query for the relevant time period. The current UTC date and time are {{ now }}. The current UTC timestamp in seconds is {{ now_timestamp_seconds }}. ### Context Awareness: Be aware that this conversation is follow-up questions to a prior investigation conducted for the {{issue}}. diff --git a/holmes/plugins/prompts/generic_investigation.jinja2 b/holmes/plugins/prompts/generic_investigation.jinja2 index 052717095b..f64a741558 100644 --- a/holmes/plugins/prompts/generic_investigation.jinja2 +++ b/holmes/plugins/prompts/generic_investigation.jinja2 @@ -3,7 +3,7 @@ Whenever possible you MUST first use tools to investigate then answer the questi Do not say 'based on the tool output' Provide an terse analysis of the following {{ issue.source_type }} alert/issue and why it is firing. -* When querying tools, always query for the relevant time period +* When querying tools, always query for the relevant time period. The current UTC date and time are {{ now }}. The current UTC timestamp in seconds is {{ now_timestamp_seconds }}. * If the tool requires string format timestamps, query from 'start_timestamp' until 'end_timestamp' * If the tool requires timestamps in milliseconds, query from 'start_timestamp' until 'end_timestamp' * If you need timestamp in string format, query from 'start_timestamp_millis' until 'end_timestamp_millis' diff --git a/holmes/plugins/prompts/kubernetes_workload_ask.jinja2 b/holmes/plugins/prompts/kubernetes_workload_ask.jinja2 index 7cf3a31b89..3b9afaab71 100644 --- a/holmes/plugins/prompts/kubernetes_workload_ask.jinja2 +++ b/holmes/plugins/prompts/kubernetes_workload_ask.jinja2 @@ -4,7 +4,7 @@ Do not say 'based on the tool output' or explicitly refer to tools at all. If you output an answer and then realize you need to call more tools or there are possible next steps, you may do so by calling tools at that point in time. If the user provides you with extra instructions in a triple single quotes section, ALWAYS perform their instructions and then perform your investigation. - +When querying tools, always query for the relevant time period. The current UTC date and time are {{ now }}. The current UTC timestamp in seconds is {{ now_timestamp_seconds }}. Global Instructions You may receive a set of “Global Instructions” that describe how to perform certain tasks, handle certain situations, or apply certain best practices. They are not mandatory for every request, but serve as a reference resource and must be used if the current scenario or user request aligns with one of the described methods or conditions. diff --git a/holmes/plugins/prompts/kubernetes_workload_chat.jinja2 b/holmes/plugins/prompts/kubernetes_workload_chat.jinja2 index cc63b18dbf..daa3dc3ddb 100644 --- a/holmes/plugins/prompts/kubernetes_workload_chat.jinja2 +++ b/holmes/plugins/prompts/kubernetes_workload_chat.jinja2 @@ -2,6 +2,7 @@ You are a tool-calling AI assist provided with common DevOps and IT tools that y Whenever possible, you MUST first use tools to investigate, then answer the question. Do not say 'based on the tool output' or explicitly refer to tools at all. If you output an answer and then realize you need to call more tools or there are possible next steps, you may do so by calling tools at that point in time. +When querying tools, always query for the relevant time period. The current UTC date and time are {{ now }}. The current UTC timestamp in seconds is {{ now_timestamp_seconds }}. ### Context Awareness: Be aware that this conversation is follow-up questions to a prior investigation conducted for the {{resource}}.