File tree 5 files changed +16
-6
lines changed
5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type { UserEmailWithAI } from "@/utils/llms/types";
5
5
import type { EmailForLLM } from "@/utils/types" ;
6
6
import { stringifyEmail } from "@/utils/stringify-email" ;
7
7
import { getEconomyModel } from "@/utils/llms/model-selector" ;
8
+ import { getTodayForLLM } from "@/utils/llms/helpers" ;
8
9
9
10
const logger = createScopedLogger ( "EmailHistoryExtractor" ) ;
10
11
@@ -31,13 +32,15 @@ const USER_PROMPT = ({
31
32
historicalMessages : EmailForLLM [ ] ;
32
33
user : UserEmailWithAI ;
33
34
} ) => {
34
- return `Current Email Thread:
35
+ return `<current_email_thread>
35
36
${ currentThreadMessages . map ( ( m ) => stringifyEmail ( m , 10000 ) ) . join ( "\n---\n" ) }
37
+ </current_email_thread>
36
38
37
39
${
38
40
historicalMessages . length > 0
39
- ? `Historical Email Threads:
40
- ${ historicalMessages . map ( ( m ) => stringifyEmail ( m , 10000 ) ) . join ( "\n---\n" ) } `
41
+ ? `<historical_email_threads>
42
+ ${ historicalMessages . map ( ( m ) => stringifyEmail ( m , 10000 ) ) . join ( "\n---\n" ) }
43
+ </historical_email_threads>`
41
44
: "No historical email threads available."
42
45
}
43
46
52
55
</user_info>`
53
56
}
54
57
58
+ ${ getTodayForLLM ( ) }
55
59
Analyze the historical email threads and extract any relevant information that would be helpful for drafting a response to the current email thread. Provide a concise summary of the key historical context.` ;
56
60
} ;
57
61
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { chatCompletionObject } from "@/utils/llms";
4
4
import type { UserEmailWithAI } from "@/utils/llms/types" ;
5
5
import type { EmailForLLM } from "@/utils/types" ;
6
6
import { stringifyEmail } from "@/utils/stringify-email" ;
7
+ import { getTodayForLLM } from "@/utils/llms/helpers" ;
7
8
8
9
const logger = createScopedLogger ( "DraftWithKnowledge" ) ;
9
10
@@ -84,7 +85,7 @@ ${stringifyEmail(msg, 3000)}
84
85
. join ( "\n" ) }
85
86
86
87
Please write a reply to the email.
87
- Today's date is: ${ new Date ( ) . toISOString ( ) . split ( "T" ) [ 0 ] } .
88
+ ${ getTodayForLLM ( ) }
88
89
IMPORTANT: The person you're writing an email for is: ${ messages . at ( - 1 ) ?. to } .` . trim ( ) ;
89
90
} ;
90
91
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { UserEmailWithAI } from "@/utils/llms/types";
3
3
import { stringifyEmail } from "@/utils/stringify-email" ;
4
4
import { createScopedLogger } from "@/utils/logger" ;
5
5
import type { EmailForLLM } from "@/utils/types" ;
6
+ import { getTodayForLLM } from "@/utils/llms/helpers" ;
6
7
7
8
const logger = createScopedLogger ( "generate-nudge" ) ;
8
9
@@ -34,7 +35,7 @@ ${stringifyEmail(msg, 3000)}
34
35
35
36
Write a brief follow-up email to politely nudge for a response.
36
37
37
- Today's date is: ${ new Date ( ) . toISOString ( ) . split ( "T" ) [ 0 ] } .
38
+ ${ getTodayForLLM ( ) }
38
39
IMPORTANT: The person you're writing an email for is: ${ messages . at ( - 1 ) ?. from } .` ;
39
40
40
41
logger . trace ( "Input" , { system, prompt } ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { UserEmailWithAI } from "@/utils/llms/types";
3
3
import { stringifyEmail } from "@/utils/stringify-email" ;
4
4
import { createScopedLogger } from "@/utils/logger" ;
5
5
import type { EmailForLLM } from "@/utils/types" ;
6
+ import { getTodayForLLM } from "@/utils/llms/helpers" ;
6
7
7
8
const logger = createScopedLogger ( "generate-reply" ) ;
8
9
@@ -59,7 +60,7 @@ ${stringifyEmail(msg, 3000)}
59
60
. join ( "\n" ) }
60
61
61
62
Please write a reply to the email.
62
- Today's date is: ${ new Date ( ) . toISOString ( ) . split ( "T" ) [ 0 ] } .
63
+ ${ getTodayForLLM ( ) }
63
64
IMPORTANT: The person you're writing an email for is: ${ messages . at ( - 1 ) ?. to } .` . trim ( ) ;
64
65
65
66
logger . trace ( "Input" , { system, prompt } ) ;
Original file line number Diff line number Diff line change
1
+ export function getTodayForLLM ( ) {
2
+ return `Today's date is: ${ new Date ( ) . toISOString ( ) . split ( "T" ) [ 0 ] } .` ;
3
+ }
You can’t perform that action at this time.
0 commit comments