Skip to content

Commit

Permalink
Another config updated needed for ANTHROPIC_API_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbickett committed Mar 20, 2024
1 parent f9772a7 commit 2213bbe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions operate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def __init__(self):
None # instance variables are backups in case saving to a `.env` fails
)


def initialize_openai(self):
if self.verbose:
print("[Config][initialize_openai]")
Expand Down Expand Up @@ -76,15 +75,14 @@ def initialize_google(self):
model = genai.GenerativeModel("gemini-pro-vision")

return model

def initialize_anthropic(self):
if self.anthropic_api_key:
api_key = self.anthropic_api_key
else:
api_key = os.getenv("ANTHROPIC_API_KEY")
return anthropic.Anthropic(api_key=api_key)


def validation(self, model, voice_mode):
"""
Validate the input parameters for the dialog operation.
Expand All @@ -101,7 +99,7 @@ def validation(self, model, voice_mode):
"GOOGLE_API_KEY", "Google API key", model == "gemini-pro-vision"
)
self.require_api_key(
"ANTHROPIC_API_KEY", "Anthropic API key", model == "claude-3-with-ocr"
"ANTHROPIC_API_KEY", "Anthropic API key", model == "claude-3"
)

def require_api_key(self, key_name, key_description, is_required):
Expand All @@ -127,6 +125,8 @@ def prompt_and_save_api_key(self, key_name, key_description):
self.openai_api_key = key_value
elif key_name == "GOOGLE_API_KEY":
self.google_api_key = key_value
elif key_name == "ANTHROPIC_API_KEY":
self.anthropic_api_key = key_value
self.save_api_key_to_env(key_name, key_value)
load_dotenv() # Reload environment variables
# Update the instance attribute with the new key
Expand Down

0 comments on commit 2213bbe

Please sign in to comment.