diff --git a/simplemind/providers/anthropic.py b/simplemind/providers/anthropic.py index e4cdb7a..328577f 100644 --- a/simplemind/providers/anthropic.py +++ b/simplemind/providers/anthropic.py @@ -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 diff --git a/simplemind/providers/groq.py b/simplemind/providers/groq.py index 465f428..ec5e6ac 100644 --- a/simplemind/providers/groq.py +++ b/simplemind/providers/groq.py @@ -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, diff --git a/simplemind/providers/openai.py b/simplemind/providers/openai.py index 4eb2795..2006f0c 100644 --- a/simplemind/providers/openai.py +++ b/simplemind/providers/openai.py @@ -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 diff --git a/simplemind/providers/xai.py b/simplemind/providers/xai.py index 04b9709..df4cc92 100644 --- a/simplemind/providers/xai.py +++ b/simplemind/providers/xai.py @@ -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