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.
model = server.models.get('existing_model')agent = server.agents.create('demo_agent', model)
Furthermore, you can list all existing agents, get agents by name, update agents, and delete agents.
Copy
Ask AI
# list all agentsagents = agents.list()# get an agent by nameagent = agents.get('my_agent')# update an agentnew_model = models.get('new_model')agent.model_name = new_model.namenew_skill = skills.create('new_skill', 'sql', { 'tables': ['new_table'], 'database': 'new_database' })updated_agent.skills.append(new_skill)updated_agent = agents.update('my_agent', agent)# delete an agent by nameagents.delete('my_agent')
You can add skills to an agent, providing it with data stored in databases, files, or webpages.The retrieval skill is similar to knowledge bases.
Copy
Ask AI
# add data from one or more files as skillsagent.add_file('./file_name.txt', 'file content description')agent.add_files(['./file_name.pdf', './file_name.pdf', ...], 'files content description')# add data from one or more webpages as skillsagent.add_webpages(['example1.com', 'example2.com', ...], 'webpages content description')
The text2SQL skill retrieves relevant information from databases.
Copy
Ask AI
# add data from a database connected to mindsdb as skillsdb = server.databases.create('datasource_name', 'engine_name', {'database': 'db.db_name'})db = server.databases.get('datasource_name')agent.add_database(db.name, ['table_name'], 'data description')
import mindsdb_sdkcon = mindsdb_sdk.connect()# IMPORTANT: This code requires to set OPENAI_API_KEY as env variableagent = con.agents.create(f'new_demo_agent')print('Adding Hooblyblob details...')agent.add_file('./hooblyblob.txt', 'Details about the company Hooblyblob')print('Adding rulebook details...')agent.add_files(['./codenames-rulebook.pdf'], 'Rulebooks for various board games')print('Adding MindsDB docs...')agent.add_webpages(['docs.mindsdb.com'], 'Documentation for MindsDB')print('Agent ready to use.')while True: print('Ask a question: ') question = input() answer = agent.completion([{'question': question, 'answer': None}]) print(answer.content)