* feat: support timescale pg_textsearch as text search extension * refactor: deduplicate text search query in retrieve_semantic_bm25_combined Instead of maintaining 3 complete query copies (native, vchord, pg_textsearch), now we: - Build backend-specific parts (score_expr, order_by, where_filter) - Use a single query template with injected backend-specific parts This makes maintenance easier - changes to the semantic CTE or overall structure only need to be made once.
91 lines
3.2 KiB
YAML
91 lines
3.2 KiB
YAML
name: hindsight
|
|
# Docker Compose file for Hindsight with PostgreSQL and Timescale pg_textsearch
|
|
# docker compose -f docker/docker-compose/pg_textsearch/docker-compose.yaml down && sleep 2 && docker compose -f docker/docker-compose/pg_textsearch/docker-compose.yaml up -d
|
|
# Make sure to set the required environment variables before running:
|
|
# - HINDSIGHT_DB_PASSWORD: Password for the PostgreSQL user
|
|
# - Configure LLM provider variables as needed (see below in the hindsight service)
|
|
#
|
|
# Usage:
|
|
# docker compose up -d
|
|
#
|
|
# Optional environment variables with defaults:
|
|
# - HINDSIGHT_VERSION: Hindsight application version (default: latest)
|
|
# - HINDSIGHT_DB_USER: PostgreSQL user (default: hindsight_user)
|
|
# - HINDSIGHT_DB_NAME: PostgreSQL database name (default: hindsight_db)
|
|
|
|
services:
|
|
db:
|
|
# Use custom PostgreSQL image with pgvector and pg_textsearch extensions
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: hindsight-db
|
|
restart: always
|
|
# Expose PostgreSQL port
|
|
ports:
|
|
- "5437:5432"
|
|
environment:
|
|
POSTGRES_USER: ${HINDSIGHT_DB_USER:-hindsight_user}
|
|
POSTGRES_PASSWORD: ${HINDSIGHT_DB_PASSWORD:-hindsight_password}
|
|
POSTGRES_DB: ${HINDSIGHT_DB_NAME:-hindsight_db}
|
|
volumes:
|
|
- pg_data:/var/lib/postgresql/data
|
|
networks:
|
|
- hindsight-net
|
|
|
|
pg-textsearch-init:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
depends_on:
|
|
- db
|
|
environment:
|
|
- PGPASSWORD=${HINDSIGHT_DB_PASSWORD:-hindsight_password}
|
|
command: >
|
|
bash -c "
|
|
echo 'Waiting for PostgreSQL to be ready...';
|
|
until pg_isready -h hindsight-db -p 5432 -U hindsight_user; do
|
|
echo 'PostgreSQL is unavailable - sleeping';
|
|
sleep 2;
|
|
done;
|
|
echo 'PostgreSQL is ready - creating hindsight_db database';
|
|
psql -h hindsight-db -p 5432 -U hindsight_user -c 'CREATE DATABASE hindsight_db;' 2>/dev/null || echo 'Database already exists';
|
|
echo 'Creating extensions in hindsight_db database';
|
|
psql -h hindsight-db -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS vector CASCADE;';
|
|
psql -h hindsight-db -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS pg_textsearch CASCADE;';
|
|
echo 'Database and extensions created successfully';
|
|
"
|
|
restart: "no"
|
|
networks:
|
|
- hindsight-net
|
|
|
|
hindsight:
|
|
image: ghcr.io/vectorize-io/hindsight:${HINDSIGHT_VERSION:-latest}
|
|
container_name: hindsight-app
|
|
ports:
|
|
- "8888:8888"
|
|
- "9999:9999"
|
|
environment:
|
|
# LLM Configuration
|
|
HINDSIGHT_API_LLM_PROVIDER: ${HINDSIGHT_API_LLM_PROVIDER:-openai}
|
|
HINDSIGHT_API_LLM_API_KEY: ${OPENAI_API_KEY:-your-api-key}
|
|
|
|
# Database Configuration
|
|
HINDSIGHT_API_DATABASE_URL: postgresql://${HINDSIGHT_DB_USER:-hindsight_user}:${HINDSIGHT_DB_PASSWORD:-hindsight_password}@db:5432/${HINDSIGHT_DB_NAME:-hindsight_db}
|
|
|
|
# Vector and Text Search Extensions
|
|
HINDSIGHT_API_VECTOR_EXTENSION: pgvector
|
|
HINDSIGHT_API_TEXT_SEARCH_EXTENSION: pg_textsearch
|
|
|
|
depends_on:
|
|
- db
|
|
networks:
|
|
- hindsight-net
|
|
|
|
|
|
networks:
|
|
hindsight-net:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
pg_data:
|