mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-15 00:15:15 -05:00
## CHANGES - Add NeedsRawMode to Vendor interface - Implement NeedsRawMode in all AI clients - Return false for all implementations - Support model-specific raw mode detection - Enable future raw mode requirements
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package exolab
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/danielmiessler/fabric/plugins"
|
|
"github.com/danielmiessler/fabric/plugins/ai/openai"
|
|
|
|
goopenai "github.com/sashabaranov/go-openai"
|
|
)
|
|
|
|
func NewClient() (ret *Client) {
|
|
ret = &Client{}
|
|
ret.Client = openai.NewClientCompatibleNoSetupQuestions("Exolab", ret.configure)
|
|
|
|
ret.ApiBaseURL = ret.AddSetupQuestion("API Base URL", true)
|
|
ret.ApiBaseURL.Value = "http://localhost:52415"
|
|
|
|
ret.ApiModels = ret.AddSetupQuestionCustom("models", true,
|
|
"Enter your deployed Exolab models (comma separated)")
|
|
|
|
return
|
|
}
|
|
|
|
type Client struct {
|
|
*openai.Client
|
|
ApiModels *plugins.SetupQuestion
|
|
|
|
apiModels []string
|
|
}
|
|
|
|
func (oi *Client) configure() (err error) {
|
|
oi.apiModels = strings.Split(oi.ApiModels.Value, ",")
|
|
|
|
config := goopenai.DefaultConfig("")
|
|
config.BaseURL = oi.ApiBaseURL.Value
|
|
|
|
oi.ApiClient = goopenai.NewClientWithConfig(config)
|
|
return
|
|
}
|
|
|
|
func (oi *Client) ListModels() (ret []string, err error) {
|
|
ret = oi.apiModels
|
|
return
|
|
}
|
|
|
|
func (oi *Client) NeedsRawMode(modelName string) bool {
|
|
return false
|
|
}
|