Improve ghostwriter output language guidance (#248)
This commit is contained in:
@@ -80,6 +80,15 @@ describe("buildJobChatPromptContext", () => {
|
||||
});
|
||||
expect(context.systemPrompt).toContain("Writing style tone: direct.");
|
||||
expect(context.systemPrompt).toContain("Writing style formality: high.");
|
||||
expect(context.systemPrompt).toContain(
|
||||
"Follow the user's requested output language exactly when they specify one.",
|
||||
);
|
||||
expect(context.systemPrompt).toContain(
|
||||
"If the global writing constraints specify an output language, follow that when the user has not requested a different language.",
|
||||
);
|
||||
expect(context.systemPrompt).toContain(
|
||||
"If no output language is specified elsewhere, reply in the same language as the most recent user message.",
|
||||
);
|
||||
expect(context.systemPrompt).toContain(
|
||||
"Writing constraints: Keep responses under 120 words",
|
||||
);
|
||||
@@ -104,6 +113,24 @@ describe("buildJobChatPromptContext", () => {
|
||||
expect(context.systemPrompt).toContain("Writing style tone: professional.");
|
||||
});
|
||||
|
||||
it("preserves language instructions inside global writing constraints", async () => {
|
||||
const job = createJob({ id: "job-ctx-3" });
|
||||
vi.mocked(getJobById).mockResolvedValue(job);
|
||||
vi.mocked(getWritingStyle).mockResolvedValue({
|
||||
tone: "professional",
|
||||
formality: "medium",
|
||||
constraints: "Always respond in French.",
|
||||
doNotUse: "",
|
||||
});
|
||||
vi.mocked(getProfile).mockResolvedValue({});
|
||||
|
||||
const context = await buildJobChatPromptContext(job.id);
|
||||
|
||||
expect(context.systemPrompt).toContain(
|
||||
"Writing constraints: Always respond in French.",
|
||||
);
|
||||
});
|
||||
|
||||
it("throws not found for unknown job", async () => {
|
||||
vi.mocked(getJobById).mockResolvedValue(null);
|
||||
|
||||
|
||||
@@ -103,6 +103,9 @@ function buildSystemPrompt(style: WritingStyle): string {
|
||||
"Do not claim actions were executed. You are read-only and advisory.",
|
||||
"If details are missing, say what is missing before making assumptions.",
|
||||
"Avoid exposing private profile details that are unrelated to the user request.",
|
||||
"Follow the user's requested output language exactly when they specify one.",
|
||||
"If the global writing constraints specify an output language, follow that when the user has not requested a different language.",
|
||||
"If no output language is specified elsewhere, reply in the same language as the most recent user message.",
|
||||
`Writing style tone: ${style.tone}.`,
|
||||
`Writing style formality: ${style.formality}.`,
|
||||
style.constraints ? `Writing constraints: ${style.constraints}` : null,
|
||||
|
||||
Reference in New Issue
Block a user