1 line
4.7 KiB
JSON
1 line
4.7 KiB
JSON
{"repo": "bzanniupoiiu/be-ai-chat", "files": {"ai-chat-service/pkg/config/config.go": {"0353cb3fe18ac22fb31445ef7ce2195c57358b35": {"t": 1785745644.6893995, "n": 2309, "h": "dbb32347a13d5f52", "c": "package config\n\nimport (\n\t\"github.com/spf13/viper\"\n\t\"log\"\n\t\"strings\"\n)\n\ntype Config struct {\n\tServer struct {\n\t\tIP string\n\t\tPort int\n\t\tAccessToken string\n\t}\n\tLog struct {\n\t\tLevel string\n\t\tLogPath string `mapstructure:\"logPath\"`\n\t} `mapstructure:\"log\"`\n\tChat struct {\n\t\tApiKey string `mapstructure:\"api_key\"`\n\t\tBaseUrl string `mapstructure:\"base_url\"`\n\t\tModel string `mapstructure:\"model\"`\n\t\tMaxTokens int `mapstructure:\"max_tokens\"`\n\t\tTemperature float32 `mapstructure:\"temperature\"`\n\t\tTopP float32 `mapstructure:\"top_p\"`\n\t\tPresencePenalty float32 `mapstructure:\"presence_penalty\"`\n\t\tFrequencyPenalty float32 `mapstructure:\"frequency_penalty\"`\n\t\tBotDesc string `mapstructure:\"bot_desc\"`\n\t\tMinResponseTokens int `mapstructure:\"min_response_tokens\"`\n\t\tContextTTL int `mapstructure:\"context_ttl\"`\n\t\tContextLen int `mapstructure:\"context_len\"`\n\t}\n\n\tKVStore struct {\n\t\tMasterAddr string `mapstructure:\"master_addr\"`\n\t\tSlaveAddr string `mapstructure:\"slave_addr\"`\n\t\tModelPath string `mapstructure:\"model_path\"`\n\t\tONNXFilename string `mapstructure:\"onnx_filename\"`\n\t\tSearchTopK int `mapstructure:\"search_top_k\"`\n\t\tMinScore float64 `mapstructure:\"min_score\"`\n\t\tMinScoreMargin float64 `mapstructure:\"min_score_margin\"`\n\t} `mapstructure:\"kvstore\"`\n\n\tRAG struct {\n\t\tBaseURL string `mapstructure:\"base_url\"`\n\t\tTimeoutMS int `mapstructure:\"timeout_ms\"`\n\t\tTopK int `mapstructure:\"top_k\"`\n\t\tEvidenceTopK int `mapstructure:\"evidence_top_k\"`\n\t} `mapstructure:\"rag\"`\n\n\tDependOn struct {\n\t\tSensitive struct {\n\t\t\tAddress string\n\t\t\tAccessToken string\n\t\t}\n\t\tKeywords struct {\n\t\t\tAddress string\n\t\t\tAccessToken string\n\t\t}\n\t\tTokenizer struct {\n\t\t\tAddress string\n\t\t}\n\t}\n}\n\nvar conf *Config\n\nfunc InitConfig(filePath string, typ ...string) {\n\tv := viper.New()\n\tv.SetConfigFile(filePath)\n\tv.SetEnvKeyReplacer(strings.NewReplacer(\".\", \"_\"))\n\tv.AutomaticEnv()\n\t_ = v.BindEnv(\"chat.api_key\", \"DEEPSEEK_API_KEY\")\n\tif len(typ) > 0 {\n\t\tv.SetConfigType(typ[0])\n\t}\n\terr := v.ReadInConfig()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tconf = &Config{}\n\terr = v.Unmarshal(conf)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n}\n\nfunc GetConfig() *Config {\n\treturn conf\n}\n"}, "90a5be9893665dd63afa1803ee06fb6deeffa978": {"t": 1785755267.536035, "n": 1660, "h": "8b89c3044c63106d", "c": "package config\n\nimport (\n\t\"github.com/spf13/viper\"\n\t\"log\"\n)\n\ntype Config struct {\n\tServer struct {\n\t\tIP string\n\t\tPort int\n\t\tAccessToken string\n\t}\n\tLog struct {\n\t\tLevel string\n\t\tLogPath string `mapstructure:\"logPath\"`\n\t} `mapstructure:\"log\"`\n\tChat struct {\n\t\tApiKey string `mapstructure:\"api_key\"`\n\t\tBaseUrl string `mapstructure:\"base_url\"`\n\t\tModel string `mapstructure:\"model\"`\n\t\tMaxTokens int `mapstructure:\"max_tokens\"`\n\t\tTemperature float32 `mapstructure:\"temperature\"`\n\t\tTopP float32 `mapstructure:\"top_p\"`\n\t\tPresencePenalty float32 `mapstructure:\"presence_penalty\"`\n\t\tFrequencyPenalty float32 `mapstructure:\"frequency_penalty\"`\n\t\tBotDesc string `mapstructure:\"bot_desc\"`\n\t\tMinResponseTokens int `mapstructure:\"min_response_tokens\"`\n\t\tContextTTL int `mapstructure:\"context_ttl\"`\n\t\tContextLen int `mapstructure:\"context_len\"`\n\t}\n\t\n\tKVStore struct {\n\t\tMasterAddr string `mapstructure:\"master_addr\"`\n\t\tSlaveAddr string `mapstructure:\"slave_addr\"`\n\t} `mapstructure:\"kvstore\"`\n\n\n\tDependOn struct {\n\t\tSensitive struct {\n\t\t\tAddress string\n\t\t\tAccessToken string\n\t\t}\n\t\tKeywords struct {\n\t\t\tAddress string\n\t\t\tAccessToken string\n\t\t}\n\t\tTokenizer struct {\n\t\t\tAddress string\n\t\t}\n\t}\n\t\n}\n\nvar conf *Config\n\nfunc InitConfig(filePath string, typ ...string) {\n\tv := viper.New()\n\tv.SetConfigFile(filePath)\n\tif len(typ) > 0 {\n\t\tv.SetConfigType(typ[0])\n\t}\n\terr := v.ReadInConfig()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tconf = &Config{}\n\terr = v.Unmarshal(conf)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n}\n\nfunc GetConfig() *Config {\n\treturn conf\n}\n"}}}} |