diff --git a/src/agents/agent.ts b/src/agents/agent.ts index 9928971..400af97 100644 --- a/src/agents/agent.ts +++ b/src/agents/agent.ts @@ -14,8 +14,6 @@ export default class Agent { name: string; /** Model name */ model: string; - /** Skills of the agent */ - skills: Array; /** Additional parameters */ params: any; /** Rest API client to use for executing agent operations */ @@ -27,7 +25,6 @@ export default class Agent { * @param {string} project - Project name to which agent belongs to * @param {string} name - Agent name * @param {string} model - Model name - * @param {Array} skills - Skills of the agent * @param {any} params - Additional parameters * @param {AgentsRestApiClient} agentsRestApiClient - Rest API client to use for executing agent operations */ @@ -35,14 +32,12 @@ export default class Agent { project: string, name: string, model: string, - skills: Array, params: any, agentsRestApiClient: AgentsRestApiClient ) { this.project = project; this.name = name; this.model = model; - this.skills = skills; this.params = params; this.agentsRestApiClient = agentsRestApiClient; } @@ -64,7 +59,6 @@ export default class Agent { project, json.name, json.model, - json.skills.map((skill: any) => skill.name), json.params || {}, agentsRestApiClient ); diff --git a/src/agents/agentsApiClient.ts b/src/agents/agentsApiClient.ts index ee90c6e..eb910d3 100644 --- a/src/agents/agentsApiClient.ts +++ b/src/agents/agentsApiClient.ts @@ -27,7 +27,6 @@ export default abstract class AgentsApiClient { * @param {string} name - The name of the agent. * @param {string} model - The model of the agent. * @param {string} provider - The provider of the agent. - * @param {Array} skills - An array of skills for the agent. * @param {any} [params] - Optional parameters for the agent. * @throws {MindsDbError} If the agent cannot be created. * @returns {Promise} A promise that resolves to the created agent. @@ -37,7 +36,6 @@ export default abstract class AgentsApiClient { name: string, model: string, provider: string, - skills: Array, params?: any ): Promise; @@ -47,7 +45,6 @@ export default abstract class AgentsApiClient { * @param {string} agentName - The current name of the agent. * @param {string} [updatedName] - The new name of the agent (optional). * @param {string} [updatedModel] - The new model of the agent (optional). - * @param {Array} [updatedSkills] - An array of updated skills for the agent (optional). * @param {any} [updatedParams] - Optional updated parameters for the agent. * @throws {MindsDbError} If the agent cannot be updated. * @returns {Promise} A promise that resolves to the updated agent. @@ -57,7 +54,6 @@ export default abstract class AgentsApiClient { agentName: string, updatedName?: string, updatedModel?: string, - updatedSkills?: Array, updatedParams?: any ): Promise; diff --git a/src/agents/agentsRestApiClient.ts b/src/agents/agentsRestApiClient.ts index cb9a583..269fff4 100644 --- a/src/agents/agentsRestApiClient.ts +++ b/src/agents/agentsRestApiClient.ts @@ -75,7 +75,6 @@ export default class AgentsRestApiClient extends AgentsApiClient { * @param {string} name Agent name to create * @param {string} [model] Model to use for the agent * @param {string} [provider] Provider to use for the agent - * @param {Array} [skills] Skills to assign to the agent * @param {any} [params] Additional parameters for the agent * @returns {Promise} A promise that resolves to the created agent. */ @@ -84,7 +83,6 @@ export default class AgentsRestApiClient extends AgentsApiClient { name: string, model?: string, provider?: string, - skills?: Array, params?: any ): Promise { const agentsUrl = this.getAgentsUrl(project); @@ -98,13 +96,11 @@ export default class AgentsRestApiClient extends AgentsApiClient { const agent: { name: string; model_name?: string; - skills?: Array; params?: any; provider?: string | null; } = { name: name, model_name: model || DEFAULT_LLM_MODEL, - skills: skills || [], provider: provider || null, params: agentsParams, }; @@ -124,7 +120,6 @@ export default class AgentsRestApiClient extends AgentsApiClient { * @param {string} agentName Name of the agent to update * @param {string} [updatedName] New name for the agent * @param {string} [updatedModel] New model for the agent - * @param {Array} [updatedSkills] New skills for the agent * @param {any} [updatedParams] New parameters for the agent * @returns {Promise} A promise that resolves to the updated agent. */ @@ -133,41 +128,19 @@ export default class AgentsRestApiClient extends AgentsApiClient { agentName: string, updatedName?: string, updatedModel?: string, - updatedSkills?: Array, updatedParams?: any ): Promise { const agentsUrl = this.getAgentsUrl(project) + `/${agentName}`; try { const agent = await this.getAgent(project, agentName); - const updatedSkillSet = new Set(); - if (updatedSkills) { - updatedSkills?.forEach((skill) => updatedSkillSet.add(skill)); - } - const existingSkillSet = new Set(agent.skills); - const skillsToAddSet = new Set(updatedSkillSet); - existingSkillSet.forEach((skill) => { - if (skillsToAddSet.has(skill)) { - skillsToAddSet.delete(skill); - } - }); - const skillsToRemoveSet = new Set(existingSkillSet); - updatedSkillSet.forEach((skill) => { - if (skillsToRemoveSet.has(skill)) { - skillsToRemoveSet.delete(skill); - } - }); const updatedAgent: { name: string; model_name: string; - skills_to_add: Array; - skills_to_remove: Array; params: any; } = { name: updatedName || agent.name, model_name: updatedModel || agent.model, - skills_to_add: Array.from(skillsToAddSet), - skills_to_remove: Array.from(skillsToRemoveSet), params: updatedParams || agent.params, }; diff --git a/src/index.ts b/src/index.ts index d8222c4..432ae1e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,6 @@ import { import TablesModule from './tables/tablesModule'; import knowledgeBaseModule from './knowledge_bases/knowledge_baseModule'; import AgentsModule from './agents/agentsModule'; -import skillsModule from './skills/skillsModule'; import HttpAuthenticator from './httpAuthenticator'; import { Axios } from 'axios'; @@ -67,7 +66,6 @@ const KnowledgeBases = new knowledgeBaseModule.KnowledgeBaseRestApiClient( defaultAxiosInstance ); const Agents = new AgentsModule.AgentsRestApiClient(defaultAxiosInstance); -const Skills = new skillsModule.SkillsRestApiClient(defaultAxiosInstance); const Callbacks = new CallbacksModule.CallbacksRestApiClient( defaultAxiosInstance, @@ -135,7 +133,6 @@ export default { Agents, Callbacks, KnowledgeBases, - Skills, }; export { ConnectionOptions, diff --git a/src/skills/skill.ts b/src/skills/skill.ts deleted file mode 100644 index fd09d6b..0000000 --- a/src/skills/skill.ts +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Parameters for SQL skills. - * - * @property {string} database - The name of the database. - * @property {string[]} tables - The list of tables. - * @property {string} [description] - Optional description of the skill. - */ -export interface SQLSkillParams { - database: string; - tables: string[]; - description?: string; -} - -/** - * Parameters for Retrieval skills. - * - * @property {string} source - The source of the data. - * @property {string} [description] - Optional description of the skill. - */ -export interface RetrievalSkillParams { - source: string; - description?: string; -} - -/** - * Union type for skill parameters. - */ -export type SkillParams = SQLSkillParams | RetrievalSkillParams; - -/** - * Represents a generic skill. - * - * @property {string} name - The name of the skill. - * @property {string} type - The type of the skill. - * @property {string} project - The project associated with the skill. - * @property {SkillParams} params - The parameters of the skill. - */ -export default class Skill { - name: string; - type: string; - project: string; - params: SkillParams; - - /** - * Creates an instance of Skill. - * - * @param {string} name - The name of the skill. - * @param {string} type - The type of the skill. - * @param {string} project - The project associated with the skill. - * @param {SkillParams} params - The parameters of the skill. - */ - constructor( - name: string, - type: string, - project: string, - params: SkillParams - ) { - this.name = name; - this.type = type; - this.project = project; - this.params = params; - } - - /** - * Creates a Skill instance from a JSON object. - * - * @param {string} project - The project associated with the skill. - * @param {any} json - The JSON object containing skill data. - * @returns {Skill} The created Skill instance. - */ - static fromJson(project: string, json: any): Skill { - const { name, type, params } = json; - if (type === 'sql') { - return new SQLSkill( - name, - params.tables, - params.database, - params.description - ); - } else if (type === 'retrieval') { - return new RetrievalSkill(name, params.source, params.description); - } - return new Skill(name, type, project, params); - } - - /** - * Checks if this skill is equal to another skill. - * - * @param {Skill} other - The other skill to compare with. - * @returns {boolean} True if the skills are equal, false otherwise. - */ - equals(other: Skill): boolean { - return ( - this.name === other.name && - this.type === other.type && - JSON.stringify(this.params) === JSON.stringify(other.params) - ); - } - - /** - * Returns a string representation of the skill. - * - * @returns {string} The string representation of the skill. - */ - toString(): string { - return `${this.constructor.name}(name: ${this.name})`; - } -} - -/** - * Represents a SQL skill. - */ -export class SQLSkill extends Skill { - /** - * Creates an instance of SQLSkill. - * - * @param {string} name - The name of the skill. - * @param {string[]} tables - The list of tables. - * @param {string} database - The name of the database. - * @param {string} project - The project associated with the skill. - * @param {string} [description] - Optional description of the skill. - */ - constructor( - name: string, - tables: string[], - database: string, - project: string, - description?: string - ) { - const params: SQLSkillParams = { database, tables, description }; - super(name, 'sql', project, params); - } -} - -/** - * Represents a Retrieval skill. - */ -export class RetrievalSkill extends Skill { - /** - * Creates an instance of RetrievalSkill. - * - * @param {string} name - The name of the skill. - * @param {string} project - The project associated with the skill. - * @param {string} source - The source of the data. - * @param {string} [description] - Optional description of the skill. - */ - constructor( - name: string, - project: string, - source: string, - description?: string - ) { - const params: RetrievalSkillParams = { source, description }; - super(name, 'retrieval', project, params); - } -} diff --git a/src/skills/skillsApiClient.ts b/src/skills/skillsApiClient.ts deleted file mode 100644 index 15310dc..0000000 --- a/src/skills/skillsApiClient.ts +++ /dev/null @@ -1,58 +0,0 @@ -import Skill, { SkillParams } from './skill'; - -/** - * An abstract class representing the API client for managing skills. - * This class provides methods to interact with skills in a specific project. - */ -export default abstract class SkillsApiClient { - /** - * Retrieves all skills associated with a given project. - * @param project - The name of the project. - * @returns A promise that resolves to an array of skills. - */ - abstract getAllSkills(project: string): Promise>; - - /** - * Retrieves a specific skill by name within a given project. - * @param name - The name of the skill. - * @param project - The name of the project. - * @returns A promise that resolves to the skill. - */ - abstract getSkill(name: string, project: string): Promise; - - /** - * Creates a new skill within a given project. - * @param name - The name of the skill. - * @param type - The type of the skill. - * @param project - The name of the project. - * @param params - The parameters for the skill. - * @returns A promise that resolves to the created skill. - */ - abstract createSkill( - name: string, - type: string, - project: string, - params: SkillParams - ): Promise; - - /** - * Updates an existing skill within a given project. - * @param name - The name of the skill. - * @param project - The name of the project. - * @param updatedSkill - The updated skill object. - * @returns A promise that resolves to the updated skill. - */ - abstract updateSkill( - name: string, - project: string, - updatedSkill: Skill - ): Promise; - - /** - * Deletes a specific skill by name within a given project. - * @param name - The name of the skill. - * @param project - The name of the project. - * @returns A promise that resolves when the skill is deleted. - */ - abstract deleteSkill(name: string, project: string): Promise; -} diff --git a/src/skills/skillsModule.ts b/src/skills/skillsModule.ts deleted file mode 100644 index 457b76a..0000000 --- a/src/skills/skillsModule.ts +++ /dev/null @@ -1,3 +0,0 @@ -import SkillsRestApiClient from './skillsRestApiClient'; - -export default { SkillsRestApiClient }; diff --git a/src/skills/skillsRestApiClient.ts b/src/skills/skillsRestApiClient.ts deleted file mode 100644 index b7f9262..0000000 --- a/src/skills/skillsRestApiClient.ts +++ /dev/null @@ -1,128 +0,0 @@ -import SkillsApiClient from './skillsApiClient'; -import Skill, { SkillParams, SQLSkill, SQLSkillParams } from './skill'; -import SqlApiClient from '../sql/sqlApiClient'; -import { Axios } from 'axios'; -import Constants from '../constants'; - -/** Implementation of SkillApiClient that goes through the REST API */ -export default class SkillsRestApiClient extends SkillsApiClient { - /** Axios client to send all HTTP requests. */ - client: Axios; - - /** - * - * @param {Axios} client - Axios client to send all HTTP requests. - */ - constructor(client: Axios) { - super(); - this.client = client; - } - - /** - * Retrieves all skills associated with a given project. - * - * @param {string} project - Project name skill belongs to - * @returns {Array} - Array of skills - */ - override async getAllSkills(project: string): Promise> { - const baseUrl = - this.client.defaults.baseURL || Constants.BASE_CLOUD_API_ENDPOINT; - const skillsUrl = `${baseUrl}${Constants.BASE_PROJECTS_URI}/${project}/skills`; - const response = await this.client.get(skillsUrl); - return response.data.map((skill: any) => Skill.fromJson(project, skill)); - } - - /** - * Retrieves a specific skill by name within a given project. - * - * @param name - Name of the skill. - * @param project - Name of the project. - * @returns {Skill} - The skill. - */ - override async getSkill(name: string, project: string): Promise { - const baseUrl = - this.client.defaults.baseURL || Constants.BASE_CLOUD_API_ENDPOINT; - const skillUrl = `${baseUrl}${Constants.BASE_PROJECTS_URI}/${project}/skills/${name}`; - const response = await this.client.get(skillUrl); - return Skill.fromJson(project, response.data); - } - - /** - * Creates a new skill within a given project. - * - * @param name - Name of the skill. - * @param type - Type of the skill. - * @param project - Name of the project. - * @param params - Parameters for the skill. - * @returns {Skill} - The created skill. - */ - override async createSkill( - name: string, - type: string, - project: string, - params: SkillParams - ): Promise { - const baseUrl = - this.client.defaults.baseURL || Constants.BASE_CLOUD_API_ENDPOINT; - const skillUrl = `${baseUrl}${Constants.BASE_PROJECTS_URI}/${project}/skills`; - await this.client.post(skillUrl, { - skill: { - name, - type, - params, - }, - }); - if (type === 'sql') { - const sqlParams = params as SQLSkillParams; - const sqlSkill = new SQLSkill( - name, - sqlParams.tables, - sqlParams.database, - project - ); - return sqlSkill; - } else { - return new Skill(name, type, project, params); - } - } - - /** - * Updates an existing skill within a given project. - * - * @param name - Name of the skill - * @param project - Name of the project - * @param updatedSkill - Updated skill object - * @returns {Skill} - The updated skill - */ - override async updateSkill( - name: string, - project: string, - updatedSkill: Skill - ): Promise { - const baseUrl = - this.client.defaults.baseURL || Constants.BASE_CLOUD_API_ENDPOINT; - const skillUrl = `${baseUrl}${Constants.BASE_PROJECTS_URI}/${project}/skills/${name}`; - const response = await this.client.put(skillUrl, { - skill: { - name: updatedSkill.name, - type: updatedSkill.type, - params: updatedSkill.params, - }, - }); - - return Skill.fromJson(updatedSkill.project, response.data); - } - - /** - * Deletes a specific skill by name within a given project. - * - * @param name - Name of the skill - * @param project - Name of the project - */ - override async deleteSkill(name: string, project: string): Promise { - const baseUrl = - this.client.defaults.baseURL || Constants.BASE_CLOUD_API_ENDPOINT; - const skillUrl = `${baseUrl}${Constants.BASE_PROJECTS_URI}/${project}/skills/${name}`; - await this.client.delete(skillUrl); - } -} diff --git a/tests/es6-import.test.ts b/tests/es6-import.test.ts index 795be36..d125e78 100644 --- a/tests/es6-import.test.ts +++ b/tests/es6-import.test.ts @@ -23,7 +23,6 @@ describe('Testing ES6 import compatibility', () => { expect(typeof MindsDB.Agents).toBe('object'); expect(typeof MindsDB.Callbacks).toBe('object'); expect(typeof MindsDB.KnowledgeBases).toBe('object'); - expect(typeof MindsDB.Skills).toBe('object'); }); test('should be able to import named exports using ES6 syntax', async () => {