Update: 将子项目从 submodule 转为完整内容
- 移除 GovAI, nomifun-tauri, 算力盒子 的 submodule 引用 - 添加所有子项目的完整源代码 - 保留原始 .git 为 .git.bak 备份
This commit is contained in:
@@ -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 基础 URL(OpenAI 兼容格式)
|
||||
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", ""),
|
||||
SecretKey: getEnv("MINIO_SECRET_KEY", ""),
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package config
|
||||
|
||||
import "time"
|
||||
|
||||
// ==================== 分页与查询 ====================
|
||||
const (
|
||||
DefaultPage = 1
|
||||
DefaultPageSize = 20
|
||||
MaxPageSize = 100
|
||||
)
|
||||
|
||||
// ==================== Token 与会话 ====================
|
||||
const (
|
||||
DefaultAccessTokenExpiry = 24 * time.Hour
|
||||
DefaultRefreshTokenExpiry = 7 * 24 * time.Hour
|
||||
TokenHeader = "Authorization"
|
||||
TokenPrefix = "Bearer "
|
||||
)
|
||||
|
||||
// ==================== 文件上传 ====================
|
||||
const (
|
||||
MaxFileSize = 10 * 1024 * 1024 // 10MB
|
||||
AllowedFileExtensions = ".pdf,.doc,.docx,.txt,.md,.jpg,.jpeg,.png,.gif,.xlsx,.xls"
|
||||
AllowedMimeTypes = "application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain,text/markdown,image/jpeg,image/png,image/gif,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
)
|
||||
|
||||
// ==================== AI 模型 ====================
|
||||
const (
|
||||
DefaultEmbeddingDimensions = 1024
|
||||
DefaultEmbeddingModel = "text-embedding-v3"
|
||||
DefaultLLMTemperature = 0.7
|
||||
DefaultLLMTopP = 0.95
|
||||
DefaultLLMMaxTokens = 8192
|
||||
)
|
||||
|
||||
// ==================== RateLimit ====================
|
||||
const (
|
||||
DefaultRateLimitMax = 100
|
||||
DefaultRateLimitWindow = 1 * time.Minute
|
||||
)
|
||||
|
||||
// ==================== Redis Key 前缀 ====================
|
||||
const (
|
||||
RedisKeyPrefixRateLimit = "rl:"
|
||||
RedisKeyPrefixSession = "session:"
|
||||
RedisKeyPrefixToken = "token:"
|
||||
RedisKeyPrefixCache = "cache:"
|
||||
)
|
||||
|
||||
// ==================== Chat ====================
|
||||
const (
|
||||
MaxConversationHistory = 50
|
||||
MaxMessageLength = 4000
|
||||
)
|
||||
Reference in New Issue
Block a user