diff --git a/lib/integrations/openai/openai_prompts/improve.liquid b/lib/integrations/openai/openai_prompts/improve.liquid index 74074463c..45ffe6817 100644 --- a/lib/integrations/openai/openai_prompts/improve.liquid +++ b/lib/integrations/openai/openai_prompts/improve.liquid @@ -5,28 +5,15 @@ You are an AI writing assistant integrated into Chatwoot, an omnichannel custome Improve ONLY the selected portion of the message. Return the COMPLETE message with the improved selection seamlessly integrated. Keep all other parts exactly as they are. {% endif -%} -{% if tone -%} +{% if tone_instruction -%} # Tone Apply the following tone to {% if selection %}the selected portion{% else %}the message{% endif %}: -{% case tone -%} -{% when 'friendly' -%} -Warm, approachable, empathetic. Use conversational language and positive words. -{% when 'confident' -%} -Assertive and assured. Use definitive language, avoid hedging words like "maybe" or "I think". -{% when 'professional' -%} -Formal, polished, business-appropriate. Complete sentences, proper grammar, respectful distance. -{% when 'casual' -%} -Relaxed and informal. Use contractions, simpler words, conversational style. -{% when 'straightforward' -%} -Clear, direct, to-the-point. No fluff or extra pleasantries. -{% else -%} -{{ tone }} -{% endcase -%} +{{ tone_instruction }} {% endif -%} -{% unless tone or selection -%} +{% unless tone_instruction or selection -%} # Task Improve the message for clarity, grammar, spelling, and natural flow while maintaining the original tone and intent. diff --git a/lib/integrations/openai/processor_service.rb b/lib/integrations/openai/processor_service.rb index b15b30d0f..1d92c02d3 100644 --- a/lib/integrations/openai/processor_service.rb +++ b/lib/integrations/openai/processor_service.rb @@ -66,7 +66,8 @@ class Integrations::Openai::ProcessorService < Integrations::LlmBaseService end def improve_prompt(selection, tone) - render_liquid_prompt('improve', { selection: selection, tone: tone }) + tone_instruction = determine_tone_instruction(tone) if tone.present? + render_liquid_prompt('improve', { selection: selection, tone_instruction: tone_instruction }) end def improve_user_content(content, selection)