feat: Round 5 - Memory Service, Tool Engine, Call Records, Thinking Logs
- Fix: Session history flash (race condition + WS guard) - Fix: Chat background overlay + sidebar transparency - Fix: IoT device control (Chinese action names, status field) - Feat: Independent memory-service (port 8091, 13 endpoints) - Feat: Independent tool-engine service (port 8092, 13 tools) - Feat: Tool call logs with paginated DevTools panel - Feat: Thinking log records with DevTools panel - Feat: Future development roadmap document - Chore: Updated .gitignore, go.work, DevTools config - Chore: 5-service health check, project review docs
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Config 记忆服务配置
|
||||
type Config struct {
|
||||
Port string
|
||||
DatabaseURL string
|
||||
}
|
||||
|
||||
// Load 从环境变量加载配置
|
||||
func Load() *Config {
|
||||
return &Config{
|
||||
Port: getEnv("PORT", "8091"),
|
||||
DatabaseURL: buildDatabaseURL(),
|
||||
}
|
||||
}
|
||||
|
||||
// buildDatabaseURL 构建 PostgreSQL 连接字符串
|
||||
func buildDatabaseURL() string {
|
||||
// 优先使用 DB_URL 环境变量(简化模式)
|
||||
if url := os.Getenv("DB_URL"); url != "" {
|
||||
return url
|
||||
}
|
||||
|
||||
host := getEnv("POSTGRES_HOST", "localhost")
|
||||
port := getEnv("POSTGRES_PORT", "5432")
|
||||
user := getEnv("POSTGRES_USER", "cyrene")
|
||||
password := getEnv("POSTGRES_PASSWORD", "change_me")
|
||||
dbname := getEnv("POSTGRES_DB", "cyrene_ai")
|
||||
sslmode := getEnv("POSTGRES_SSLMODE", "disable")
|
||||
|
||||
return fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=%s",
|
||||
user, password, host, port, dbname, sslmode)
|
||||
}
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
Reference in New Issue
Block a user