Module genai_apis.anthropic_api
Classes
class AnthropicAPI (client)
-
Abstract base class for text generation APIs.
Expand source code
class AnthropicAPI(TextGenerationAPI): def __init__(self, client): self.client = client async def generate_text(self, model, prompt, system_instruction="", **kwargs): messages = [{"role": "user", "content": prompt}] response = await self.client.messages.create( model=model, system=system_instruction, messages=messages, **kwargs, ) if "stream" in kwargs and kwargs["stream"] is True: return _get_stream_outputs(response) else: return response.content[0].text
Ancestors
Inherited members