mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +09:00
34 lines
570 B
Go
34 lines
570 B
Go
package claude
|
|
|
|
import (
|
|
"chat/utils"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
type ChatInstance struct {
|
|
Endpoint string
|
|
ApiKey string
|
|
}
|
|
|
|
func NewChatInstance(endpoint, apiKey string) *ChatInstance {
|
|
return &ChatInstance{
|
|
Endpoint: endpoint,
|
|
ApiKey: apiKey,
|
|
}
|
|
}
|
|
|
|
func NewChatInstanceFromConfig() *ChatInstance {
|
|
return NewChatInstance(
|
|
viper.GetString("claude.endpoint"),
|
|
utils.GetRandomKey(viper.GetString("claude.apikey")),
|
|
)
|
|
}
|
|
|
|
func (c *ChatInstance) GetEndpoint() string {
|
|
return c.Endpoint
|
|
}
|
|
|
|
func (c *ChatInstance) GetApiKey() string {
|
|
return c.ApiKey
|
|
}
|