Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ GOOGLE_API_KEY=your-google-ai-studio-key-here
# BROWSER_USE_API_KEY=bu_your_key_here

# Database Configuration
# asyncpg requires ssl=require instead of sslmode=require
DATABASE_URL=postgresql://user:pass@host:port/dbname?ssl=require
DB_POOL_PRE_PING=true
DB_POOL_RECYCLE=1800
DB_POOL_SIZE=5
DB_MAX_OVERFLOW=10
DB_POOL_TIMEOUT=30
# SQLite database for reminders, calories, workouts, and preferences
# Default: {AGENT_DIR}/.adk/tools.db (inside container: /app/src/.adk/tools.db)
# SQLITE_PATH=/data/tools.db

# Server Configuration
LOG_LEVEL=INFO
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ jobs:
TELEGRAM_ENABLED: ${{ secrets.TELEGRAM_ENABLED }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_TOOL_NOTIFICATIONS: ${{ secrets.TELEGRAM_TOOL_NOTIFICATIONS }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
BRAVE_SEARCH_API_KEY: ${{ secrets.BRAVE_SEARCH_API_KEY }}
BROWSER_USE_API_KEY: ${{ secrets.BROWSER_USE_API_KEY }}
SANDBOX_ENABLED: ${{ secrets.SANDBOX_ENABLED }}
Expand Down Expand Up @@ -131,7 +130,6 @@ jobs:
TELEGRAM_ENABLED="${TELEGRAM_ENABLED}"
TELEGRAM_BOT_TOKEN="${TELEGRAM_BOT_TOKEN}"
TELEGRAM_TOOL_NOTIFICATIONS="${TELEGRAM_TOOL_NOTIFICATIONS}"
DATABASE_URL="${DATABASE_URL}"
BRAVE_SEARCH_API_KEY="${BRAVE_SEARCH_API_KEY}"
BROWSER_USE_API_KEY="${BROWSER_USE_API_KEY}"
SANDBOX_ENABLED="${SANDBOX_ENABLED}"
Expand Down Expand Up @@ -210,7 +208,6 @@ jobs:
TELEGRAM_ENABLED="${TELEGRAM_ENABLED}"
TELEGRAM_BOT_TOKEN="${TELEGRAM_BOT_TOKEN}"
TELEGRAM_TOOL_NOTIFICATIONS="${TELEGRAM_TOOL_NOTIFICATIONS}"
DATABASE_URL="${DATABASE_URL}"
BRAVE_SEARCH_API_KEY="${BRAVE_SEARCH_API_KEY}"
BROWSER_USE_API_KEY="${BROWSER_USE_API_KEY}"
HOST_PORT="${HOST_PORT}"
Expand Down
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ RUN --mount=type=cache,target=/root/.cache/uv \
# ============================================================================
FROM python:3.13-slim AS runtime

# Install system dependencies
# - netcat-openbsd: for checking DB readiness (used in entrypoint.sh)
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user for security (matching common host UID 1000)
RUN groupadd -g 1000 app && \
useradd -u 1000 -g app -s /bin/sh -m app
Expand Down
21 changes: 0 additions & 21 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
#!/bin/sh
set -e

# Wait for the database if DATABASE_URL is set and looks like a postgres url
if echo "$DATABASE_URL" | grep -q "postgresql://"; then
echo "Waiting for database..."
# Extract host and port from DATABASE_URL
# Assumes format postgresql://user:pass@host:port/dbname
# This is a basic extraction and might need adjustment for complex URLs
DB_HOST=$(echo $DATABASE_URL | sed -e 's|^.*@||' -e 's|/.*$||' -e 's|:.*$||')
DB_PORT=$(echo $DATABASE_URL | sed -e 's|^.*@||' -e 's|/.*$||' -e 's|^.*:||')

# Default port if not specified
if [ "$DB_HOST" = "$DB_PORT" ]; then
DB_PORT=5432
fi

# Loop until the database is ready
while ! nc -z $DB_HOST $DB_PORT; do
sleep 1
done
echo "Database started"
fi

exec "$@"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"pydantic>=2.11.0,<3.0.0",
"python-dotenv>=1.0.0,<2.0.0",
"litellm>=1.60.0",
"asyncpg>=0.30.0",
"aiosqlite>=0.20.0",
"greenlet>=3.0.0",
"openinference-instrumentation-google-adk>=0.1.8",
"httpx>=0.27.0,<1.0.0",
Expand Down
9 changes: 5 additions & 4 deletions scripts/speech_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import re
import sys
from pathlib import Path
from typing import Any

import httpx
Expand Down Expand Up @@ -259,11 +260,11 @@ async def main() -> None:
# Initialize Blacki ADK Runtime
env = initialize_environment(ServerEnv)

# Initialize global container so tools that depend on Postgres can function
# Initialize global container so tools that depend on SQLite can function
container = None
if env.database_url:
container = await init_container(env.database_url)
await container.initialize_all_storages()
sqlite_path = env.sqlite_path or str(Path(env.agent_dir) / ".adk" / "tools.db")
container = await init_container(sqlite_path)
await container.initialize_all_storages()

runtime = create_adk_runtime(env)

Expand Down
14 changes: 6 additions & 8 deletions src/blacki/adk_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ def build_session_service_uri(env: ServerEnv) -> str | None:


def build_session_db_kwargs(env: ServerEnv) -> dict[str, Any]:
"""Build shared SQLAlchemy kwargs for database-backed ADK sessions."""
return {
"pool_pre_ping": env.db_pool_pre_ping,
"pool_recycle": env.db_pool_recycle,
"pool_size": env.db_pool_size,
"max_overflow": env.db_max_overflow,
"pool_timeout": env.db_pool_timeout,
}
"""Build shared SQLAlchemy kwargs for database-backed ADK sessions.

Note: Pool settings are only relevant for PostgreSQL. SQLite uses
a single connection and ignores pool settings.
"""
return {}


def create_session_service(
Expand Down
6 changes: 0 additions & 6 deletions src/blacki/calories/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from .storage import (
close_calorie_storage,
init_calorie_storage,
)
from .tools import (
delete_meal,
edit_meal,
Expand All @@ -11,8 +7,6 @@
)

__all__ = [
"close_calorie_storage",
"init_calorie_storage",
"delete_meal",
"edit_meal",
"get_calorie_summary",
Expand Down
Loading
Loading