mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-10 07:10:31 +00:00
24 lines
499 B
Go
24 lines
499 B
Go
|
package grocq
|
||
|
|
||
|
import (
|
||
|
"github.com/danielmiessler/fabric/vendors/openai"
|
||
|
goopenai "github.com/sashabaranov/go-openai"
|
||
|
)
|
||
|
|
||
|
func NewClient() (ret *Client) {
|
||
|
ret = &Client{}
|
||
|
ret.Client = openai.NewClientCompatible("Grocq", ret.configure)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
type Client struct {
|
||
|
*openai.Client
|
||
|
}
|
||
|
|
||
|
func (oi *Client) configure() (err error) {
|
||
|
config := goopenai.DefaultConfig(oi.ApiKey.Value)
|
||
|
config.BaseURL = "https://api.groq.com/openai/v1"
|
||
|
oi.ApiClient = goopenai.NewClientWithConfig(config)
|
||
|
return
|
||
|
}
|