- Updated LLMClient interface to support model-specific generation and model listing. - Integrated model store and validator into the command application for managing AI models. - Implemented commands for setting, getting, and listing active AI models in Discord. - Enhanced AI query handling to utilize the selected model and return model information in responses. - Added caching mechanism for model validation to improve performance. - Introduced gRPC methods for listing available AI models in the ai-gateway. - Updated protobuf definitions to include model-related fields and messages. - Added tests for model store and validator functionalities.
29 lines
547 B
Go
29 lines
547 B
Go
package modelstore
|
|
|
|
import "sync"
|
|
|
|
// Store keeps the globally selected AI model in memory.
|
|
type Store struct {
|
|
mu sync.RWMutex
|
|
selected string
|
|
}
|
|
|
|
// New constructs an empty in-memory model store.
|
|
func New() *Store {
|
|
return &Store{}
|
|
}
|
|
|
|
// Get returns the currently selected model, or empty for default behavior.
|
|
func (s *Store) Get() string {
|
|
s.mu.RLock()
|
|
defer s.mu.RUnlock()
|
|
return s.selected
|
|
}
|
|
|
|
// Set updates the currently selected model.
|
|
func (s *Store) Set(model string) {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
s.selected = model
|
|
}
|