This commit is contained in:
2026-03-12 16:36:03 +09:00
parent 5d7de270f2
commit 07fa685539

View File

@@ -64,6 +64,7 @@ const getSystemPrompt = (
- 「~です」「~ます」などの語尾を使って **丁寧に** 話す。 - 「~です」「~ます」などの語尾を使って **丁寧に** 話す。
- ハッシュタグや絵文字を使わない。 - ハッシュタグや絵文字を使わない。
- \`{ name: string, text: string }\` の JSON 形式で出力する。name と text 以外のプロパティは出力しない。 - \`{ name: string, text: string }\` の JSON 形式で出力する。name と text 以外のプロパティは出力しない。
- 3センテンス、140文字程度で出力する。
${instruction}`; ${instruction}`;
const postJobPrompt = getSystemPrompt( const postJobPrompt = getSystemPrompt(
@@ -74,6 +75,15 @@ const replyJobPrompt = getSystemPrompt(
); );
async function rephrase(text: string) { async function rephrase(text: string) {
if (
text.includes("です") ||
text.includes("ます") ||
text.includes("でし") ||
text.includes("まし") ||
text.includes("ません")
) {
return text;
}
await using rephraseSession = new LlmSession( await using rephraseSession = new LlmSession(
model, model,
"ユーザが与えたテキストを「~です」「~ます」調(丁寧な文体)で言い換えたものを、そのまま出力してください。", "ユーザが与えたテキストを「~です」「~ます」調(丁寧な文体)で言い換えたものを、そのまま出力してください。",
@@ -111,12 +121,13 @@ type Job =
history: Note[]; history: Note[];
}; };
await using postJobSession = new LlmSession(model, postJobPrompt);
await postJobSession.init();
async function processPostJob() { async function processPostJob() {
const notes = await getNotes(10, 0, 5); const notes = await getNotes(10, 0, 5);
const input = notes.map(formatNote).join("\n"); const input = notes.map(formatNote).join("\n");
const text = await parseResponse( const text = await (async () => {
await using postJobSession = new LlmSession(model, postJobPrompt);
await postJobSession.init();
return await parseResponse(
grammar, grammar,
await postJobSession.prompt(input, { await postJobSession.prompt(input, {
...baseChatPromptOptions, ...baseChatPromptOptions,
@@ -128,6 +139,7 @@ async function processPostJob() {
}, },
}), }),
); );
})();
if (text) { if (text) {
const rephrased = await rephrase(text); const rephrased = await rephrase(text);
if (values.test) return; if (values.test) return;