Skip to content

Commit d1c614d

Browse files
committed
refactor: extract vendor token identifier constant and remove redundant configure call
## CHANGES - Extract vendor token identifier into named constant - Remove redundant Configure() call from IsConfigured method - Use constant for token validation consistency - Improve code maintainability with centralized identifier
1 parent dbaa0b9 commit d1c614d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

plugins/ai/anthropic/anthropic.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const webSearchToolName = "web_search"
1919
const webSearchToolType = "web_search_20250305"
2020
const sourcesHeader = "## Sources"
2121

22+
const vendorTokenIdentifier = "claude"
23+
2224
func NewClient() (ret *Client) {
2325
vendorName := "Anthropic"
2426
ret = &Client{}
@@ -50,9 +52,6 @@ func NewClient() (ret *Client) {
5052

5153
// IsConfigured returns true if either the API key or OAuth is configured
5254
func (an *Client) IsConfigured() bool {
53-
// First configure to load values from environment variables
54-
an.Configure()
55-
5655
// Check if API key is configured
5756
if an.ApiKey.Value != "" {
5857
return true
@@ -66,7 +65,7 @@ func (an *Client) IsConfigured() bool {
6665
}
6766

6867
// If no valid token exists, automatically run OAuth flow
69-
if !storage.HasValidToken("claude", 5) {
68+
if !storage.HasValidToken(vendorTokenIdentifier, 5) {
7069
fmt.Println("OAuth enabled but no valid token found. Starting authentication...")
7170
_, err := RunOAuthFlow()
7271
if err != nil {

0 commit comments

Comments
 (0)