55"""
66
77import time
8+ from datetime import datetime
89from typing import Annotated , Any , Optional , cast
910
1011from fastapi import APIRouter , BackgroundTasks , Depends , HTTPException , Request
@@ -101,18 +102,20 @@ def _get_rh_identity_context(request: Request) -> tuple[str, str]:
101102
102103
103104def _build_instructions (systeminfo : RlsapiV1SystemInfo ) -> str :
104- """Build LLM instructions incorporating system context when available .
105+ """Build LLM instructions incorporating date and system context .
105106
106- Enhances the default system prompt with RHEL system information to provide
107- the LLM with relevant context about the user's environment.
107+ Enhances the default system prompt with today's date and RHEL system
108+ information to provide the LLM with relevant context about the user's
109+ environment and current time.
108110
109111 Args:
110112 systeminfo: System information from the client (OS, version, arch).
111113
112114 Returns:
113- Instructions string for the LLM, with system context if available .
115+ Instructions string for the LLM, with date and system context .
114116 """
115117 base_prompt = _get_base_prompt ()
118+ date_today = datetime .now ().strftime ("%B %d, %Y" )
116119
117120 context_parts = []
118121 if systeminfo .os :
@@ -123,10 +126,10 @@ def _build_instructions(systeminfo: RlsapiV1SystemInfo) -> str:
123126 context_parts .append (f"Architecture: { systeminfo .arch } " )
124127
125128 if not context_parts :
126- return base_prompt
129+ return f" { base_prompt } \n \n Today's date: { date_today } "
127130
128131 system_context = ", " .join (context_parts )
129- return f"{ base_prompt } \n \n User's system: { system_context } "
132+ return f"{ base_prompt } \n \n Today's date: { date_today } \n \ n User's system: { system_context } "
130133
131134
132135def _get_base_prompt () -> str :
0 commit comments