Initial commit: GovAI 政务AI平台

This commit is contained in:
freedakgmail
2026-06-15 23:48:37 +08:00
commit 0f490f72a9
245 changed files with 51669 additions and 0 deletions
+135
View File
@@ -0,0 +1,135 @@
package config
import (
"os"
"time"
)
type Config struct {
Server ServerConfig
Database DatabaseConfig
Redis RedisConfig
JWT JWTConfig
Dify DifyConfig
LLM LLMConfig
Embedding EmbeddingConfig
Gateway GatewayConfig
MinIO MinIOConfig
PPTWorker PPTWorkerConfig
}
type PPTWorkerConfig struct {
URL string // PPT Worker 微服务地址
}
type LLMConfig struct {
Provider string // "openai" or "anthropic"
OpenAIKey string
OpenAIBaseURL string
OpenAIModel string
AnthropicKey string
AnthropicBaseURL string
AnthropicModel string
}
type EmbeddingConfig struct {
APIKey string // Embedding API 密钥
BaseURL string // Embedding API 基础 URLOpenAI 兼容格式)
Model string // 向量模型名称
Dimensions int // 向量维度
}
type ServerConfig struct {
Host string
Port string
}
type DatabaseConfig struct {
URL string
}
type RedisConfig struct {
URL string
}
type JWTConfig struct {
Secret string
AccessExpiry time.Duration
RefreshExpiry time.Duration
}
type DifyConfig struct {
APIURL string
APIKey string
}
type GatewayConfig struct {
URL string
}
type MinIOConfig struct {
Endpoint string
AccessKey string
SecretKey string
Bucket string
UseSSL bool
}
func Load() *Config {
return &Config{
Server: ServerConfig{
Host: getEnv("SERVER_HOST", "0.0.0.0"),
Port: getEnv("SERVER_PORT", "8080"),
},
Database: DatabaseConfig{
URL: getEnv("DATABASE_URL", "postgres://localhost:5432/govai_portal?sslmode=disable"),
},
Redis: RedisConfig{
URL: getEnv("REDIS_URL", "redis://localhost:6379"),
},
JWT: JWTConfig{
Secret: getEnv("JWT_SECRET", "dev-secret-change-in-production"),
AccessExpiry: 24 * time.Hour,
RefreshExpiry: 7 * 24 * time.Hour,
},
Dify: DifyConfig{
APIURL: getEnv("DIFY_API_URL", "http://localhost:5001/v1"),
APIKey: getEnv("DIFY_API_KEY", ""),
},
LLM: LLMConfig{
Provider: getEnv("LLM_PROVIDER", "openai"),
OpenAIKey: getEnv("OPENAI_API_KEY", ""),
OpenAIBaseURL: getEnv("OPENAI_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1"),
OpenAIModel: getEnv("OPENAI_MODEL", "qwen-plus"),
AnthropicKey: getEnv("ANTHROPIC_API_KEY", ""),
AnthropicBaseURL: getEnv("ANTHROPIC_BASE_URL", "https://api.anthropic.com"),
AnthropicModel: getEnv("ANTHROPIC_MODEL", "claude-sonnet-4-20250514"),
},
Embedding: EmbeddingConfig{
APIKey: getEnv("EMBEDDING_API_KEY", ""),
BaseURL: getEnv("EMBEDDING_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1"),
Model: getEnv("EMBEDDING_MODEL", "text-embedding-v3"),
Dimensions: 1024,
},
Gateway: GatewayConfig{
URL: getEnv("MODEL_GATEWAY_URL", "http://localhost:8081"),
},
MinIO: MinIOConfig{
Endpoint: getEnv("MINIO_ENDPOINT", "localhost:9000"),
AccessKey: getEnv("MINIO_ACCESS_KEY", "minioadmin"),
SecretKey: getEnv("MINIO_SECRET_KEY", "minioadmin"),
Bucket: getEnv("MINIO_BUCKET", "aily-files"),
UseSSL: false,
},
PPTWorker: PPTWorkerConfig{
URL: getEnv("PPT_WORKER_URL", "http://localhost:8090"),
},
}
}
func getEnv(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}