mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 04:50:14 +09:00
42 lines
755 B
Go
42 lines
755 B
Go
package baichuan
|
|
|
|
import (
|
|
factory "chat/adapter/common"
|
|
"chat/globals"
|
|
"fmt"
|
|
)
|
|
|
|
type ChatInstance struct {
|
|
Endpoint string
|
|
ApiKey string
|
|
}
|
|
|
|
func (c *ChatInstance) GetEndpoint() string {
|
|
return c.Endpoint
|
|
}
|
|
|
|
func (c *ChatInstance) GetApiKey() string {
|
|
return c.ApiKey
|
|
}
|
|
|
|
func (c *ChatInstance) GetHeader() map[string]string {
|
|
return map[string]string{
|
|
"Content-Type": "application/json",
|
|
"Authorization": fmt.Sprintf("Bearer %s", c.GetApiKey()),
|
|
}
|
|
}
|
|
|
|
func NewChatInstance(endpoint, apiKey string) *ChatInstance {
|
|
return &ChatInstance{
|
|
Endpoint: endpoint,
|
|
ApiKey: apiKey,
|
|
}
|
|
}
|
|
|
|
func NewChatInstanceFromConfig(conf globals.ChannelConfig) factory.Factory {
|
|
return NewChatInstance(
|
|
conf.GetEndpoint(),
|
|
conf.GetRandomSecret(),
|
|
)
|
|
}
|