Skip to content

Commit

Permalink
Add missing pluginName sendMessage() in AIService
Browse files Browse the repository at this point in the history
  • Loading branch information
Aboubakar authored and Zorin95670 committed Sep 26, 2024
1 parent a37ac62 commit f9871c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/drawer/AIChatDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async function submit(event) {
props.pluginName,
files,
);
const aiMessage = await sendMessage(aiConversation.id, formattedText);
const aiMessage = await sendMessage(aiConversation.id, props.pluginName, formattedText);
lastAIMessage.value = {
isMine: false,
Expand Down
5 changes: 3 additions & 2 deletions src/services/AIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ export async function manageConversation(project, diagram, plugin, files) {
/**
* Send Message to AI and get its answers.
* @param {string} conversationId - Id of conversation.
* @param {string} pluginName - Plugin name.
* @param {string} message - Message to send.
* @returns {Promise<object>} Answer of AI.
*/
export async function sendMessage(conversationId, message) {
export async function sendMessage(conversationId, pluginName, message) {
const api = await prepareApiRequest();

return api.post(`/ai/conversations/${conversationId}/messages`, message, options)
return api.post(`/ai/conversations/${conversationId}/messages`, { plugin: pluginName, message }, options)
.then((data) => ({
...data,
message: uncompress(data.message),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/services/AIService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('AI Service tests', () => {
}));
prepareApiRequest.mockImplementation(() => Promise.resolve(api));

const result = await sendMessage('1', 'test');
const result = await sendMessage('1', 'plugin', 'test');

expect(result.message).toEqual('OK');
});
Expand Down

0 comments on commit f9871c9

Please sign in to comment.