mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-01-08 22:08:03 -05:00
36 lines
866 B
Go
36 lines
866 B
Go
package azure
|
|
|
|
import (
|
|
"github.com/danielmiessler/fabric/plugins"
|
|
"github.com/danielmiessler/fabric/plugins/ai/openai"
|
|
goopenai "github.com/sashabaranov/go-openai"
|
|
"strings"
|
|
)
|
|
|
|
func NewClient() (ret *Client) {
|
|
ret = &Client{}
|
|
ret.Client = openai.NewClientCompatible("Azure", "", ret.configure)
|
|
ret.ApiDeployments = ret.AddSetupQuestionCustom("deployments", true,
|
|
"Enter your Azure deployments (comma separated)")
|
|
|
|
return
|
|
}
|
|
|
|
type Client struct {
|
|
*openai.Client
|
|
ApiDeployments *plugins.SetupQuestion
|
|
|
|
apiDeployments []string
|
|
}
|
|
|
|
func (oi *Client) configure() (err error) {
|
|
oi.apiDeployments = strings.Split(oi.ApiDeployments.Value, ",")
|
|
oi.ApiClient = goopenai.NewClientWithConfig(goopenai.DefaultAzureConfig(oi.ApiKey.Value, oi.ApiBaseURL.Value))
|
|
return
|
|
}
|
|
|
|
func (oi *Client) ListModels() (ret []string, err error) {
|
|
ret = oi.apiDeployments
|
|
return
|
|
}
|