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