File size: 3,047 Bytes
feccc69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766bd1c
feccc69
 
 
 
 
 
 
 
 
 
 
 
 
3678d9b
feccc69
 
 
 
 
 
 
 
 
 
 
 
766bd1c
feccc69
 
 
 
 
 
 
 
 
 
 
 
 
3678d9b
 
0c46526
 
 
 
3678d9b
feccc69
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package settings

import (
	"net/http"
	"strings"

	authn "ds2api/internal/auth"
	"ds2api/internal/config"
	"ds2api/internal/promptcompat"
)

func (h *Handler) getSettings(w http.ResponseWriter, _ *http.Request) {
	snap := h.Store.Snapshot()
	recommended := defaultRuntimeRecommended(len(snap.Accounts), h.Store.RuntimeAccountMaxInflight())
	needsSync := config.IsVercel() && snap.VercelSyncHash != "" && snap.VercelSyncHash != h.computeSyncHash()
	writeJSON(w, http.StatusOK, map[string]any{
		"success": true,
		"config_snapshot": map[string]any{
			"admin": map[string]any{
				"jwt_expire_hours": snap.Admin.JWTExpireHours,
			},
			"runtime": map[string]any{
				"account_max_inflight":         snap.Runtime.AccountMaxInflight,
				"account_max_queue":            snap.Runtime.AccountMaxQueue,
				"global_max_inflight":          snap.Runtime.GlobalMaxInflight,
				"token_refresh_interval_hours": snap.Runtime.TokenRefreshIntervalHours,
				"backup_release_count":         snap.Runtime.BackupReleaseCount,
			},
			"responses":   snap.Responses,
			"embeddings":  snap.Embeddings,
			"auto_delete": snap.AutoDelete,
			"current_input_file": map[string]any{
				"enabled":   snap.CurrentInputFile.Enabled,
				"min_chars": snap.CurrentInputFile.MinChars,
			},
			"thinking_injection": map[string]any{
				"enabled": snap.ThinkingInjection.Enabled,
				"prompt":  snap.ThinkingInjection.Prompt,
			},
			"model_aliases": snap.ModelAliases,
			"platform":      snap.Platform,
		},
		"admin": map[string]any{
			"has_password_hash":        strings.TrimSpace(snap.Admin.PasswordHash) != "",
			"jwt_expire_hours":         h.Store.AdminJWTExpireHours(),
			"jwt_valid_after_unix":     snap.Admin.JWTValidAfterUnix,
			"default_password_warning": authn.UsingDefaultAdminKey(h.Store),
		},
		"runtime": map[string]any{
			"account_max_inflight":         h.Store.RuntimeAccountMaxInflight(),
			"account_max_queue":            h.Store.RuntimeAccountMaxQueue(recommended),
			"global_max_inflight":          h.Store.RuntimeGlobalMaxInflight(recommended),
			"token_refresh_interval_hours": h.Store.RuntimeTokenRefreshIntervalHours(),
			"backup_release_count":         h.Store.RuntimeBackupReleaseCount(),
		},
		"responses":   snap.Responses,
		"embeddings":  snap.Embeddings,
		"auto_delete": snap.AutoDelete,
		"current_input_file": map[string]any{
			"enabled":   h.Store.CurrentInputFileEnabled(),
			"min_chars": h.Store.CurrentInputFileMinChars(),
		},
		"thinking_injection": map[string]any{
			"enabled":        h.Store.ThinkingInjectionEnabled(),
			"prompt":         h.Store.ThinkingInjectionPrompt(),
			"default_prompt": promptcompat.DefaultThinkingInjectionPrompt,
		},
		"model_aliases": snap.ModelAliases,
		"platform": map[string]any{
			"mode":              h.Store.PlatformMode(),
			"android_version":   snap.Platform.AndroidVersion,
			"web_version":       snap.Platform.WebVersion,
			"android_api_level": snap.Platform.AndroidAPILevel,
		},
		"env_backed":        h.Store.IsEnvBacked(),
		"needs_vercel_sync": needsSync,
	})
}