Something went wrong. Try again.
sloproxy
Something went wrong. Try again.
2.6 kB · 89 lines
Go
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990package diff
import ( "crypto/sha256" "encoding/hex" "encoding/json" "sort" "strings"
"github.com/router-for-me/CLIProxyAPI/v7/internal/config" "github.com/router-for-me/CLIProxyAPI/v7/internal/modelconfig" "github.com/router-for-me/CLIProxyAPI/v7/internal/registry")
// ComputeOpenAICompatModelsHash returns a stable hash for OpenAI-compat models.// Used to detect model list changes during hot reload.func ComputeOpenAICompatModelsHash(models []config.OpenAICompatibilityModel) string { return modelconfig.ComputeOpenAICompatModelsHash(models)}
// ComputeVertexCompatModelsHash returns a stable hash for Vertex-compatible models.func ComputeVertexCompatModelsHash(models []config.VertexCompatModel) string { return modelconfig.ComputeVertexCompatModelsHash(models)}
// ComputeClaudeModelsHash returns a stable hash for Claude model aliases.func ComputeClaudeModelsHash(models []config.ClaudeModel) string { return modelconfig.ComputeClaudeModelsHash(models)}
// ComputeCodexModelsHash returns a stable hash for Codex model aliases.func ComputeCodexModelsHash(models []config.CodexModel) string { return modelconfig.ComputeCodexModelsHash(models)}
// ComputeGeminiModelsHash returns a stable hash for Gemini model aliases.func ComputeGeminiModelsHash(models []config.GeminiModel) string { return modelconfig.ComputeGeminiModelsHash(models)}
// ComputeExcludedModelsHash returns a normalized hash for excluded model lists.func ComputeExcludedModelsHash(excluded []string) string { if len(excluded) == 0 { return "" } normalized := make([]string, 0, len(excluded)) for _, entry := range excluded { if trimmed := strings.TrimSpace(entry); trimmed != "" { normalized = append(normalized, strings.ToLower(trimmed)) } } if len(normalized) == 0 { return "" } sort.Strings(normalized) data, _ := json.Marshal(normalized) sum := sha256.Sum256(data) return hex.EncodeToString(sum[:])}
func thinkingHashSuffix(support *registry.ThinkingSupport) string { data, _ := json.Marshal(support) return "|thinking=" + string(data)}
func normalizeModelPairs(collect func(out func(key string))) []string { seen := make(map[string]struct{}) keys := make([]string, 0) collect(func(key string) { if _, exists := seen[key]; exists { return } seen[key] = struct{}{} keys = append(keys, key) }) if len(keys) == 0 { return nil } sort.Strings(keys) return keys}
func hashJoined(keys []string) string { if len(keys) == 0 { return "" } sum := sha256.Sum256([]byte(strings.Join(keys, "\n"))) return hex.EncodeToString(sum[:])}