Skip to content

Add AI Resolver interface and Anthropic backend#148

Open
vivekkrishna wants to merge 1 commit into
VibiumDev:mainfrom
vivekkrishna:feat/ai-resolver
Open

Add AI Resolver interface and Anthropic backend#148
vivekkrishna wants to merge 1 commit into
VibiumDev:mainfrom
vivekkrishna:feat/ai-resolver

Conversation

@vivekkrishna

Copy link
Copy Markdown

Summary

  • Introduces clicker/internal/ai — a model-agnostic Resolver interface with a single Resolve(ctx, Request) (Response, error) method
  • Concrete AnthropicResolver implementation calls the Anthropic Messages API via standard net/http (no SDK dependency)
  • Prompt caching enabled via 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)
  • API key read from VIBIUM_ANTHROPIC_API_KEY, consistent with existing VIBIUM_ env var convention
  • ModelHaiku and ModelSonnet constants exported for use by the locator pipeline

Test 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 clean

Context

This is PR 1 of 8 for the AI-powered locator feature.
Architecture discussion: #138

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant