Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions provider/autoconfig/autoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,25 @@ var _ Config = netconfig{}

// Configure LLM interface using ~/.netrc configuration
func FromNetRC(host string, model ...string) (chatter.Chatter, error) {
return FromFile(".netrc", host, model...)
}

// Configure LLM interface using custom rc configuration file,
// typically located at ~/.<file>, file is relative to home directory.
func FromFile(file, host string, model ...string) (chatter.Chatter, error) {
usr, err := user.Current()
if err != nil {
return nil, err
}

n, err := netrc.Parse(filepath.Join(usr.HomeDir, ".netrc"))
n, err := netrc.Parse(filepath.Join(usr.HomeDir, file))
if err != nil {
return nil, err
}

machine := n.Machine(host)
if machine == nil {
return nil, fmt.Errorf("undefined config for <%s> at ~/.netrc", host)
return nil, fmt.Errorf("undefined config for <%s> at %s", host, file)
}

return New(netconfig{machine: machine}, model...)
Expand Down
2 changes: 1 addition & 1 deletion provider/autoconfig/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

package autoconfig

const Version = "provider/autoconfig/v0.10.0"
const Version = "provider/autoconfig/v0.11.0"
Loading