Spaces:
Running
Running
zach
commited on
Commit
·
30c882f
1
Parent(s):
adecb62
Add additional validation for required attributes in AnthropicConfig
Browse files
src/integrations/anthropic_api.py
CHANGED
@@ -59,9 +59,15 @@ When writing, tailor your tone and style to match the user's request. For exampl
|
|
59 |
Always keep your responses concise, unless explicitly instructed to elaborate."""
|
60 |
|
61 |
def __post_init__(self):
|
62 |
-
#
|
63 |
if not self.api_key:
|
64 |
raise ValueError("Anthropic API key is not set.")
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
@property
|
67 |
def client(self) -> Anthropic:
|
@@ -72,7 +78,7 @@ Always keep your responses concise, unless explicitly instructed to elaborate.""
|
|
72 |
Anthropic: Configured client instance.
|
73 |
"""
|
74 |
return Anthropic(api_key=self.api_key)
|
75 |
-
|
76 |
|
77 |
class AnthropicError(Exception):
|
78 |
"""Custom exception for errors related to the Anthropic API."""
|
|
|
59 |
Always keep your responses concise, unless explicitly instructed to elaborate."""
|
60 |
|
61 |
def __post_init__(self):
|
62 |
+
# Validate that required attributes are set
|
63 |
if not self.api_key:
|
64 |
raise ValueError("Anthropic API key is not set.")
|
65 |
+
if not self.model:
|
66 |
+
raise ValueError("Anthropic Model is not set.")
|
67 |
+
if not self.max_tokens:
|
68 |
+
raise ValueError("Anthropic Max Tokens is not set.")
|
69 |
+
if not self.system_prompt:
|
70 |
+
raise ValueError("Anthropic System Prompt is not set.")
|
71 |
|
72 |
@property
|
73 |
def client(self) -> Anthropic:
|
|
|
78 |
Anthropic: Configured client instance.
|
79 |
"""
|
80 |
return Anthropic(api_key=self.api_key)
|
81 |
+
|
82 |
|
83 |
class AnthropicError(Exception):
|
84 |
"""Custom exception for errors related to the Anthropic API."""
|