### [SQL Chat](https://github.com/sqlchat/sqlchat)

> Handle: `sqlchat`<br/>
> URL: [http://localhost:34351](http://localhost:34351)

![SQL Chat screenshot](sqlchat.png)

SQL Chat is a chat-based SQL client, which uses natural language to communicate with the database to implement operations such as query, modification, addition, and deletion of the database.

#### Starting

```bash
# [Optional] Pre-pull the image
harbor pull sqlchat

# SQL Chat relies on OpenAI-compatible model IDs
# So to use with Ollama, model needs to be named accordingly
harbor ollama cp llama3.1:8b gpt-3.5-turbo
# Start the service [--open is optional, to open in browser]
harbor up sqlchat --open

# [Optional] Open the URL in your browser
harbor open sqlchat
# [Optional] See service logs
harbor logs sqlchat
```

See [troubleshooting guide](./1.-Harbor-User-Guide.md#troubleshooting) if you encounter any issues.

#### Usage

- Harbor will pre-configure `sqlchat` to use Ollama as OpenAI-compatible backend when started together
- Connection settings for SQL Chat are stored in the browser, so you won't be able to pre-configure them via Harbor
- When configuring a connection - `sqlchat` runs within docker, so `localhost` will refer to the docker container, not your host machine
  - On MacOS/Windows - use `host.docker.internal`
  - On Linux - use `172.17.0.1`
- SQL Chat relies on OpenAI-compatible model IDs, so ensure to use the correct model name when configuring the service
  - For Ollama, you can "copy" the model definition to be available with the new ID: `harbor ollama cp llama3.1:8b gpt-3.5-turbo`

#### Configuration

Following options can be set via [`harbor config`](./3.-Harbor-CLI-Reference.md#harbor-config):

```bash
# The port on the host where SQL Chat endpoint will be available
HARBOR_SQLCHAT_HOST_PORT       34351

# The version (docker image tag) of SQL Chat to use
HARBOR_SQLCHAT_VERSION         latest

# The docker image to use for SQL Chat
HARBOR_SQLCHAT_IMAGE           sqlchat/sqlchat

# Next Auth Secret for SQL Chat
HARBOR_SQLCHAT_AUTH_SECRET     sk-harbor
```

Additionally, you can set arbitrary environment variables for SQL Chat according to Harbor's [environment configuration guide](./1.-Harbor-User-Guide.md#environment-variables).

```bash
# Example: Set the OpenAI API key
harbor env sqlchat OPENAI_API_KEY <your-key>

# Example: Set the OpenAI API endpoint
harbor env sqlchat OPENAI_API_ENDPOINT <your-endpoint>
```
