返回 DeepSeek-Reasonix
deepseek_model_reference.go
根目录 / internal / config / deepseek_model_reference.go
1 package config
2
3 import "strings"
4
5 // acceptsDeepSeekModelReference preserves saved session references to retired
6 // official Flash IDs without putting aliases back in the selectable catalog.
7 // Resolution keeps the original wire ID, pricing and model-specific overrides.
8 func acceptsDeepSeekModelReference(p *ProviderEntry, model string) bool {
9 if p.HasModel(model) {
10 return true
11 }
12 if !p.HasModel("deepseek-flash") || !isOfficialDeepSeekModelReferenceEndpoint(p) {
13 return false
14 }
15 switch model {
16 case "deepseek-v4-flash", "deepseek-v4-flash-vision-exp":
17 return true
18 default:
19 return false
20 }
21 }
22
23 func normalizeOfficialDeepSeekModels(c *Config) {
24 if c == nil {
25 return
26 }
27 for i := range c.Providers {
28 p := &c.Providers[i]
29 if officialProviderHost(p.BaseURL) != "api.deepseek.com" {
30 continue
31 }
32 // Explicit lists belong to the user. Legacy singular entries still
33 // receive the stock catalog while retaining their original model.
34 if len(p.Models) == 0 {
35 legacyModel := p.Model
36 legacyDefault := p.DefaultModel()
37 switch strings.TrimSpace(p.Name) {
38 case "deepseek", "deepseek-chat", "deepseek-anthropic", "deepseek-responses":
39 ensureProviderModels(p, deepSeekOfficialModels, "deepseek-flash")
40 case "deepseek-flash":
41 ensureProviderModels(p, []string{"deepseek-flash"}, "deepseek-flash")
42 case "deepseek-pro":
43 ensureProviderModels(p, []string{"deepseek-v4-pro"}, "deepseek-v4-pro")
44 }
45 // A singular price belongs to the original model ID. Keep that
46 // provenance for billing migrations and saved legacy references.
47 if legacyModel != "" {
48 p.Model = legacyModel
49 if len(p.Models) > 0 && p.HasModel(legacyDefault) {
50 p.Default = legacyDefault
51 }
52 }
53 }
54 backfillOfficialDeepSeekVisionPrice(p)
55 if isOfficialDeepSeekResponsesProvider(p) {
56 backfillOfficialDeepSeekResponsesProPrice(p)
57 }
58 backfillDeepSeekAnthropicCapabilities(p)
59 }
60 }
61
62 func isOfficialDeepSeekModelReferenceEndpoint(p *ProviderEntry) bool {
63 endpoint, exact := normalizedExactProviderRequestURL(ProviderEffectiveRequestURL(p))
64 if !exact {
65 return false
66 }
67 switch normalizedProviderProtocol(p.Kind) {
68 case "openai":
69 return endpoint == "https://api.deepseek.com/chat/completions" || endpoint == "https://api.deepseek.com/v1/chat/completions"
70 case "responses":
71 return endpoint == "https://api.deepseek.com/responses" || endpoint == "https://api.deepseek.com/v1/responses"
72 case "anthropic":
73 return endpoint == "https://api.deepseek.com/anthropic/v1/messages"
74 default:
75 return false
76 }
77 }
78
78 lines GO