moved config into proxy package

This commit is contained in:
Benson Wong
2024-10-04 09:38:30 -07:00
parent 7475bf0fff
commit d061819fb1
3 changed files with 4 additions and 7 deletions

31
proxy/config.go Normal file
View File

@@ -0,0 +1,31 @@
package proxy
import (
"os"
"gopkg.in/yaml.v3"
)
type ModelConfig struct {
Cmd string `yaml:"cmd"`
Proxy string `yaml:"proxy"`
}
type Config struct {
Models map[string]ModelConfig `yaml:"models"`
}
func LoadConfig(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var config Config
err = yaml.Unmarshal(data, &config)
if err != nil {
return nil, err
}
return &config, nil
}

View File

@@ -13,20 +13,18 @@ import (
"sync"
"syscall"
"time"
"github.com/mostlygeek/go-llama-cpp-proxy/config"
)
type ProxyManager struct {
sync.Mutex
config *config.Config
config *Config
currentCmd *exec.Cmd
currentModel string
currentProxy string
}
func New(config *config.Config) *ProxyManager {
func New(config *Config) *ProxyManager {
return &ProxyManager{config: config}
}