move agent instruction for tone to file
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
You are an AI writing assistant integrated into Chatwoot, an omnichannel customer support platform. Your task is to rewrite customer support message to match a specific tone while preserving the original meaning and intent.
|
||||
|
||||
Here is the tone to apply to the message you will receive:
|
||||
<tone_instruction>
|
||||
%s
|
||||
</tone_instruction>
|
||||
|
||||
Your task is to rewrite the message according to the specified tone instructions.
|
||||
|
||||
Important guidelines:
|
||||
- Preserve the core meaning and all important information from the original message
|
||||
- Keep the rewritten message concise and appropriate for customer support
|
||||
- Maintain helpfulness and respect regardless of tone
|
||||
- Do not add information that wasn't in the original message
|
||||
- Do not remove critical details or instructions
|
||||
- Ensure that the reply should be in user language.
|
||||
|
||||
Output only the rewritten message without any preamble, tags or explanation.
|
||||
|
||||
@@ -1,25 +1,5 @@
|
||||
class Integrations::Openai::ProcessorService < Integrations::LlmBaseService
|
||||
LANGUAGE_INSTRUCTION = 'Ensure that the reply should be in user language.'.freeze
|
||||
AGENT_INSTRUCTION = <<~HEREDOC.freeze
|
||||
You are an AI writing assistant integrated into Chatwoot, an omnichannel customer support platform. Your task is to rewrite customer support message to match a specific tone while preserving the original meaning and intent.
|
||||
|
||||
Here is the tone to apply to the message you will receive:
|
||||
<tone_instruction>
|
||||
%s
|
||||
</tone_instruction>
|
||||
|
||||
Your task is to rewrite the message according to the specified tone instructions.
|
||||
|
||||
Important guidelines:
|
||||
- Preserve the core meaning and all important information from the original message
|
||||
- Keep the rewritten message concise and appropriate for customer support
|
||||
- Maintain helpfulness and respect regardless of tone
|
||||
- Do not add information that wasn't in the original message
|
||||
- Do not remove critical details or instructions
|
||||
- #{LANGUAGE_INSTRUCTION}
|
||||
|
||||
Output only the rewritten message without any preamble, tags or explanation.
|
||||
HEREDOC
|
||||
def reply_suggestion_message
|
||||
make_api_call(reply_suggestion_body)
|
||||
end
|
||||
@@ -30,7 +10,7 @@ class Integrations::Openai::ProcessorService < Integrations::LlmBaseService
|
||||
|
||||
def confident_message
|
||||
tone_instruction = determine_tone_instruction('confident')
|
||||
make_api_call(build_api_call_body(format(AGENT_INSTRUCTION, tone_instruction)))
|
||||
make_api_call(build_api_call_body(tone_rewrite_prompt(tone_instruction)))
|
||||
end
|
||||
|
||||
def fix_spelling_grammar_message
|
||||
@@ -40,27 +20,27 @@ class Integrations::Openai::ProcessorService < Integrations::LlmBaseService
|
||||
|
||||
def straightforward_message
|
||||
tone_instruction = determine_tone_instruction('straightforward')
|
||||
make_api_call(build_api_call_body(format(AGENT_INSTRUCTION, tone_instruction)))
|
||||
make_api_call(build_api_call_body(tone_rewrite_prompt(tone_instruction)))
|
||||
end
|
||||
|
||||
def casual_message
|
||||
tone_instruction = determine_tone_instruction('casual')
|
||||
make_api_call(build_api_call_body(format(AGENT_INSTRUCTION, tone_instruction)))
|
||||
make_api_call(build_api_call_body(tone_rewrite_prompt(tone_instruction)))
|
||||
end
|
||||
|
||||
def make_friendly_message
|
||||
tone_instruction = determine_tone_instruction('friendly')
|
||||
make_api_call(build_api_call_body(format(AGENT_INSTRUCTION, tone_instruction)))
|
||||
make_api_call(build_api_call_body(tone_rewrite_prompt(tone_instruction)))
|
||||
end
|
||||
|
||||
def make_formal_message
|
||||
tone_instruction = determine_tone_instruction('formal')
|
||||
make_api_call(build_api_call_body(format(AGENT_INSTRUCTION, tone_instruction)))
|
||||
make_api_call(build_api_call_body(tone_rewrite_prompt(tone_instruction)))
|
||||
end
|
||||
|
||||
def professional_message
|
||||
tone_instruction = determine_tone_instruction('professional')
|
||||
make_api_call(build_api_call_body(format(AGENT_INSTRUCTION, tone_instruction)))
|
||||
make_api_call(build_api_call_body(tone_rewrite_prompt(tone_instruction)))
|
||||
end
|
||||
|
||||
private
|
||||
@@ -70,6 +50,10 @@ class Integrations::Openai::ProcessorService < Integrations::LlmBaseService
|
||||
Rails.root.join(path, "#{file_name}.txt").read
|
||||
end
|
||||
|
||||
def tone_rewrite_prompt(tone_instruction)
|
||||
format(prompt_from_file('tone_rewrite'), tone_instruction)
|
||||
end
|
||||
|
||||
def build_api_call_body(system_content, user_content = event['data']['content'])
|
||||
{
|
||||
model: GPT_MODEL,
|
||||
|
||||
Reference in New Issue
Block a user