added security checks for journal text box for AI
This commit is contained in:
@@ -15,20 +15,24 @@ export function getGenerationSlotCount(
|
||||
}
|
||||
|
||||
export function buildGenerationUserPrompt(
|
||||
context: AiTaskContext,
|
||||
_context: AiTaskContext,
|
||||
options?: AiTaskGenerationOptions,
|
||||
) {
|
||||
const maxCount = options?.maxCount ?? MAX_DAILY_AI_TASKS;
|
||||
const excludeLabels = options?.excludeLabels ?? [];
|
||||
|
||||
if (excludeLabels.length === 0) {
|
||||
return `Generate today's personalized habit task labels as a JSON array of up to ${maxCount} strings.`;
|
||||
}
|
||||
const baseRequest =
|
||||
excludeLabels.length === 0
|
||||
? `Generate today's personalized habit task labels as a JSON array of up to ${maxCount} strings.`
|
||||
: [
|
||||
`Generate exactly ${maxCount} NEW habit task labels as a JSON array of strings.`,
|
||||
"Do not repeat or rephrase any of these existing tasks the user already has:",
|
||||
...excludeLabels.map((label) => `- ${label}`),
|
||||
"Use different wording only for genuinely different activities.",
|
||||
].join("\n");
|
||||
|
||||
return [
|
||||
`Generate exactly ${maxCount} NEW habit task labels as a JSON array of strings.`,
|
||||
"Do not repeat or rephrase any of these existing tasks the user already has:",
|
||||
...excludeLabels.map((label) => `- ${label}`),
|
||||
"Use different wording only for genuinely different activities.",
|
||||
].join("\n");
|
||||
baseRequest,
|
||||
"Output contract: respond with ONLY a JSON array of strings. Do not include explanations, markdown, or any other text.",
|
||||
].join("\n\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user