from __future__ import annotations from anthropic import Anthropic MODEL = "claude-sonnet-4-6" class ClaudeClient: def __init__(self, api_key: str): self._client = Anthropic(api_key=api_key) def generate_report(self, system_prompt: str, user_prompt: str) -> str: response = self._client.messages.create( model=MODEL, max_tokens=4096, system=system_prompt, messages=[{"role": "user", "content": user_prompt}], ) return "".join( block.text for block in response.content if block.type == "text" ) def chat(self, messages: list[dict], system_prompt: str) -> str: """Send a conversational turn and return the assistant response.""" response = self._client.messages.create( model=MODEL, max_tokens=8192, system=system_prompt, messages=messages, ) return "".join( block.text for block in response.content if block.type == "text" ) def chat_stream(self, messages: list[dict], system_prompt: str): """Return a streaming context manager that yields text chunks.""" return self._client.messages.stream( model=MODEL, max_tokens=8192, system=system_prompt, messages=messages, )