File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 6161 "type" : " string" ,
6262 "title" : " Instruction" ,
6363 "description" : " The initial system prompt (i.e. the hidden instruction) to use when generating responses." ,
64- "default" : " You are a helpful AI assistant. Please respond appropriately."
64+ "default" : " You are a helpful AI assistant. Please respond appropriately. Today's date is {date}. "
6565 },
6666 "page_title" : {
6767 "type" : " string" ,
Original file line number Diff line number Diff line change 22import utils
33import gradio as gr
44
5+ from datetime import date
56from urllib .parse import urljoin
67from langchain .schema import HumanMessage , AIMessage , SystemMessage
78from langchain_openai import ChatOpenAI
@@ -68,11 +69,12 @@ def inference(latest_message, history):
6869
6970 try :
7071 context = []
72+ model_instruction = settings .model_instruction .replace ("{date}" , f"{ date .today ()} " )
7173 if INCLUDE_SYSTEM_PROMPT :
72- context .append (SystemMessage (content = settings . model_instruction ))
74+ context .append (SystemMessage (content = model_instruction ))
7375 elif history and len (history ) > 0 :
7476 # Mimic system prompt by prepending it to first human message
75- history [0 ]['content' ] = f"{ settings . model_instruction } \n \n { history [0 ]['content' ]} "
77+ history [0 ]['content' ] = f"{ model_instruction } \n \n { history [0 ]['content' ]} "
7678
7779 for message in history :
7880 role = message ['role' ]
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ backend_url: http://localhost:11434
55
66host_address : 0.0.0.0
77
8- model_instruction : " You are a helpful and cheerful AI assistant. Please respond appropriately."
8+ # Model instruction allows substituting in current date
9+ model_instruction : " You are a helpful and cheerful AI assistant. Please respond appropriately. Today's date is {date}."
910
1011page_title : Large Language Model
1112
You can’t perform that action at this time.
0 commit comments