|
| 1 | +### [MindsDB](https://github.com/mindsdb/mindsdb) |
| 2 | + |
| 3 | +> Handle: `mindsdb`<br/> |
| 4 | +> URL: [http://localhost:34581](http://localhost:34581) |
| 5 | +
|
| 6 | + |
| 7 | + |
| 8 | +MindsDB is an AI platform that enables querying AI models using SQL. Harbor integrates MindsDB with local LLM backends (Ollama, llama.cpp, vLLM) so you can build AI-powered applications without external API dependencies. |
| 9 | + |
| 10 | +## Starting |
| 11 | + |
| 12 | +```bash |
| 13 | +# Start MindsDB with Ollama |
| 14 | +harbor up mindsdb ollama |
| 15 | + |
| 16 | +# Or with other backends |
| 17 | +harbor up mindsdb llamacpp |
| 18 | +harbor up mindsdb vllm |
| 19 | +``` |
| 20 | + |
| 21 | +## Configuration |
| 22 | + |
| 23 | +Following options can be set via [`harbor config`](./3.-Harbor-CLI-Reference.md#harbor-config): |
| 24 | + |
| 25 | +```bash |
| 26 | +# Ports |
| 27 | +HARBOR_MINDSDB_HOST_PORT 34581 |
| 28 | +HARBOR_MINDSDB_MYSQL_HOST_PORT 34582 |
| 29 | + |
| 30 | +# Docker image |
| 31 | +HARBOR_MINDSDB_IMAGE mindsdb/mindsdb |
| 32 | +HARBOR_MINDSDB_VERSION latest |
| 33 | + |
| 34 | +# Persistent storage |
| 35 | +HARBOR_MINDSDB_WORKSPACE ./mindsdb/data |
| 36 | + |
| 37 | +# APIs to expose (http, mysql, postgres) |
| 38 | +HARBOR_MINDSDB_APIS http,mysql |
| 39 | + |
| 40 | +# Authentication (optional) |
| 41 | +HARBOR_MINDSDB_USERNAME "" |
| 42 | +HARBOR_MINDSDB_PASSWORD "" |
| 43 | + |
| 44 | +# Default Ollama model for LLM() function |
| 45 | +HARBOR_MINDSDB_OLLAMA_MODEL llama3.1:8b |
| 46 | +``` |
| 47 | + |
| 48 | +## LLM Integration |
| 49 | + |
| 50 | +When running MindsDB with a Harbor LLM backend, the `LLM()` function is automatically configured: |
| 51 | + |
| 52 | +| Backend | Base URL | Model | API Key | |
| 53 | +|---------|----------|-------|---------| |
| 54 | +| Ollama | `http://ollama:11434/v1` | `HARBOR_MINDSDB_OLLAMA_MODEL` | `sk-ollama` | |
| 55 | +| llama.cpp | `http://llamacpp:8080/v1` | (loaded model) | `sk-llamacpp` | |
| 56 | +| vLLM | `http://vllm:8000/v1` | (loaded model) | `sk-vllm` | |
| 57 | + |
| 58 | +### Using LLM() Function |
| 59 | + |
| 60 | +```sql |
| 61 | +-- Text generation |
| 62 | +SELECT LLM('What is the capital of France?'); |
| 63 | + |
| 64 | +-- Process data |
| 65 | +SELECT LLM('Summarize: ' || content) FROM articles; |
| 66 | +``` |
| 67 | + |
| 68 | +### Creating Agents |
| 69 | + |
| 70 | +Agents query data sources using natural language. Specify the Harbor backend configuration: |
| 71 | + |
| 72 | +```sql |
| 73 | +CREATE AGENT mindsdb.my_agent |
| 74 | +USING |
| 75 | + model = { |
| 76 | + "provider": "ollama", |
| 77 | + "model_name": "llama3.1:8b", |
| 78 | + "api_key": "sk-ollama", |
| 79 | + "base_url": "http://ollama:11434" |
| 80 | + }, |
| 81 | + data = { |
| 82 | + "tables": ["my_database.my_table"] |
| 83 | + }; |
| 84 | +``` |
| 85 | + |
| 86 | +### Creating ML Engines |
| 87 | + |
| 88 | +Create ML engines to use Harbor backends in models: |
| 89 | + |
| 90 | +```sql |
| 91 | +-- Ollama engine |
| 92 | +CREATE ML_ENGINE ollama_engine |
| 93 | +FROM ollama |
| 94 | +USING |
| 95 | + ollama_serve_url = 'http://ollama:11434'; |
| 96 | + |
| 97 | +-- llama.cpp (OpenAI-compatible) |
| 98 | +CREATE ML_ENGINE llamacpp_engine |
| 99 | +FROM openai |
| 100 | +USING |
| 101 | + openai_api_base = 'http://llamacpp:8080/v1', |
| 102 | + openai_api_key = 'sk-llamacpp'; |
| 103 | + |
| 104 | +-- vLLM (OpenAI-compatible) |
| 105 | +CREATE ML_ENGINE vllm_engine |
| 106 | +FROM openai |
| 107 | +USING |
| 108 | + openai_api_base = 'http://vllm:8000/v1', |
| 109 | + openai_api_key = 'sk-vllm'; |
| 110 | +``` |
| 111 | + |
| 112 | +> **Note**: The `LLM()` function configuration is separate from the "Default MindsDB Configuration" UI settings. UI settings (Settings → Models) are for agents/knowledge bases and persist in `./mindsdb/data`. |
| 113 | +
|
| 114 | +## Connecting to Harbor Services |
| 115 | + |
| 116 | +Use Docker network hostnames to connect MindsDB to other Harbor services: |
| 117 | + |
| 118 | +```sql |
| 119 | +-- Connect to a database running in Harbor |
| 120 | +CREATE DATABASE harbor_postgres |
| 121 | +WITH ENGINE = 'postgres', |
| 122 | +PARAMETERS = { |
| 123 | + "host": "postgres", |
| 124 | + "port": "5432", |
| 125 | + "database": "mydb", |
| 126 | + "user": "user", |
| 127 | + "password": "password" |
| 128 | +}; |
| 129 | +``` |
| 130 | + |
| 131 | +## MySQL API |
| 132 | + |
| 133 | +Connect to MindsDB using MySQL clients for BI tools and integrations: |
| 134 | + |
| 135 | +```bash |
| 136 | +mysql -h 127.0.0.1 -P 34582 |
| 137 | +``` |
0 commit comments