Update CerebrasLLMService docstrings

This commit is contained in:
Mark Backman
2025-06-26 10:26:42 -04:00
parent 9cbe85bf99
commit 3828df8cf9

View File

@@ -4,6 +4,8 @@
# SPDX-License-Identifier: BSD 2-Clause License # SPDX-License-Identifier: BSD 2-Clause License
# #
"""Cerebras LLM service implementation using OpenAI-compatible interface."""
from typing import List from typing import List
from loguru import logger from loguru import logger
@@ -21,10 +23,10 @@ class CerebrasLLMService(OpenAILLMService):
maintaining full compatibility with OpenAI's interface and functionality. maintaining full compatibility with OpenAI's interface and functionality.
Args: Args:
api_key (str): The API key for accessing Cerebras's API api_key: The API key for accessing Cerebras's API.
base_url (str, optional): The base URL for Cerebras API. Defaults to "https://api.cerebras.ai/v1" base_url: The base URL for Cerebras API. Defaults to "https://api.cerebras.ai/v1".
model (str, optional): The model identifier to use. Defaults to "llama-3.3-70b" model: The model identifier to use. Defaults to "llama-3.3-70b".
**kwargs: Additional keyword arguments passed to OpenAILLMService **kwargs: Additional keyword arguments passed to OpenAILLMService.
""" """
def __init__( def __init__(
@@ -38,7 +40,16 @@ class CerebrasLLMService(OpenAILLMService):
super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs)
def create_client(self, api_key=None, base_url=None, **kwargs): def create_client(self, api_key=None, base_url=None, **kwargs):
"""Create OpenAI-compatible client for Cerebras API endpoint.""" """Create OpenAI-compatible client for Cerebras API endpoint.
Args:
api_key: The API key for authentication. If None, uses instance key.
base_url: The base URL for the API. If None, uses instance URL.
**kwargs: Additional arguments passed to the client constructor.
Returns:
An OpenAI-compatible client configured for Cerebras API.
"""
logger.debug(f"Creating Cerebras client with api {base_url}") logger.debug(f"Creating Cerebras client with api {base_url}")
return super().create_client(api_key, base_url, **kwargs) return super().create_client(api_key, base_url, **kwargs)
@@ -48,14 +59,14 @@ class CerebrasLLMService(OpenAILLMService):
"""Create a streaming chat completion using Cerebras's API. """Create a streaming chat completion using Cerebras's API.
Args: Args:
context (OpenAILLMContext): The context object containing tools configuration context: The context object containing tools configuration
and other settings for the chat completion. and other settings for the chat completion.
messages (List[ChatCompletionMessageParam]): The list of messages comprising messages: The list of messages comprising
the conversation history and current request. the conversation history and current request.
Returns: Returns:
AsyncStream[ChatCompletionChunk]: A streaming response of chat completion A streaming response of chat completion
chunks that can be processed asynchronously. chunks that can be processed asynchronously.
""" """
params = { params = {
"model": self.model_name, "model": self.model_name,