@@ -6,6 +6,8 @@ import { createMCPToolId } from "./mcp/mcp-tool-id";
66import { format } from "date-fns" ;
77import { Agent } from "app-types/agent" ;
88
9+ const CURRENT_TIME_FORMAT = "EEEE, MMMM d, yyyy 'at' h:mm:ss a" ;
10+
911export const CREATE_THREAD_TITLE_PROMPT = `
1012You are a chat title generation expert.
1113
@@ -52,19 +54,34 @@ export const buildUserSystemPrompt = (
5254 user ?: User ,
5355 userPreferences ?: UserPreferences ,
5456 agent ?: Agent ,
57+ ) => {
58+ return [
59+ buildUserSystemStaticPrompt ( user , userPreferences , agent ) ,
60+ buildCurrentDateTimeSystemPrompt ( ) ,
61+ ]
62+ . filter ( Boolean )
63+ . join ( "\n\n" ) ;
64+ } ;
65+
66+ export const buildCurrentDateTimeSystemPrompt = ( ) => {
67+ const currentTime = format ( new Date ( ) , CURRENT_TIME_FORMAT ) ;
68+ return `The current date and time is ${ currentTime } .` ;
69+ } ;
70+
71+ export const buildUserSystemStaticPrompt = (
72+ user ?: User ,
73+ userPreferences ?: UserPreferences ,
74+ agent ?: Agent ,
5575) => {
5676 const assistantName =
5777 agent ?. name || userPreferences ?. botName || "better-chatbot" ;
58- const currentTime = format ( new Date ( ) , "EEEE, MMMM d, yyyy 'at' h:mm:ss a" ) ;
5978
60- let prompt = `You are ${ assistantName } ` ;
79+ let prompt = `You are ${ assistantName } . ` ;
6180
6281 if ( agent ?. instructions ?. role ) {
63- prompt += `. You are an expert in ${ agent . instructions . role } ` ;
82+ prompt += ` You are an expert in ${ agent . instructions . role } . ` ;
6483 }
6584
66- prompt += `. The current date and time is ${ currentTime } .` ;
67-
6885 // Agent-specific instructions as primary core
6986 if ( agent ?. instructions ?. systemPrompt ) {
7087 prompt += `
@@ -136,17 +153,29 @@ export const buildSpeechSystemPrompt = (
136153 user : User ,
137154 userPreferences ?: UserPreferences ,
138155 agent ?: Agent ,
156+ ) => {
157+ return [
158+ buildSpeechSystemStaticPrompt ( user , userPreferences , agent ) ,
159+ buildCurrentDateTimeSystemPrompt ( ) ,
160+ ]
161+ . filter ( Boolean )
162+ . join ( "\n\n" ) ;
163+ } ;
164+
165+ export const buildSpeechSystemStaticPrompt = (
166+ user : User ,
167+ userPreferences ?: UserPreferences ,
168+ agent ?: Agent ,
139169) => {
140170 const assistantName = agent ?. name || userPreferences ?. botName || "Assistant" ;
141- const currentTime = format ( new Date ( ) , "EEEE, MMMM d, yyyy 'at' h:mm:ss a" ) ;
142171
143172 let prompt = `You are ${ assistantName } ` ;
144173
145174 if ( agent ?. instructions ?. role ) {
146175 prompt += `. You are an expert in ${ agent . instructions . role } ` ;
147176 }
148177
149- prompt += `. The current date and time is ${ currentTime } .` ;
178+ prompt += "." ;
150179
151180 // Agent-specific instructions as primary core
152181 if ( agent ?. instructions ?. systemPrompt ) {
0 commit comments