ai-ui

command module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

ai-ui

CI Docs Release Go GHCR

A small, self-hosted ChatGPT-like web interface written in Go with document context (RAG), connected to an Azure Foundry model router (Azure OpenAI compatible).

Website with the full screenshot gallery: https://daknoblo.github.io/ai-ui/

Screenshots

Chat with Markdown answers

Documents as context (RAG) Image generation Token statistics
Documents as chat context Image generation Token statistics

All screenshots are generated automatically from the demo instance (cmd/demo) - see Demo & documentation.

Features

  • Chat interface with a sidebar, multiple conversations and history
  • Answer streaming (token by token) via server-sent events
  • Model picker in the top right of the chat window ("Auto" lets the router decide). The list comes from AZURE_MODELS; the selection is global and survives switching chats
  • Reasoning effort selectable per chat next to the input field; the offered values follow the selected model
  • Document upload as RAG context (embeddings + brute-force cosine search). PDF (layout aware: lines and columns survive), Word (.docx, including tables, headers, footers and footnotes - tracked deletions and field codes are left out), Excel (.xlsx, sheet by sheet as tab separated rows), PowerPoint (.pptx, slides plus speaker notes), RTF, HTML/XML, Markdown, CSV, JSON, YAML and source code. Anything else that is textual is recognized by its content, so a file without a useful name or type still works
  • Scanned PDFs are read automatically: a PDF without a text layer has its pages transcribed by the vision model, one request per page, and the transcript is embedded like any other document. The upload notice says which files were read that way and how many pages, because a transcription can be imperfect in a way a parsed document is not
  • Attach files next to the input field (πŸ“Ž) or drag and drop them into the chat window; attachments are shown as chips above the input. Documents reach the model as retrieved context sections, attached images are sent along with the message so a vision capable model can look at them. The names of all attachments are part of the prompt, so the model knows what it has
  • The model follows the attachment: a picture attached while a text-only model is selected is answered by the first vision capable entry of AZURE_MODELS. The switch applies to that one answer, the picker stays where it is, and the model tag names whoever replied
  • Optional web search (🌐) per request: pulls in current online results as context - provider agnostic (Tavily, Brave Search, SearXNG)
  • Optional image generation (πŸ–Ό): the toggle switches the next message from a chat answer to a generated image (Azure image models such as gpt-image-2); images are stored in the database and shown inline. In image mode an attached image turns the next prompt into an edit of that image. There the model picker offers the image deployments
  • Documents and images are bound to their chat and are removed together with it (including their embeddings)
  • Settings dialog in the UI (language, endpoints, deployments, API version, system prompt, temperature, default reasoning effort); the configured models are listed read-only
  • User interface available in English and German, switchable in the settings
  • Readiness/connection check: uploads are only possible once storage and the embedding endpoint are verified; checked at start-up and periodically in the background, with a status indicator in the sidebar
  • API key exclusively via the AZURE_API_KEY environment variable
  • Persistence in SQLite under the mounted data path
  • Single binary, single Docker image (distroless, non-root), designed to run behind a reverse proxy such as Traefik

Architecture

  • Go + chi router, html/template + HTMX (server rendered)
  • SQLite (modernc.org/sqlite, CGO free) for chats, messages, documents and embeddings
  • goldmark for Markdown rendering (raw HTML is escaped, never rendered)
  • RAG: chunking β†’ embeddings β†’ cosine similarity (top-k)

Configuration

Variable Default Description
AZURE_API_KEY – Secret. API key of the AI endpoint (chat).
AZURE_EMBEDDING_API_KEY – Secret, optional. Dedicated key if embeddings live on a separate Azure resource. Empty β‡’ AZURE_API_KEY is used.
SEARCH_API_KEY – Secret, optional. API key for web search (Tavily or Brave). Not required for SearXNG.
DATA_DIR /appdata Persistent data path. The SQLite database is stored directly in it, the UI settings in <DATA_DIR>/appdata/config.json.
PORT 8080 HTTP port.
HEALTHCHECK_INTERVAL 60s Interval of the periodic connection check (Go duration, e.g. 30s, 2m). 0 or off disables the periodic check (the start-up check still runs).
TZ – IANA time zone name. The binary bundles time/tzdata, so this works in the distroless image.

All remaining settings are configured in the UI dialog and stored in <DATA_DIR>/appdata/config.json (without secrets). The general AI endpoint and the embeddings can use separate endpoints, deployments and API versions; empty embedding fields fall back to the values of the AI endpoint.

Two endpoint schemas are detected automatically: the classic Azure OpenAI format (https://<resource>.openai.azure.com, deployment in the path, api-version required) and the new OpenAI compatible v1 format of Azure AI Foundry, recognizable by the /openai/v1 path (https://<resource>.services.ai.azure.com/openai/v1). With the v1 format the deployment is passed as model in the request and api-version is optional. The chat and embedding endpoints may use different schemas.

Several deployments, one configuration

All deployments of a resource share its endpoint and API key, so AZURE_MODELS is all it takes to offer several models: list the deployment names, and the picker in the top right switches between them. With the v1 schema the selected name is sent as model, with the classic schema it becomes the deployment in the request path - in both cases the request goes to that deployment. The entry of AZURE_DEPLOYMENT answers "Auto (router)" and is the fallback.

Embeddings and image generation are separate APIs and therefore keep their own deployment setting, but they can live in the same resource: leave their endpoint empty and only name the deployment.

Language

The interface language (English or German) is selected in the settings dialog and applies to the whole application, including the prompts used for the automatic chat titles and the document/web context. The page reloads once after the language has been changed. New installations default to English.

Temperature & reasoning effort

The temperature lives in the settings dialog under Behavior and applies to every chat request. The reasoning effort (the reasoning_effort parameter of reasoning models) is chosen per chat next to the input field; the settings dialog only holds the default for new chats.

The offered values follow the model selected in the top right and are updated when it changes: none, low, medium, high, xhigh for GPT-5.1 and newer, minimal, low, medium, high for GPT-5, low, medium, high for the o-series. Models without reasoning hide the field, and auto omits the parameter so the model keeps its own default. A value the answering model does not accept - which cannot be ruled out behind a model router - is dropped automatically and the request is repeated without it, the same way an unsupported temperature is.

Pinning the endpoint via environment variables (optional)

The endpoint settings can be provided entirely through environment variables instead of the UI dialog. When one of these variables is set, its value takes precedence over config.json and the matching field in the settings dialog is shown but disabled (not editable through the UI):

The naming scheme is consistent: the general AI endpoint uses the base names AZURE_*, the embeddings consistently use AZURE_EMBEDDING_*.

General AI endpoint:

Variable Setting
AZURE_ENDPOINT Endpoint URL of the AI endpoint.
AZURE_DEPLOYMENT Deployment name of the chat model.
AZURE_MODELS Selectable models (comma or newline separated), e.g. model-router,gpt-5.1,o4-mini. The only source of the list; the settings dialog shows it read-only. The entries are deployment names of the same resource, and the first one is the default for new chats.
AZURE_API_VERSION API version of the AI endpoint. Only used by the classic schema; with a /openai/v1 endpoint the client picks it and the field disappears from the settings dialog.

Embeddings (fall back to the AI endpoint when empty):

Variable Setting
AZURE_EMBEDDING_ENDPOINT Embedding endpoint URL.
AZURE_EMBEDDING_DEPLOYMENT Deployment name of the embedding model.
AZURE_EMBEDDING_API_VERSION Embedding API version.

Image generation (fall back to the AI endpoint when empty):

Variable Setting
AZURE_IMAGE_ENDPOINT Image endpoint URL, e.g. https://my-resource.services.ai.azure.com/openai/v1.
AZURE_IMAGE_DEPLOYMENT Deployment name of the image model, e.g. gpt-image-2.
AZURE_IMAGE_MODELS Selectable image deployments (comma or newline separated). Empty β‡’ only AZURE_IMAGE_DEPLOYMENT. In image mode the picker in the top right offers these instead of the chat models.
AZURE_IMAGE_API_VERSION Image API version.

The key is AZURE_IMAGE_API_KEY; when it is empty AZURE_API_KEY is used. A dedicated key is required as soon as the image endpoint belongs to a different resource - the chat key is rejected there with HTTP 401. The settings dialog points that out, and the connection check probes the image deployments as well (with an intentionally incomplete request, so it costs nothing and generates no image). Size, quality and file format are chosen in the settings dialog.

The matching secrets are AZURE_API_KEY and AZURE_EMBEDDING_API_KEY respectively (see the table above).

Variables that are not set stay editable in the UI. Empty values count as "not set" and do not lock anything.

Readiness & connection check

The connection check sits at the top of the settings dialog and runs on its own: once when the container starts and again in the dialog whenever the configuration changed. It probes storage (data path writable), the chat and embedding endpoint and every deployment from AZURE_MODELS individually - a typo in the list shows up there instead of when that model is picked. Check again repeats it on demand.

Document uploads are only enabled once storage and the embedding endpoint are green, because a document is chunked and embedded on the way in. Attaching an image needs neither: it is stored as is and travels with the message. A scanned PDF additionally needs a vision capable entry in AZURE_MODELS; without one the upload fails with that reason instead of storing an empty document. A background check (HEALTHCHECK_INTERVAL) monitors the connection continuously - without the per-deployment probes - and reports failures through the sidebar status and the log.

Web search (optional)

Pick a provider in the settings dialog under Web search:

  • Tavily – optimized for LLM/RAG, returns already extracted content (requires SEARCH_API_KEY).
  • Brave Search – REST API (requires SEARCH_API_KEY).
  • SearXNG – self-hosted meta search; only the base URL is needed, no key.

When a provider is configured, a 🌐 toggle appears next to the chat input. While it is active, the message is enriched with current web results; the state survives switching chats. The search API key is - like the Azure keys - read exclusively from the SEARCH_API_KEY environment variable and never stored in config.json.

The SearXNG base URL is fetched by the server, so it is validated: only http/https URLs are accepted, and connections to loopback and link-local addresses (including the cloud metadata service 169.254.169.254) are refused. Private LAN ranges stay reachable because that is where a self-hosted instance usually lives.

Security

  • Single static binary on a distroless base image, running as non-root (UID/GID 65532); the container image is signed with cosign and scanned with Trivy in CI
  • Secrets are read from environment variables only and are never written to config.json
  • All SQL statements are parameterized; no user input is concatenated into queries
  • Model and document content is rendered as sanitized Markdown - raw HTML is escaped, never injected
  • Defensive response headers on every request: Content-Security-Policy, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Cross-Origin-Opener-Policy and Permissions-Policy
  • Uploads are limited to 25 MiB per file and 150 MiB per request; the extracted text is capped, the OOXML formats (.docx, .xlsx, .pptx) are bounded against decompression bombs, and the PDF reader is fed untrusted input behind a panic guard
  • The app is meant to run inside a trusted network or behind a reverse proxy/VPN. It has no user accounts and should not be exposed to the internet unprotected

Running locally

export AZURE_API_KEY=your-key
DATA_DIR=./data PORT=8080 go run .
# http://localhost:8080

Docker

docker build -t ai-ui .
docker run --rm -p 8080:8080 \
  -e AZURE_API_KEY=your-key \
  -v ai-ui-data:/appdata \
  ai-ui
Data path permissions (non-root)

The container runs as a non-root user (UID/GID 65532) and stores all data (chats, documents, embeddings, configuration) under /appdata. A Docker managed named volume is used as persistent storage:

services:
  ai-ui:
    image: ghcr.io/daknoblo/ai-ui:latest
    volumes:
      - ai-ui-data:/appdata
volumes:
  ai-ui-data:

A freshly created named volume inherits its ownership from the image (65532) and therefore works out of the box - including in Dockge/Portainer as a normal user, without any manual permission handling. Docker manages the volume; no changes on the host are required.

Deployment

docker-compose.example.yml contains one ai-ui container with a named volume and the published port 8080; Traefik labels are included but commented out. The project is designed for exactly one container - how many instances of it you run is up to you (e.g. several services in a single stack). The image is built and published to ghcr.io/daknoblo/ai-ui by GitHub Actions (on pushes to main and on v* tags).

Development

gofmt -l .                  # must print nothing
go vet ./...
golangci-lint run ./...
go test -race ./...
CGO_ENABLED=0 go build ./...

User interface strings live in internal/i18n. Every key must exist in all supported languages; a test enforces that.

Demo & documentation

The repository contains a demo instance that needs neither an API key nor any Azure resources: internal/demo provides a stub of the Azure-compatible endpoints (chat streaming, embeddings, images) and seeds the database with conversations, documents, a generated image and token statistics.

go run ./cmd/demo             # http://localhost:8080
go run ./cmd/demo -lang de    # German interface

The demo is also the source of the screenshots. They are captured with Playwright and written to docs/screenshots, together with a manifest that describes every shot:

go build -o bin/ai-ui-demo ./cmd/demo
cd tools/screenshots && npm ci && npx playwright install chromium
node capture.mjs --bin=../../bin/ai-ui-demo --out=../../docs/screenshots

cmd/site turns this README and the screenshots into the static website that is published on GitHub Pages:

go run ./cmd/site -out site   # open site/index.html

The Docs workflow runs all three steps on every push to main that touches the application, the templates or this README: it recaptures the screenshots, commits them when they changed and deploys the regenerated website. New features therefore appear in the documentation without a manual screenshot session.

License

Released under the MIT License.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
cmd
demo command
Command demo runs the application against a stub backend with seeded content.
Command demo runs the application against a stub backend with seeded content.
site command
Command site generates the static documentation website that is published on GitHub Pages.
Command site generates the static documentation website that is published on GitHub Pages.
internal
config
Package config loads and persists the user-editable settings.
Package config loads and persists the user-editable settings.
demo
Package demo builds a self-contained demo instance of the application: a stub of the Azure-compatible backend plus seeded chats, documents, images and token statistics.
Package demo builds a self-contained demo instance of the application: a stub of the Azure-compatible backend plus seeded chats, documents, images and token statistics.
docparse
Package docparse extracts plain text from uploaded documents.
Package docparse extracts plain text from uploaded documents.
i18n
Package i18n provides the message catalog for the user interface.
Package i18n provides the message catalog for the user interface.
llm
Package llm talks to the Azure-OpenAI-compatible model router.
Package llm talks to the Azure-OpenAI-compatible model router.
logbuf
Package logbuf keeps the most recent log lines in memory so the UI can show them without access to the container log.
Package logbuf keeps the most recent log lines in memory so the UI can show them without access to the container log.
rag
Package rag implements chunking, ingestion and retrieval (brute-force cosine).
Package rag implements chunking, ingestion and retrieval (brute-force cosine).
server
Package server contains the HTTP server, its routes and handlers.
Package server contains the HTTP server, its routes and handlers.
storage
Package storage wraps all access to the SQLite database.
Package storage wraps all access to the SQLite database.
websearch
Package websearch provides a provider-agnostic web search whose results can be fed into the chat as additional context.
Package websearch provides a provider-agnostic web search whose results can be fed into the chat as additional context.
Package web bundles the embedded templates and static assets.
Package web bundles the embedded templates and static assets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL