coai/adapter/palm2/struct.go
2023-09-30 21:09:14 +08:00

34 lines
574 B
Go

package palm2
import (
"chat/utils"
"github.com/spf13/viper"
)
type ChatInstance struct {
Endpoint string
ApiKey string
}
func (c *ChatInstance) GetApiKey() string {
return c.ApiKey
}
func (c *ChatInstance) GetEndpoint() string {
return c.Endpoint
}
func NewChatInstance(endpoint string, apiKey string) *ChatInstance {
return &ChatInstance{
Endpoint: endpoint,
ApiKey: apiKey,
}
}
func NewChatInstanceFromConfig() *ChatInstance {
return NewChatInstance(
viper.GetString("palm2.endpoint"),
utils.GetRandomKey(viper.GetString("palm2.apikey")),
)
}