| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package config
-
- import "git.x2erp.com/qdy/go-svc-ai/internal/factory"
-
- // 模拟数据库中的配置
- var MockConfigs = map[string]*factory.ModelConfig{
- // OpenAI配置
- "openai-gpt4": {
- Provider: "openai",
- BaseURL: "https://api.openai.com/v1",
- APIKey: "sk-xxx", // 实际使用时从环境变量/数据库读取
- Model: "gpt-4",
- MaxTokens: 2000,
- Temperature: 0.7,
- Timeout: 30,
- },
-
- // DeepSeek配置
- "deepseek-chat": {
- Provider: "deepseek",
- BaseURL: "https://api.deepseek.com",
- APIKey: "sk-xxx",
- Model: "deepseek-chat",
- MaxTokens: 2048,
- Temperature: 0.7,
- Timeout: 30,
- },
-
- // Claude配置
- "claude-3": {
- Provider: "claude",
- BaseURL: "https://api.anthropic.com/v1",
- APIKey: "sk-xxx",
- Model: "claude-3-sonnet",
- MaxTokens: 4096,
- Temperature: 0.8,
- Timeout: 60,
- },
-
- // 流式专用配置
- "openai-stream": {
- Provider: "openai",
- BaseURL: "https://api.openai.com/v1",
- APIKey: "sk-xxx",
- Model: "gpt-3.5-turbo",
- MaxTokens: 1000,
- Temperature: 0.9,
- Timeout: 60, // 流式需要更长超时
- },
- }
-
- // GetConfig 模拟从数据库读取配置
- func GetConfig(configKey string) (*factory.ModelConfig, error) {
- if config, exists := MockConfigs[configKey]; exists {
- return config, nil
- }
- return nil, &ConfigError{Msg: "配置不存在: " + configKey}
- }
-
- // ConfigError 配置错误
- type ConfigError struct {
- Msg string
- }
-
- func (e *ConfigError) Error() string {
- return e.Msg
- }
|