diff --git a/assembly/index.ts b/assembly/index.ts index 1c1d4cd..349e1b9 100644 --- a/assembly/index.ts +++ b/assembly/index.ts @@ -8,6 +8,7 @@ import { import { bulletPointSummaryInstruction, generateGrammarCheckerInstruction, + generateParaphraseInstruction, generateSummaryInstruction, @@ -48,3 +49,13 @@ export function summarizeText(text: string, length:string, summaryMode:string ): return output.choices[0].message.content.trim() } +export function paraphraseText(text: string, mode:string ): string { + const model = models.getModel(summarizeTextModel) + const paraphraseTextInstruction = generateParaphraseInstruction(mode) + const input = model.createInput([ + new SystemMessage(paraphraseTextInstruction), + new UserMessage(text), + ]) + const output = model.invoke(input) + return output.choices[0].message.content.trim() +} \ No newline at end of file diff --git a/assembly/instructions.ts b/assembly/instructions.ts index e83c950..c2093c8 100644 --- a/assembly/instructions.ts +++ b/assembly/instructions.ts @@ -101,3 +101,22 @@ Expected output format: ] **Important**: Do not include markdown-style code block indicators (\`json and \`\`) in your response. Return only the array. `; + +export function generateParaphraseInstruction(tone: string): string { + + const prompt: string = ` + Rewrite the given text in a ${tone} tone while: + - Preserving the core meaning and context + - Maintaining natural flow and readability + - Keeping key terminology and technical concepts + - Adapting word choice and expressions to match the ${tone} style + - Ensuring proper grammar and punctuation + - Retaining the original language and general sentence structure + + **Important**: + - Output only the paraphrased text + - Do not include any explanatory notes or meta-commentary + - Do not add introductory phrases or conclusions + - Do not include phrases like "Here's the rewritten text' or any other explanation—just the paraphrased text itself."`; + return prompt; +} \ No newline at end of file