Merge branch 'main' into 587-issue---refactor-delete-dialog-logic

This commit is contained in:
yassinedorbozgithub
2025-01-23 10:14:16 +01:00
10 changed files with 91 additions and 39 deletions

4
api/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "hexabot",
"version": "2.2.0",
"version": "2.2.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hexabot",
"version": "2.2.0",
"version": "2.2.1",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "hexabot",
"version": "2.2.0",
"version": "2.2.1",
"description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.",
"author": "Hexastack",
"license": "AGPL-3.0-only",

View File

@@ -110,7 +110,7 @@ export class BlockController extends BaseController<
throw new NotFoundException('Plugin Not Found');
}
return plugin.settings;
return plugin.getDefaultSettings();
} catch (e) {
this.logger.error('Unable to fetch plugin settings', e);
throw e;
@@ -134,7 +134,7 @@ export class BlockController extends BaseController<
...p.template,
message: {
plugin: p.name,
args: p.settings.reduce(
args: p.getDefaultSettings().reduce(
(acc, setting) => {
acc[setting.label] = setting.value;
return acc;

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
@@ -10,7 +10,9 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
import { Test, TestingModule } from '@nestjs/testing';
import { I18nService } from '@/i18n/services/i18n.service';
import { BasePlugin } from '@/plugins/base-plugin.service';
import { PluginService } from '@/plugins/plugins.service';
import { PluginBlockTemplate } from '@/plugins/types';
import { SettingType } from '@/setting/schemas/types';
import { SettingService } from '@/setting/services/setting.service';
@@ -157,26 +159,56 @@ describe('TranslationService', () => {
attachedBlock: null,
};
const mockedPlugin: any = {
name: 'ollama-plugin',
type: 'block',
settings: [
{
label: 'model',
group: 'default',
type: SettingType.text,
value: 'llama3.2',
translatable: false,
},
{
label: 'context',
group: 'default',
type: SettingType.multiple_text,
value: ['Answer the user QUESTION using the DOCUMENTS text above.'],
translatable: true,
},
],
};
class MockPlugin extends BasePlugin {
template: PluginBlockTemplate = { name: 'Ollama Plugin' };
name: `${string}-plugin`;
type: any;
private settings: {
label: string;
group: string;
type: SettingType;
value: any;
translatable: boolean;
}[];
constructor() {
super('ollama-plugin', pluginService);
this.name = 'ollama-plugin';
this.type = 'block';
this.settings = [
{
label: 'model',
group: 'default',
type: SettingType.text,
value: 'llama3.2',
translatable: false,
},
{
label: 'context',
group: 'default',
type: SettingType.multiple_text,
value: ['Answer the user QUESTION using the DOCUMENTS text above.'],
translatable: true,
},
];
}
// Implementing the 'getPath' method (with a mock return value)
getPath() {
// Return a mock path
return '/mock/path';
}
getDefaultSettings() {
return this.settings;
}
}
// Create an instance of the mock plugin
const mockedPlugin = new MockPlugin();
jest
.spyOn(pluginService, 'getPlugin')

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
@@ -59,7 +59,9 @@ export class TranslationService extends BaseService<Translation> {
// plugin
Object.entries(block.message.args).forEach(([l, arg]) => {
const setting = plugin?.settings.find(({ label }) => label === l);
const setting = plugin
?.getDefaultSettings()
.find(({ label }) => label === l);
if (setting?.translatable) {
if (Array.isArray(arg)) {
// array of text

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
@@ -30,7 +30,7 @@ export abstract class BaseBlockPlugin<
> extends BasePlugin {
public readonly type: PluginType = PluginType.block;
public readonly settings: T;
private readonly settings: T;
constructor(name: PluginName, pluginService: PluginService<BasePlugin>) {
super(name, pluginService);
@@ -38,6 +38,10 @@ export abstract class BaseBlockPlugin<
this.settings = require(path.join(this.getPath(), 'settings')).default;
}
getDefaultSettings(): T {
return this.settings;
}
abstract template: PluginBlockTemplate;
effects?: PluginEffects;
@@ -50,8 +54,22 @@ export abstract class BaseBlockPlugin<
protected getArguments(block: Block) {
if ('args' in block.message) {
return block.message.args as SettingObject<T>;
return (
Object.entries(block.message.args)
// Filter out old settings
.filter(
([argKey]) =>
this.settings.findIndex(({ label }) => label === argKey) !== -1,
)
.reduce(
(acc, [k, v]) => ({
...acc,
[k]: v,
}),
{} as SettingObject<T>,
)
);
}
throw new Error(`Block "${block.name}" does not have any arguments.`);
throw new Error(`Block ${block.name} does not have any arguments.`);
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "hexabot-ui",
"private": true,
"version": "2.2.0",
"version": "2.2.1",
"description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.",
"author": "Hexastack",
"license": "AGPL-3.0-only",

8
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "hexabot",
"version": "2.1.9",
"version": "2.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hexabot",
"version": "2.1.9",
"version": "2.2.0",
"license": "AGPL-3.0-only",
"workspaces": [
"frontend",
@@ -45,7 +45,7 @@
},
"frontend": {
"name": "hexabot-ui",
"version": "2.2.0",
"version": "2.2.1",
"license": "AGPL-3.0-only",
"dependencies": {
"@chatscope/chat-ui-kit-react": "^2.0.3",
@@ -10304,7 +10304,7 @@
},
"widget": {
"name": "hexabot-chat-widget",
"version": "2.2.0",
"version": "2.2.1",
"license": "AGPL-3.0-only",
"dependencies": {
"@types/emoji-js": "^3.5.2",

View File

@@ -5,7 +5,7 @@
"frontend",
"widget"
],
"version": "2.2.0",
"version": "2.2.1",
"description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.",
"author": "Hexastack",
"license": "AGPL-3.0-only",

View File

@@ -1,6 +1,6 @@
{
"name": "hexabot-chat-widget",
"version": "2.2.0",
"version": "2.2.1",
"description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.",
"author": "Hexastack",
"license": "AGPL-3.0-only",