diff --git a/telegram/telegram.go b/telegram/telegram.go index 212fdc6..06a084c 100644 --- a/telegram/telegram.go +++ b/telegram/telegram.go @@ -38,6 +38,7 @@ type Config struct { WhitelistChats []int64 `json:"whitelistChats"` ComicPath string `json:"comicPath"` DeleteDelay string `json:"deleteDelay"` + OpenAIBaseURL string `json:"openAIBaseURL"` OpenAIKey string `json:"openAIKey"` } @@ -113,8 +114,10 @@ func (b *Bot) WithMeilisearch(meili *meilisearch.Client) *Bot { return b } -func (b *Bot) WithOpenAI(key string) *Bot { - b.ai = openai.NewClient(key) +func (b *Bot) WithOpenAI(baseURL, key string) *Bot { + config := openai.DefaultConfig(key) + config.BaseURL = baseURL + b.ai = openai.NewClientWithConfig(config) return b } diff --git a/yubari.go b/yubari.go index e8a45b1..dfc6ed2 100644 --- a/yubari.go +++ b/yubari.go @@ -88,7 +88,7 @@ func main() { telegramBot = telegramBot.WithPixiv(pixivBot) if cfg.Telegram.OpenAIKey != "" { logger.Debug("bot: openai: enabled") - telegramBot = telegramBot.WithOpenAI(cfg.Telegram.OpenAIKey) + telegramBot = telegramBot.WithOpenAI(cfg.Telegram.OpenAIBaseURL, cfg.Telegram.OpenAIKey) } rssUpdate := make(chan string)