Files
sure/app/models/provider
Guillem Arias c1dbb51553 feat(ai): add Anthropic provider with chat parity (1/5)
Introduces Provider::Anthropic alongside Provider::Openai, implementing
the LlmConcept chat_response contract over the official anthropic Ruby
SDK. Batch ops, PDF, and RAG land in follow-up PRs.

- Provider::Anthropic uses Messages API for sync and streaming responses
- ChatConfig builds requests with ephemeral prompt-cache markers on the
  system prompt and the last tool definition
- MessageFormatter reconstructs multi-turn history (text + tool_use +
  tool_result blocks) from raw Message records, including the paired
  user-role tool_result turn Anthropic requires after every tool_use
- ChatParser maps Anthropic Message into the shared ChatResponse Data
- Registry, Setting, User, Chat default model wired for ANTHROPIC_*
  envs and Setting.anthropic_*; LLM_PROVIDER selects between providers
- Responder forwards raw conversation_history (Array<Message>) so
  providers without hosted conversation state can rebuild context
- OpenAI provider accepts and ignores the new kwarg (no behavior change)

Tests cover provider init, model gating, MessageFormatter for all turn
shapes, ChatConfig request building (max_tokens, system cache, tool
conversion), ChatParser for text / tool_use / mixed blocks, Registry
discovery, and mocked chat_response success / error / function_request
paths. Live VCR cassettes recorded in a follow-up with a real key.

Stacked PRs: 2/5 batch ops + cost ledger, 3/5 PDF, 4/5 pgvector RAG,
5/5 settings UI + disclosure.
2026-05-25 16:29:53 +02:00
..
2025-11-24 19:52:34 +01:00
2026-04-11 21:37:07 +02:00
2025-11-25 20:21:29 +01:00
2026-04-09 18:33:59 +02:00
2025-11-24 19:52:34 +01:00
2025-08-05 23:35:01 +02:00
2026-04-09 18:33:59 +02:00
2026-05-10 22:13:57 +02:00
2026-05-10 22:13:57 +02:00
2025-09-24 00:19:51 +02:00
2025-10-28 19:32:27 +01:00
2026-04-09 18:33:59 +02:00