From 2235129ad527ff210a7dba1704177b5f53ec1061 Mon Sep 17 00:00:00 2001 From: Scott Davidson Date: Tue, 28 Oct 2025 11:25:11 +0000 Subject: [PATCH 1/2] Add optional date templating in model system prompt --- web-apps/chat/app.py | 6 ++++-- web-apps/chat/defaults.yml | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web-apps/chat/app.py b/web-apps/chat/app.py index 18284bbb..a65d4923 100644 --- a/web-apps/chat/app.py +++ b/web-apps/chat/app.py @@ -2,6 +2,7 @@ import utils import gradio as gr +from datetime import date from urllib.parse import urljoin from langchain.schema import HumanMessage, AIMessage, SystemMessage from langchain_openai import ChatOpenAI @@ -68,11 +69,12 @@ def inference(latest_message, history): try: context = [] + model_instruction = settings.model_instruction.replace("{date}", f"{date.today()}") if INCLUDE_SYSTEM_PROMPT: - context.append(SystemMessage(content=settings.model_instruction)) + context.append(SystemMessage(content=model_instruction)) elif history and len(history) > 0: # Mimic system prompt by prepending it to first human message - history[0]['content'] = f"{settings.model_instruction}\n\n{history[0]['content']}" + history[0]['content'] = f"{model_instruction}\n\n{history[0]['content']}" for message in history: role = message['role'] diff --git a/web-apps/chat/defaults.yml b/web-apps/chat/defaults.yml index 8b9ebdff..55e4fd2b 100644 --- a/web-apps/chat/defaults.yml +++ b/web-apps/chat/defaults.yml @@ -5,7 +5,8 @@ backend_url: http://localhost:11434 host_address: 0.0.0.0 -model_instruction: "You are a helpful and cheerful AI assistant. Please respond appropriately." +# Model instruction allows substituting in current date +model_instruction: "You are a helpful and cheerful AI assistant. Please respond appropriately. Today's date is {date}." page_title: Large Language Model From f3edfce0e8b12453f9bda98028fa607d481a725b Mon Sep 17 00:00:00 2001 From: Scott Davidson Date: Tue, 28 Oct 2025 11:29:52 +0000 Subject: [PATCH 2/2] Include date template in default Azimuth system prompt --- charts/azimuth-chat/values.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/azimuth-chat/values.schema.json b/charts/azimuth-chat/values.schema.json index f7643777..d82ec389 100644 --- a/charts/azimuth-chat/values.schema.json +++ b/charts/azimuth-chat/values.schema.json @@ -61,7 +61,7 @@ "type": "string", "title": "Instruction", "description": "The initial system prompt (i.e. the hidden instruction) to use when generating responses.", - "default": "You are a helpful AI assistant. Please respond appropriately." + "default": "You are a helpful AI assistant. Please respond appropriately. Today's date is {date}." }, "page_title": { "type": "string",