Files
Fabric/plugins/ai/azure/azure.go
2025-02-11 22:22:36 +00:00

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
}