Class Agents

java.lang.Object
mindsdb.services.Agents

public class Agents extends Object
The `Agents` class provides methods to manage agents within a MindsDB project. It allows for creating, updating, listing, and deleting agents, as well as adding files, web pages, and databases to agents. The class interacts with various components such as knowledge bases, models, skills, databases, and machine learning engines to facilitate these operations.

Key functionalities include:

  • Listing all agents in a project
  • Retrieving a specific agent by name
  • Creating new agents with specified models, providers, skills, and parameters
  • Updating existing agents
  • Deleting agents
  • Adding files, web pages, and databases to agents
  • Validating URLs

The class relies on the `RestAPI` for communication with the MindsDB backend and uses various models such as `Agent`, `AgentCompletion`, `KnowledgeBase`, `Model`, `Project`, `Skill`, and `Database` to represent and manipulate data.

Example usage:


 Project project = new Project("project_name");
 RestAPI api = new RestAPI("api_url");
 Agents agentsService = new Agents(project, api);
 
 // List all agents
 List<Agent> agents = agentsService.list();
 
 // Create a new agent
 Agent newAgent = agentsService.create("agent_name", "model_name", "provider_name", skills, params);
 
 // Add a file to an agent
 agentsService.addFile("agent_name", "file_path", "file_description", "knowledge_base_name");
 
See Also:
  • Constructor Details

    • Agents

      public Agents(Project project, RestAPI api)
      Constructor for the `Agents` class.
      Parameters:
      project - - Project object
      api - - RestAPI object
  • Method Details

    • list

      public List<Agent> list()
      List all agents
      Returns:
      List of agents
    • get

      public Agent get(String name)
      Get an agent by name
      Parameters:
      name - Name of the agent
      Returns:
      Agent
    • completion

      public AgentCompletion completion(String name, List<com.google.gson.JsonObject> messages)
      Get the completion of an agent
      Parameters:
      name - - Name of the agent
      messages - - List of messages
      Returns:
      AgentCompletion object
    • addFiles

      public void addFiles(String name, List<String> filePaths, String description, String knowledgeBase)
      Add files to an agent
      Parameters:
      name - - Name of the agent
      filePaths - - List of file paths
      description - - Description of the files
      knowledgeBase - - Name of the knowledge base
    • addFile

      public void addFile(String name, String filePath, String description, String knowledgeBase)
      Add a file to an agent
      Parameters:
      name - - Name of the agent
      filePath - - File path
      description - - Description of the file
      knowledgeBase - - Name of the knowledge base
    • addWebPages

      public void addWebPages(String name, List<String> urls, String description, String knowledgeBase, Integer crawlDepth, List<String> filters)
      Add web pages to an agent
      Parameters:
      name - - Name of the agent
      urls - - List of URLs
      description - - Description of the web pages
      knowledgeBase - - Name of the knowledge base
      crawlDepth - - Crawl depth
      filters - - List of filters
    • addWebPage

      public void addWebPage(String name, String url, String description, String knowledgeBase, Integer crawlDepth, List<String> filters)
      Add a web page to an agent
      Parameters:
      name - - Name of the agent
      url - - URL
      description - - Description of the web page
      knowledgeBase - - Name of the knowledge base
      crawlDepth - - Crawl depth
      filters - - List of filters
    • addDatabase

      public void addDatabase(String name, String database, List<String> tables, String description)
      Add databases to an agent
      Parameters:
      name - - Name of the agent
      database - - Name of the database
      tables - - List of tables
      description - - Description of the database
    • create

      public Agent create(String name, String model, String provider, List<String> skills, Map<String,Object> params)
      Create an agent
      Parameters:
      name - - Name of the agent
      model - - Model name
      provider - - Provider
      skills - - List of skills
      params - - Parameters
      Returns:
      Agent
    • create

      public Agent create(String name)
      Create an agent
      Parameters:
      name - - Name of the agent
      Returns:
      Agent
    • update

      public void update(String name, Agent updatedAgent)
      Update an agent
      Parameters:
      name - - Name of the agent
      updatedAgent - - Updated agent
    • drop

      public void drop(String name)
      Drop an agent
      Parameters:
      name - Name of the agent