Add AI provider configuration
All checks were successful
CI / test (push) Successful in 12s
Build and Deploy / build-and-deploy (push) Successful in 22s

This commit is contained in:
Grendgi
2026-06-08 13:42:18 +03:00
parent 0081e910ba
commit 0da278a45e
4 changed files with 49 additions and 0 deletions

View File

@@ -41,9 +41,23 @@ service.
- `HTTP_PORT`, default `8080` - `HTTP_PORT`, default `8080`
- `DATABASE_URL`, required - `DATABASE_URL`, required
- `MIGRATE_ON_START`, default `true` - `MIGRATE_ON_START`, default `true`
- `LLM_BASE_URL`, primary OpenAI-compatible LLM endpoint
- `LLM_API_KEY`, primary LLM API key
- `LLM_MODEL`, default `qwen2.5-14b`
- `LLM_TIMEOUT`, default `5m`
- `WHISPERX_URL`, WhisperX endpoint for transcription jobs
- `OPENCLAW_URL`, optional OpenClaw gateway URL if we route through OpenClaw
instead of direct vLLM
## Next integration step ## Next integration step
`telephony` should first mirror low-risk analysis jobs into this service while `telephony` should first mirror low-risk analysis jobs into this service while
continuing local processing. Remote execution can then be enabled by feature continuing local processing. Remote execution can then be enabled by feature
flag per task type. flag per task type.
## OpenClaw note
Current Portal services call the local AI server directly: vLLM for LLM tasks
and WhisperX for transcription. OpenClaw is not required for the current
`ai-service` queue deployment. It becomes useful if we want centralized model
routing, provider fallback, request policy and cross-model gateway behavior.

View File

@@ -3,6 +3,7 @@ package config
import ( import (
"os" "os"
"strconv" "strconv"
"time"
) )
type Config struct { type Config struct {
@@ -10,6 +11,13 @@ type Config struct {
HTTPPort int HTTPPort int
DatabaseURL string DatabaseURL string
MigrateOnStart bool MigrateOnStart bool
LLMBaseURL string
LLMAPIKey string
LLMModel string
LLMTimeout time.Duration
WhisperXURL string
OpenClawURL string
} }
func Load() Config { func Load() Config {
@@ -18,6 +26,13 @@ func Load() Config {
HTTPPort: envInt("HTTP_PORT", 8080), HTTPPort: envInt("HTTP_PORT", 8080),
DatabaseURL: envString("DATABASE_URL", ""), DatabaseURL: envString("DATABASE_URL", ""),
MigrateOnStart: envBool("MIGRATE_ON_START", true), MigrateOnStart: envBool("MIGRATE_ON_START", true),
LLMBaseURL: envString("LLM_BASE_URL", ""),
LLMAPIKey: envString("LLM_API_KEY", ""),
LLMModel: envString("LLM_MODEL", "qwen2.5-14b"),
LLMTimeout: envDuration("LLM_TIMEOUT", 5*time.Minute),
WhisperXURL: envString("WHISPERX_URL", ""),
OpenClawURL: envString("OPENCLAW_URL", ""),
} }
} }
@@ -51,3 +66,15 @@ func envBool(key string, fallback bool) bool {
} }
return v return v
} }
func envDuration(key string, fallback time.Duration) time.Duration {
raw := os.Getenv(key)
if raw == "" {
return fallback
}
v, err := time.ParseDuration(raw)
if err != nil {
return fallback
}
return v
}

View File

@@ -7,3 +7,10 @@ data:
HTTP_HOST: "0.0.0.0" HTTP_HOST: "0.0.0.0"
HTTP_PORT: "8080" HTTP_PORT: "8080"
MIGRATE_ON_START: "true" MIGRATE_ON_START: "true"
# Default direct AI endpoints. OpenClaw can replace LLM_BASE_URL later when
# we decide to route model traffic through a gateway instead of direct vLLM.
LLM_BASE_URL: "http://10.2.3.5:8002"
LLM_MODEL: "qwen2.5-14b"
LLM_TIMEOUT: "5m"
WHISPERX_URL: "http://10.2.3.5:8001"
OPENCLAW_URL: ""

View File

@@ -17,3 +17,4 @@ metadata:
type: Opaque type: Opaque
stringData: stringData:
DATABASE_URL: "postgres://ai_service:ai_service@postgres:5432/ai_service?sslmode=disable" DATABASE_URL: "postgres://ai_service:ai_service@postgres:5432/ai_service?sslmode=disable"
LLM_API_KEY: "sk-111f838ccec43406e078cd9094b6797307cb895236179f32"