feat(CW-6116): Reply Editor AI Changes (#13030)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com> Co-authored-by: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com> Fixes https://linear.app/chatwoot/issue/CW-5648/reply-editor-ai-changes
This commit is contained in:
@@ -30,25 +30,23 @@ 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.
|
||||
* @param {string} options.hookId - The ID of the hook to use for processing the event.
|
||||
* @param {AbortSignal} [signal] - AbortSignal to cancel the request.
|
||||
* @returns {Promise} A promise that resolves with the result of the event processing.
|
||||
*/
|
||||
processEvent({ type = 'rephrase', content, tone, conversationId, hookId }) {
|
||||
processEvent(
|
||||
{ type = 'improve', content, tone, conversationId, hookId },
|
||||
signal
|
||||
) {
|
||||
/**
|
||||
* @type {ConversationMessageData}
|
||||
*/
|
||||
@@ -69,12 +67,16 @@ class OpenAIAPI extends ApiClient {
|
||||
};
|
||||
}
|
||||
|
||||
return axios.post(`${this.url}/hooks/${hookId}/process_event`, {
|
||||
event: {
|
||||
name: type,
|
||||
data,
|
||||
return axios.post(
|
||||
`${this.url}/hooks/${hookId}/process_event`,
|
||||
{
|
||||
event: {
|
||||
name: type,
|
||||
data,
|
||||
},
|
||||
},
|
||||
});
|
||||
{ signal }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user