Skip to content

Commit

Permalink
Support OpenAI API token for AI Assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec committed Nov 5, 2024
1 parent 67c5038 commit 6b7363b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/source/ai-brain/assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func newAssistant(cfg *Config, log logrus.FieldLogger, out chan source.Event, ku
return nil, fmt.Errorf("while creating Botkube runner: %w", err)
}

config := openai.DefaultConfig("")
config := openai.DefaultConfig(cfg.OpenAIAPIToken)
config.BaseURL = cfg.OpenAIBaseURL
config.AssistantVersion = "v2"

Expand Down
6 changes: 5 additions & 1 deletion internal/source/ai-brain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const assistantID = "asst_eMM9QaWLi6cajHE4PdG1yU53"
type Config struct {
Log config.Logger `yaml:"log"`
OpenAIBaseURL string `yaml:"openAIBaseURL"`
OpenAIAssistantID string `yaml:"openAIAssistantId"`
OpenAIAssistantID string `yaml:"openAIAssistantID"`
OpenAIAPIToken string `yaml:"openAIAPIToken"`
HoneycombAPIKey string `yaml:"honeycombAPIKey"`
HoneycombSampleRate int `yaml:"honeycombSampleRate"`
VectorStoreIDForThread string `yaml:"vectorStoreIDForThread"`
Expand All @@ -30,6 +31,9 @@ func (c *Config) Validate() error {
if c.OpenAIAssistantID == "" {
issues = multierror.Append(issues, errors.New("the Open AI Assistant ID cannot be empty"))
}
if c.OpenAIAPIToken == "" {
issues = multierror.Append(issues, errors.New("the Open AI API token cannot be empty"))
}
return issues.ErrorOrNil()
}

Expand Down

0 comments on commit 6b7363b

Please sign in to comment.