Merge branch 'feat/CW-5648' into feat/CW-6153

This commit is contained in:
Shivam Mishra
2025-12-16 17:16:48 +05:30
committed by GitHub
7 changed files with 11 additions and 23 deletions
@@ -30,18 +30,12 @@ class OpenAIAPI extends ApiClient {
'reply_suggestion',
'label_suggestion',
];
/**
* The message events supported by the API.
* @type {string[]}
*/
this.message_events = ['rephrase'];
}
/**
* Processes an event using the OpenAI API.
* @param {Object} options - The options for the event.
* @param {string} [options.type='rephrase'] - The type of event to process.
* @param {string} [options.type='improve'] - The type of event to process.
* @param {string} [options.content] - The content of the event.
* @param {string} [options.tone] - The tone of the event.
* @param {string} [options.conversationId] - The ID of the conversation to process the event for.
@@ -50,7 +44,7 @@ class OpenAIAPI extends ApiClient {
* @returns {Promise} A promise that resolves with the result of the event processing.
*/
processEvent(
{ type = 'rephrase', content, tone, conversationId, hookId },
{ type = 'improve', content, tone, conversationId, hookId },
signal
) {
/**
@@ -48,7 +48,7 @@ export default {
this.$emit('close');
},
async generateAIContent(type = 'rephrase') {
async generateAIContent(type = 'improve') {
this.isGenerating = true;
this.generatedContent = await this.processEvent(type);
this.isGenerating = false;
@@ -163,10 +163,7 @@ const handleMenuItemClick = item => {
};
const handleSubMenuItemClick = (parentItem, subItem) => {
emit('executeCopilotAction', subItem.key, {
parentKey: parentItem.key,
tone: subItem.label.toLowerCase(),
});
emit('executeCopilotAction', subItem.key);
};
</script>
@@ -191,12 +191,12 @@ const imageUpload = useTemplateRef('imageUpload');
const editor = useTemplateRef('editor');
const handleCopilotAction = actionKey => {
if (actionKey === 'rephrase_selection' && editorView?.state) {
if (actionKey === 'improve_selection' && editorView?.state) {
const { from, to } = editorView.state.selection;
const selectedText = editorView.state.doc.textBetween(from, to).trim();
if (from !== to && selectedText) {
emit('executeCopilotAction', 'rephrase', selectedText);
emit('executeCopilotAction', 'improve', selectedText);
}
} else {
emit('executeCopilotAction', actionKey);
@@ -157,18 +157,14 @@ export function useAI() {
};
/**
* Processes an AI event, such as rephrasing content.
* @param {string} [type='rephrase'] - The type of AI event to process.
* Processes an AI event, such as improving content.
* @param {string} [type='improve'] - The type of AI event to process.
* @param {string} [content=''] - The content to process (for full message) or selected text (for selection-based).
* @param {Object} [options={}] - Additional options.
* @param {AbortSignal} [options.signal] - AbortSignal to cancel the request.
* @returns {Promise<string>} The generated message or an empty string if an error occurs.
*/
const processEvent = async (
type = 'rephrase',
content = '',
options = {}
) => {
const processEvent = async (type = 'improve', content = '', options = {}) => {
try {
const result = await EditorAPI.processEvent(
{
@@ -55,7 +55,7 @@ export function useCopilotReply() {
}
/**
* Executes a copilot action (e.g., rephrase, fix grammar).
* Executes a copilot action (e.g., improve, fix grammar).
* @param {string} action - The action type
* @param {string} data - The content to process
*/
@@ -88,6 +88,7 @@ export const OPEN_AI_EVENTS = Object.freeze({
SUMMARIZE: 'OpenAI: Used summarize',
REPLY_SUGGESTION: 'OpenAI: Used reply suggestion',
REPHRASE: 'OpenAI: Used rephrase',
IMPROVE: 'OpenAI: Used improve',
FIX_SPELLING_AND_GRAMMAR: 'OpenAI: Used fix spelling and grammar',
SHORTEN: 'OpenAI: Used shorten',
EXPAND: 'OpenAI: Used expand',