mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 22:50:18 +00:00
added expection for missing key
This commit is contained in:
@@ -21,6 +21,8 @@ class Anthropic(BaseProvider):
|
||||
@property
|
||||
def client(self):
|
||||
"""The raw Anthropic client."""
|
||||
if not self.api_key:
|
||||
raise ValueError("Anthropic API key is required")
|
||||
return anthropic.Anthropic(api_key=self.api_key)
|
||||
|
||||
@property
|
||||
|
||||
@@ -20,6 +20,8 @@ class Groq(BaseProvider):
|
||||
@property
|
||||
def client(self):
|
||||
"""The raw Groq client."""
|
||||
if not self.api_key:
|
||||
raise ValueError("Groq API key is required")
|
||||
return groq.Groq(api_key=self.api_key)
|
||||
|
||||
@property
|
||||
@@ -43,7 +45,7 @@ class Groq(BaseProvider):
|
||||
# Create and return a properly formatted Message instance
|
||||
return Message(
|
||||
role="assistant",
|
||||
text=assistant_message.content,
|
||||
text=assistant_message.content or "",
|
||||
raw=response,
|
||||
llm_model=conversation.llm_model or DEFAULT_MODEL,
|
||||
llm_provider=PROVIDER_NAME,
|
||||
|
||||
@@ -20,6 +20,8 @@ class OpenAI(BaseProvider):
|
||||
@property
|
||||
def client(self):
|
||||
"""The raw OpenAI client."""
|
||||
if not self.api_key:
|
||||
raise ValueError("OpenAI API key is required")
|
||||
return oa.OpenAI(api_key=self.api_key)
|
||||
|
||||
@property
|
||||
|
||||
@@ -22,10 +22,11 @@ class XAI(BaseProvider):
|
||||
@property
|
||||
def client(self):
|
||||
"""The raw OpenAI client."""
|
||||
|
||||
if not self.api_key:
|
||||
raise ValueError("XAI API key is required")
|
||||
return oa.OpenAI(
|
||||
api_key=settings.XAI_API_KEY,
|
||||
base_url="https://api.x.ai/v1",
|
||||
api_key=self.api_key,
|
||||
base_url=BASE_URL,
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user