Replace hardwired Anthropic API calls with a pluggable provider system. Each deployment configures its AI provider in instance.yaml — switching between Anthropic, LiteLLM, OpenRouter, or any OpenAI-compatible proxy is a config change, not a code change. New connectors/llm/ module: - StructuredExtractor Protocol with extract_json() interface - AnthropicExtractor: direct Anthropic SDK with retry + backoff - OpenAICompatExtractor: any OpenAI-compatible proxy with three-layer structured output fallback (json_schema -> json_object -> prompt) - Configurable structured_output policy (strict/json/auto) - Custom exception hierarchy (auth/rate_limit/timeout/format/refusal) - Zero secrets in logs: no API keys, prompts, or responses logged Reviewed by: Google Gemini, Claude Sonnet, OpenAI GPT-5.4. Security audit passed with all critical findings resolved.
35 lines
754 B
Bash
35 lines
754 B
Bash
#!/bin/bash
|
|
# Wrapper script for the corporate memory knowledge collector
|
|
# This script is called by systemd timer every 30 minutes
|
|
|
|
set -euo pipefail
|
|
|
|
APP_DIR="/opt/data-analyst"
|
|
REPO_DIR="${APP_DIR}/repo"
|
|
VENV_PYTHON="${APP_DIR}/.venv/bin/python"
|
|
LOG_DIR="/data/corporate-memory"
|
|
|
|
# Ensure log directory exists
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
# Load environment variables
|
|
if [[ -f "${APP_DIR}/.env" ]]; then
|
|
set -a
|
|
source "${APP_DIR}/.env"
|
|
set +a
|
|
fi
|
|
|
|
if [[ -f "${REPO_DIR}/.env" ]]; then
|
|
set -a
|
|
source "${REPO_DIR}/.env"
|
|
set +a
|
|
fi
|
|
|
|
# Config directory for instance.yaml
|
|
export CONFIG_DIR="${APP_DIR}/instance/config"
|
|
export PYTHONPATH="${REPO_DIR}"
|
|
|
|
# Run the collector
|
|
exec "$VENV_PYTHON" -m services.corporate_memory "$@"
|