Skip to content

Commit

Permalink
feat: support custom base url
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Apr 22, 2024
1 parent bd634d0 commit 72400a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion yubari.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 72400a1

Please sign in to comment.