feat: allow to set a baseurl (#310)

* feat: allow to set a baseURL for OpenAI providers

This allows to run local models that have a compatible OpenAI API, or
for instance use a proxy.

Signed-off-by: mudler <mudler@mocaccino.org>

* feat: allow to set baseURL in the auth subcommand

Signed-off-by: mudler <mudler@mocaccino.org>

---------

Signed-off-by: mudler <mudler@mocaccino.org>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
Co-authored-by: Matthis <99146727+matthisholleville@users.noreply.github.com>
This commit is contained in:
Ettore Di Giacinto
2023-04-21 21:04:34 +02:00
committed by GitHub
parent 754bf917e1
commit cf797a6eb6
4 changed files with 23 additions and 2 deletions

View File

@@ -37,6 +37,12 @@ type OpenAIClient struct {
func (c *OpenAIClient) Configure(config IAIConfig, language string) error {
token := config.GetPassword()
defaultConfig := openai.DefaultConfig(token)
baseURL := config.GetBaseURL()
if baseURL != "" {
defaultConfig.BaseURL = baseURL
}
client := openai.NewClientWithConfig(defaultConfig)
if client == nil {
return errors.New("error creating OpenAI client")