diff --git a/enterprise/lib/enterprise/integrations/openai_processor_service.rb b/enterprise/lib/enterprise/integrations/openai_processor_service.rb index 3f0ee8c4c..a9d746852 100644 --- a/enterprise/lib/enterprise/integrations/openai_processor_service.rb +++ b/enterprise/lib/enterprise/integrations/openai_processor_service.rb @@ -17,6 +17,10 @@ module Enterprise::Integrations::OpenaiProcessorService private + def prompt_from_file(file_name) + Rails.root.join('enterprise/lib/enterprise/integrations/openai_prompts', "#{file_name}.txt").read + end + def labels_with_messages labels = hook.account.labels.pluck(:title).join(', ') @@ -30,6 +34,17 @@ module Enterprise::Integrations::OpenaiProcessorService "Messages:\n#{messages}\nLabels:\n#{labels}" end + def summarize_body + { + model: self.class::GPT_MODEL, + messages: [ + { role: 'system', + content: prompt_from_file('summary') }, + { role: 'user', content: conversation_messages } + ] + }.to_json + end + def label_suggestion_body content = labels_with_messages return nil if content.blank? @@ -39,13 +54,7 @@ module Enterprise::Integrations::OpenaiProcessorService messages: [ { role: 'system', - content: 'Your role is as an assistant to a customer support agent. You will be provided with a transcript of a conversation between a ' \ - 'customer and the support agent, along with a list of potential labels. ' \ - 'Your task is to analyze the conversation and select the two labels from the given list that most accurately ' \ - 'represent the themes or issues discussed. Ensure you preserve the exact casing of the labels as they are provided in the list. ' \ - 'Do not create new labels; only choose from those provided. Once you have made your selections, please provide your response ' \ - 'as a comma-separated list of the provided labels. Remember, your response should only contain the labels you\'ve selected, ' \ - 'in their original casing, and nothing else. ' + content: prompt_from_file('label_suggestion') }, { role: 'user', content: content } ] diff --git a/enterprise/lib/enterprise/integrations/openai_prompts/label_suggestion.txt b/enterprise/lib/enterprise/integrations/openai_prompts/label_suggestion.txt new file mode 100644 index 000000000..6b0e436a4 --- /dev/null +++ b/enterprise/lib/enterprise/integrations/openai_prompts/label_suggestion.txt @@ -0,0 +1 @@ +Your role is as an assistant to a customer support agent. You will be provided with a transcript of a conversation between a customer and the support agent, along with a list of potential labels. Your task is to analyze the conversation and select the two labels from the given list that most accurately represent the themes or issues discussed. Ensure you preserve the exact casing of the labels as they are provided in the list. Do not create new labels; only choose from those provided. Once you have made your selections, please provide your response as a comma-separated list of the provided labels. Remember, your response should only contain the labels you\'ve selected,in their original casing, and nothing else. \ No newline at end of file diff --git a/enterprise/lib/enterprise/integrations/openai_prompts/summary.txt b/enterprise/lib/enterprise/integrations/openai_prompts/summary.txt new file mode 100644 index 000000000..5196f5b1b --- /dev/null +++ b/enterprise/lib/enterprise/integrations/openai_prompts/summary.txt @@ -0,0 +1,28 @@ +As an AI-powered summarization tool, your task is to condense lengthy interactions between customer support agents and customers into brief, digestible summaries. The objective of these summaries is to provide a quick overview, enabling any agent, even those without prior context, to grasp the essence of the conversation promptly. + +Make sure you strongly adhere to the following rules when generating the summary + +1. Be brief and concise. The shorter the summary the better. +2. Aim to summarize the conversation in approximately 200 words, formatted as multiple small paragraphs that are easier to read. +3. Describe the customer intent in around 50 words. +4. Remove information that is not directly relevant to the customer's problem or the agent's solution. For example, personal anecdotes, small talk, etc. +5. Don't include segments of the conversation that didn't contribute meaningful content, like greetings or farewell. +6. The 'Action Items' should be a bullet list, arranged in order of priority if possible. +7. 'Action Items' should strictly encapsulate tasks committed to by the agent or left incomplete. Any suggestions made by the agent should not be included. +8. The 'Action Items' should be brief and concise +9. Mark important words or parts of sentences as bold. +10. Apply markdown syntax to format any included code, using backticks. +11. Include a section for "Follow-up Items" or "Open Questions" if there are any unresolved issues or outstanding questions. +12. If any section does not have any content, remove that section and the heading from the response +13. Do not insert your own opinions about the conversation. + + +Reply in the user's language, as a markdown of the following format. + +**Customer Intent** + +**Conversation Summary** + +**Action Items** + +**Follow-up Items** \ No newline at end of file