Skip to content

Commit 13a3898

Browse files
committed
llm date helper
1 parent 1624a6c commit 13a3898

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

Diff for: apps/web/utils/ai/knowledge/extract-from-email-history.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { UserEmailWithAI } from "@/utils/llms/types";
55
import type { EmailForLLM } from "@/utils/types";
66
import { stringifyEmail } from "@/utils/stringify-email";
77
import { getEconomyModel } from "@/utils/llms/model-selector";
8+
import { getTodayForLLM } from "@/utils/llms/helpers";
89

910
const logger = createScopedLogger("EmailHistoryExtractor");
1011

@@ -31,13 +32,15 @@ const USER_PROMPT = ({
3132
historicalMessages: EmailForLLM[];
3233
user: UserEmailWithAI;
3334
}) => {
34-
return `Current Email Thread:
35+
return `<current_email_thread>
3536
${currentThreadMessages.map((m) => stringifyEmail(m, 10000)).join("\n---\n")}
37+
</current_email_thread>
3638
3739
${
3840
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>`
4144
: "No historical email threads available."
4245
}
4346
@@ -52,6 +55,7 @@ ${
5255
</user_info>`
5356
}
5457
58+
${getTodayForLLM()}
5559
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.`;
5660
};
5761

Diff for: apps/web/utils/ai/reply/draft-with-knowledge.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { chatCompletionObject } from "@/utils/llms";
44
import type { UserEmailWithAI } from "@/utils/llms/types";
55
import type { EmailForLLM } from "@/utils/types";
66
import { stringifyEmail } from "@/utils/stringify-email";
7+
import { getTodayForLLM } from "@/utils/llms/helpers";
78

89
const logger = createScopedLogger("DraftWithKnowledge");
910

@@ -84,7 +85,7 @@ ${stringifyEmail(msg, 3000)}
8485
.join("\n")}
8586
8687
Please write a reply to the email.
87-
Today's date is: ${new Date().toISOString().split("T")[0]}.
88+
${getTodayForLLM()}
8889
IMPORTANT: The person you're writing an email for is: ${messages.at(-1)?.to}.`.trim();
8990
};
9091

Diff for: apps/web/utils/ai/reply/generate-nudge.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { UserEmailWithAI } from "@/utils/llms/types";
33
import { stringifyEmail } from "@/utils/stringify-email";
44
import { createScopedLogger } from "@/utils/logger";
55
import type { EmailForLLM } from "@/utils/types";
6+
import { getTodayForLLM } from "@/utils/llms/helpers";
67

78
const logger = createScopedLogger("generate-nudge");
89

@@ -34,7 +35,7 @@ ${stringifyEmail(msg, 3000)}
3435
3536
Write a brief follow-up email to politely nudge for a response.
3637
37-
Today's date is: ${new Date().toISOString().split("T")[0]}.
38+
${getTodayForLLM()}
3839
IMPORTANT: The person you're writing an email for is: ${messages.at(-1)?.from}.`;
3940

4041
logger.trace("Input", { system, prompt });

Diff for: apps/web/utils/ai/reply/generate-reply.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { UserEmailWithAI } from "@/utils/llms/types";
33
import { stringifyEmail } from "@/utils/stringify-email";
44
import { createScopedLogger } from "@/utils/logger";
55
import type { EmailForLLM } from "@/utils/types";
6+
import { getTodayForLLM } from "@/utils/llms/helpers";
67

78
const logger = createScopedLogger("generate-reply");
89

@@ -59,7 +60,7 @@ ${stringifyEmail(msg, 3000)}
5960
.join("\n")}
6061
6162
Please write a reply to the email.
62-
Today's date is: ${new Date().toISOString().split("T")[0]}.
63+
${getTodayForLLM()}
6364
IMPORTANT: The person you're writing an email for is: ${messages.at(-1)?.to}.`.trim();
6465

6566
logger.trace("Input", { system, prompt });

Diff for: apps/web/utils/llms/helpers.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function getTodayForLLM() {
2+
return `Today's date is: ${new Date().toISOString().split("T")[0]}.`;
3+
}

0 commit comments

Comments
 (0)