Package mindsdb.services
Class Agents
java.lang.Object
mindsdb.services.Agents
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");
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add databases to an agentvoid
Add a file to an agentvoid
Add files to an agentvoid
addWebPage
(String name, String url, String description, String knowledgeBase, Integer crawlDepth, List<String> filters) Add a web page to an agentvoid
addWebPages
(String name, List<String> urls, String description, String knowledgeBase, Integer crawlDepth, List<String> filters) Add web pages to an agentcompletion
(String name, List<com.google.gson.JsonObject> messages) Get the completion of an agentCreate an agentCreate an agentvoid
Drop an agentGet an agent by namelist()
List all agentsvoid
Update an agent
-
Constructor Details
-
Agents
Constructor for the `Agents` class.- Parameters:
project
- - Project objectapi
- - RestAPI object
-
-
Method Details
-
list
List all agents- Returns:
- List of agents
-
get
Get an agent by name- Parameters:
name
- Name of the agent- Returns:
- Agent
-
completion
Get the completion of an agent- Parameters:
name
- - Name of the agentmessages
- - List of messages- Returns:
- AgentCompletion object
-
addFiles
Add files to an agent- Parameters:
name
- - Name of the agentfilePaths
- - List of file pathsdescription
- - Description of the filesknowledgeBase
- - Name of the knowledge base
-
addFile
Add a file to an agent- Parameters:
name
- - Name of the agentfilePath
- - File pathdescription
- - Description of the fileknowledgeBase
- - 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 agenturls
- - List of URLsdescription
- - Description of the web pagesknowledgeBase
- - Name of the knowledge basecrawlDepth
- - Crawl depthfilters
- - 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 agenturl
- - URLdescription
- - Description of the web pageknowledgeBase
- - Name of the knowledge basecrawlDepth
- - Crawl depthfilters
- - List of filters
-
addDatabase
Add databases to an agent- Parameters:
name
- - Name of the agentdatabase
- - Name of the databasetables
- - List of tablesdescription
- - 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 agentmodel
- - Model nameprovider
- - Providerskills
- - List of skillsparams
- - Parameters- Returns:
- Agent
-
create
Create an agent- Parameters:
name
- - Name of the agent- Returns:
- Agent
-
update
Update an agent- Parameters:
name
- - Name of the agentupdatedAgent
- - Updated agent
-
drop
Drop an agent- Parameters:
name
- Name of the agent
-