redhat-et / copilot-ops

copilot-ops is a CLI tool that boosts up any DevOps repo to a ninja level of Artificially Intelligent Ops Repo
Apache License 2.0
34 stars 13 forks source link

generalize overriding default values via CLI #108

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

FIXME: create default config methods for these

https://github.com/redhat-et/copilot-ops/blob/63d4c21def30e1cabd1c0e3769000d38b0911fae/pkg/cmd/utils.go#L79


    if err := conf.Load(); err != nil {
        return nil, err
    }
    // TODO: generalize overriding default values via CLI
    conf.SetDefaults()
    // override OpenAI URL
    if openAIURL != "" {
        conf.OpenAI.BaseURL = openAIURL
    }

    // load files
    fm := filemap.NewFilemap()
    if err := fm.LoadFiles(files); err != nil {
        log.Fatalf("error loading files: %s\n", err.Error())
    }
    if len(filesets) > 0 {
        log.Printf("loading filesets: %v\n", filesets)
    }
    if err := fm.LoadFilesets(filesets, conf, config.ConfigFile); err != nil {
        log.Fatalf("error loading filesets: %s\n", err.Error())
    }
    filemapText := fm.EncodeToInputText()

    // select backend type
    selectedBackend := ai.Backend(aiBackend)
    if selectedBackend == "" {
        selectedBackend = conf.Backend
    }

    // configure backends
    // FIXME: create default config methods for these
    r := Request{
        Config:       conf,
        Filemap:      fm,
        FilemapText:  filemapText,
        UserRequest:  request,
        IsWrite:      write,
        OutputType:   outputType,
        NTokens:      nTokens,
        NCompletions: nCompletions,
        Backend:      selectedBackend,
    }

    return &r, nil