AI Agents with LLMs and Skills

With MindsDB, you can create and deploy AI agents that comprise AI models and customizable skills such as knowledge bases and text-to-SQL.

AI agents comprise of skills, such as text2sql and knowledge_base, and a conversational model.

  • Skills provide data resources to an agent, enabling it to answer questions about available data. Learn more about skills here. Learn more about knowledge bases here.

  • A conversational model (like OpenAI) from LangChain utilizes tools as skills to respond to user input. Users can customize these models with their own prompts to fit their use cases.

Syntax and Example

Creating an agent

Agent testAgent = server.agents.create("test_agent");

Or create agent with model and prompt_template

Agent sarcasticAgent = server.agents.create("sarcastic_agent", "llama3", null, null, Map.of(
    "prompt_template", "Answer user's question sarcastically {{question}}"
));

Or use an existing model:

Agent sarcasticAgent = server.agents.get("sarcastic_agent");

Furthermore, you can list all existing agents, get agents by name, update agents, and delete agents.

package mindsdb;

import java.util.List;
import java.util.Map;

import mindsdb.models.Model;
import mindsdb.models.agent.Agent;
import mindsdb.models.skill.Skill;
import mindsdb.services.Agents;
import mindsdb.services.Models;
import mindsdb.services.Server;
import mindsdb.services.Skills;

public class Main {
    public static void main(String[] args) {
        Server server = MindsDB.connect();
        Agents agents = server.agents;
        Models models = server.getModels();
        Skills skills = server.getSkills();

        // List all agents
        List<Agent> agentList = agents.list();

        // Get an agent by name
        Agent agent = agents.get("my_agent");

        // Update an agent
        Model newModel = models.getModel("new_model");
        agent.setModelName(newModel.getName());
        Skill newSkill = skills.create("new_skill", "sql", Map.of("tables", List.of("new_table"), "database", "new_database"));
        agent.getSkills().add(newSkill);
        agents.update("my_agent", agent);

        // Delete an agent by name
        agents.drop("my_agent");
    } 
    
}
Updated on