Files
sankalp ede489c219 fix: resolve 8 bugs affecting real users
- Fix KeyError 'root' in FileGrouper when merging groups with no root-level files
- Fix changelog commit parsing breaking on multiline bodies (use %x00 separator)
- Add empty choices/content checks in OpenAI, Anthropic, OpenRouter providers
- Fix config edit crash when config is empty
- Fix validate command using wrong color for 'no staged files'
- Add type check for corrupted YAML config (non-dict returns empty dict)
2026-06-16 14:36:19 +05:45

22 lines
687 B
Python

import anthropic
from devgen.providers.base import BaseProvider
class AnthropicProvider(BaseProvider):
"""Generates content using Anthropic's Claude models."""
DISPLAY_NAME = "Anthropic"
DEFAULT_MODEL = "claude-3-opus-20240229"
def _generate(self, prompt, api_key, model, **kwargs):
client = anthropic.Anthropic(api_key=api_key)
message = client.messages.create(
model=model,
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
if not message.content:
raise RuntimeError(f"Anthropic returned no content for model {model!r}.")
return message.content[0].text or ""