coai/adapter/midjourney/struct.go
2023-12-02 11:08:39 +08:00

37 lines
620 B
Go

package midjourney
import (
"chat/globals"
)
type ChatInstance struct {
Endpoint string
ApiSecret string
}
func (c *ChatInstance) GetApiSecret() string {
return c.ApiSecret
}
func (c *ChatInstance) GetEndpoint() string {
return c.Endpoint
}
func NewChatInstance(endpoint, apiSecret, whiteList string) *ChatInstance {
SaveWhiteList(whiteList)
return &ChatInstance{
Endpoint: endpoint,
ApiSecret: apiSecret,
}
}
func NewChatInstanceFromConfig(conf globals.ChannelConfig) *ChatInstance {
params := conf.SplitRandomSecret(2)
return NewChatInstance(
conf.GetEndpoint(),
params[0], params[1],
)
}