-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.go
112 lines (94 loc) · 1.78 KB
/
state.go
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package state
import (
"sync"
)
type AppState struct {
mu sync.RWMutex
platform string
model string
conversationID int
maxTokens int
topP float64
topK int
temperature float64
}
var (
state *AppState
once sync.Once
)
func GetState() *AppState {
once.Do(func() {
state = &AppState{}
})
return state
}
func (s *AppState) SetPlatform(platform string) {
s.mu.Lock()
defer s.mu.Unlock()
s.platform = platform
}
func (s *AppState) GetPlatform() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.platform
}
func (s *AppState) SetModel(model string) {
s.mu.Lock()
defer s.mu.Unlock()
s.model = model
}
func (s *AppState) GetModel() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.model
}
func (s *AppState) SetConversationID(conversationID int) {
s.mu.Lock()
defer s.mu.Unlock()
s.conversationID = conversationID
}
func (s *AppState) GetConversationID() int {
s.mu.RLock()
defer s.mu.RUnlock()
return s.conversationID
}
func (s *AppState) SetMaxTokens(maxTokens int) {
s.mu.Lock()
defer s.mu.Unlock()
s.maxTokens = maxTokens
}
func (s *AppState) GetMaxTokens() int {
s.mu.RLock()
defer s.mu.RUnlock()
return s.maxTokens
}
func (s *AppState) SetTopK(topK int) {
s.mu.Lock()
defer s.mu.Unlock()
s.topK = topK
}
func (s *AppState) GetTopK() int {
s.mu.RLock()
defer s.mu.RUnlock()
return s.topK
}
func (s *AppState) SetTopP(topP float64) {
s.mu.Lock()
defer s.mu.Unlock()
s.topP = topP
}
func (s *AppState) GetTopP() float64 {
s.mu.RLock()
defer s.mu.RUnlock()
return s.topP
}
func (s *AppState) SetTemperature(temperature float64) {
s.mu.Lock()
defer s.mu.Unlock()
s.temperature = temperature
}
func (s *AppState) GetTemperature() float64 {
s.mu.RLock()
defer s.mu.RUnlock()
return s.temperature
}