Add AI Resolver interface and Anthropic backend#148
Open
vivekkrishna wants to merge 1 commit into
Open
Conversation
Introduces clicker/internal/ai — a model-agnostic Resolver interface with an Anthropic Messages API implementation. Prompt caching is enabled via cache_control markers (ephemeral) on the image block for vision requests and on the text block for text-only requests, reducing input token cost on repeated calls within the same page context. API key is read from VIBIUM_ANTHROPIC_API_KEY. ModelHaiku and ModelSonnet constants are exported for use by the locator pipeline. A test-only constructor (NewAnthropicResolverForTest) accepts a custom base URL so unit tests run against httptest.Server without hitting the real API. The integration test is skipped unless the env var is set. This is the foundation for the AI-powered locator pipeline (PR 1 of 8). See: VibiumDev#138
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clicker/internal/ai— a model-agnosticResolverinterface with a singleResolve(ctx, Request) (Response, error)methodAnthropicResolverimplementation calls the Anthropic Messages API via standardnet/http(no SDK dependency)cache_control: ephemeral— on the image block for vision requests, on the text block for text-only requests (~90% input token cost reduction on repeated calls within the same page context)VIBIUM_ANTHROPIC_API_KEY, consistent with existingVIBIUM_env var conventionModelHaikuandModelSonnetconstants exported for use by the locator pipelineTest plan
go test ./clicker/internal/ai/...— 5 unit tests pass (mock + httptest server, no API key needed)go test ./clicker/internal/ai/... -run Integration -v— real Anthropic API call verified (Haiku, 1.37s)go build ./clicker/internal/...compiles cleanContext
This is PR 1 of 8 for the AI-powered locator feature.
Architecture discussion: #138