diff --git a/cmd/main.go b/cmd/main.go index e09c11c..76253e1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -179,7 +179,9 @@ func parseConfig(ctx context.Context) (bool, error) { fmt.Println(model) } fmt.Println() - fmt.Printf("Currently selected model: %s\n", *cfg.Model) + if cfg.Model != nil { + fmt.Printf("Currently selected model: %s\n", *cfg.Model) + } return true, nil } @@ -279,7 +281,9 @@ func cmd(ctx context.Context) error { out.Close() <-done for _, block := range blocks { - runBlock(block) + if err := runBlock(block); err != nil { + return "", err + } } return response, nil @@ -338,14 +342,11 @@ func cmd(ctx context.Context) error { func main() { flag.Parse() - ctx := context.Background() - done, err := parseConfig(ctx) + // read config first so we can use the right provider + cfg, err := config.ReadConfig() if err != nil { panic(err) } - if done { - return - } switch cfg.Provider { case config.ProviderGroq: @@ -356,6 +357,15 @@ func main() { log.Fatalf("unknown provider: %s", cfg.Provider) } + ctx := context.Background() + done, err := parseConfig(ctx) + if err != nil { + panic(err) + } + if done { + return + } + if cfg.Record { closer, err := provider.NewCacheProvider(prov, ".cache/cache.json") if err != nil {