Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing pluginName sendMessage() in AIService #527

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading