feat: add Anthropic Messages API support (#18) #21
Reference in New Issue
Block a user
Delete Branch "feat/18-anthropic-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
--llm-providerflag (openai|anthropic) to switch between API formats.Anthropic Implementation
POST /messagesendpointx-api-key+anthropic-versionheadersmax_tokens: 8192for response generation[{type: "text", text: "..."}]Changes
llm/client.go:Providertype,completeAnthropic(),doRequest()shared helpercmd/review-bot/main.go:--llm-provider/LLM_PROVIDERflag.gitea/actions/review/action.yml:llm-providerinput + envllm/client_test.go: 4 new tests for Anthropic pathBackwards compatible — default provider is still
openai.Closes #18
Adds --llm-provider flag (openai|anthropic) to switch between API formats. Anthropic implementation: - POST /messages endpoint - x-api-key + anthropic-version headers - System prompt as top-level field (not a message) - max_tokens: 8192 for response generation - Parses content blocks [{type: "text", text: "..."}] Changes: - llm/client.go: Provider type, completeAnthropic(), doRequest() shared helper - cmd/review-bot/main.go: --llm-provider / LLM_PROVIDER flag - .gitea/actions/review/action.yml: llm-provider input + env - llm/client_test.go: 4 new tests for Anthropic path Backwards compatible — default provider is still openai. Closes #18Summary
Well-scoped addition of Anthropic Messages API support with clean provider abstraction and comprehensive tests. Defaults remain backwards-compatible and the action/CLI wiring is consistent.
Recommendation
APPROVE — The implementation cleanly introduces a provider switch with minimal disruption, adds appropriate headers and request/response handling for Anthropic, and covers the new paths with tests. The shared request helper improves code reuse and error reporting. CI has passed. Consider a future minor refinement to align the comment in completeAnthropic with its behavior (it currently uses the last system message encountered), but this is non-blocking. Proceed to merge.
Summary
The PR cleanly adds Anthropic Messages API support with a provider abstraction, shared HTTP handling, and tests. Changes are well-structured, tests cover new paths, and CI passed.
Findings
llm/client.gollm/client.gocmd/review-bot/main.go.gitea/actions/review/action.ymlllm/client_test.gollm/client.goRecommendation
APPROVE — Approve: the implementation is sound and the new provider abstraction is well integrated. Address the minor items to improve configurability and robustness: make Anthropic max_tokens configurable (or document the rationale), confirm the message payload shape exactly matches Anthropic's spec, optionally tighten tests that compare floats by value, and remove the trailing space in the action.yml default. Otherwise this is ready to merge.