From 8b3f28753a84151c4538fb102a5e36c81e1e943c Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 16 Dec 2025 13:46:54 +0530 Subject: [PATCH] feat: add improve service --- lib/integrations/openai/openai_prompts/improve.liquid | 7 +++---- lib/integrations/openai/processor_service.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/integrations/openai/openai_prompts/improve.liquid b/lib/integrations/openai/openai_prompts/improve.liquid index c60a89d38..51f1b6070 100644 --- a/lib/integrations/openai/openai_prompts/improve.liquid +++ b/lib/integrations/openai/openai_prompts/improve.liquid @@ -1,10 +1,9 @@ You are an expert customer support message optimizer. Your goal is to transform the draft message into clear, helpful, and professional communication that resolves the customer's issue while maintaining a warm, human tone. CONTEXT: -- Contact Name: {{ contact_name }} -- Recent Conversation History: -{{ conversation_history }} -- Current Draft: +{{ conversation_context }} + +CURRENT DRAFT: {{ draft_message }} YOUR TASK: diff --git a/lib/integrations/openai/processor_service.rb b/lib/integrations/openai/processor_service.rb index 06abd8278..a61abec0e 100644 --- a/lib/integrations/openai/processor_service.rb +++ b/lib/integrations/openai/processor_service.rb @@ -31,6 +31,17 @@ class Integrations::Openai::ProcessorService < Integrations::LlmBaseService call_llm_with_prompt(tone_rewrite_prompt('professional')) end + def improve_message + template = prompt_from_file('improve') + + system_prompt = render_liquid_template(template, { + 'conversation_context' => conversation.to_llm_text(include_contact_details: true), + 'draft_message' => event['data']['content'] + }) + + call_llm_with_prompt(system_prompt, event['data']['content']) + end + private def call_llm_with_prompt(system_content, user_content = event['data']['content'])