Skip to content

feat: add Claude/Gemini CLI and Anthropic API LLM providers - #205

Closed
23f3001304 wants to merge 1 commit into
interviewstreet:mainfrom
23f3001304:feat/cli-providers
Closed

feat: add Claude/Gemini CLI and Anthropic API LLM providers#205
23f3001304 wants to merge 1 commit into
interviewstreet:mainfrom
23f3001304:feat/cli-providers

Conversation

@23f3001304

Copy link
Copy Markdown

Summary

Closes #204

Adds support for driving the pipeline through the Claude Code and Gemini command-line tools (and the Anthropic Claude HTTP API) as LLM backends, alongside the existing Ollama and Gemini API providers. The CLI backends reuse your existing claude / gemini login, so you can run the agent without managing API keys.

This change is purely additive. Ollama and the Gemini API continue to work exactly as before.

New providers

LLM_PROVIDER Backend Auth
ollama local models (existing) none
gemini Google Gemini HTTP API (existing) GEMINI_API_KEY
claude Anthropic Claude HTTP API (new) ANTHROPIC_API_KEY
claude_cli Claude Code CLI claude -p (new) your claude login
gemini_cli Gemini CLI (new) your gemini login

Select a backend in .env:

LLM_PROVIDER=claude_cli
DEFAULT_MODEL=opus        # or claude-sonnet-4-6, gemini-2.5-pro, gemma3:4b, ...

Provider selection

  • When LLM_PROVIDER is set, it is authoritative.
  • When unset, the provider is inferred from the model name (existing behavior, unchanged).
  • If a provider's prerequisite is missing (API key unset, or CLI not installed/logged in), it logs a warning and falls back to Ollama.

Implementation notes

All providers conform to the existing chat() contract and return the same {"message": {"content": ...}} shape, so pdf.py / evaluator.py / github.py did not need changes to call them.

The CLI providers are built to be robust:

  • Lean, non-agentic one-shot. claude -p runs with --system-prompt (replacing the large built-in coding-agent prompt), --tools "" (no tool use), and --output-format json. This greatly reduces per-call token overhead and avoids agentic behavior in headless mode.
  • Use the CLI's own login. API-key env vars are stripped from the CLI subprocess so a stray/placeholder key in .env can't cause 401 Invalid API key.
  • Windows-friendly. npm .cmd shims are resolved via PATH and run through cmd /c; the full prompt is piped over stdin to dodge command-line length/quoting limits.
  • Resilient. Transient failures retry with backoff, and the real error (including the CLI's JSON error envelope) is surfaced.

Other improvements

  • Extraction progress logging (pdf.py): each section logs [i/n] progress with timing at INFO level, so runs aren't silent.
  • GitHub rate-limit handling (github.py): logs whether GITHUB_TOKEN is present (and the 60 vs 5000 req/hour implication), and replaces the previous up-to-1-hour blocking sleep with a short, configurable cap (GITHUB_MAX_RATE_LIMIT_WAIT, default 60s) that skips the wait instead of hanging.

Config / docs

  • requirements.txt: adds anthropic.
  • .env.example: documents all providers, CLI options, and GITHUB_TOKEN; API-key placeholders are commented out so they don't break CLI/API auth by accident.
  • README.md: updated prerequisites, configuration table, and provider details.

Backward compatibility

Existing ollama and gemini setups behave identically. No changes to the pipeline flow, prompts, or output schema.

Testing

  • Ran claude_cli and gemini_cli end-to-end on Windows: section extraction and the evaluation step both return valid, schema-conforming JSON.
  • Verified provider selection across configurations (env-set vs model-name inference, and missing-prerequisite fallback to Ollama).
  • Confirmed the existing Ollama/Gemini selection and import paths are unaffected.

Copilot AI review requested due to automatic review settings June 7, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Anthropic Claude support (API + CLI) and CLI-based routing, plus improved logging for GitHub rate limiting and PDF section extraction.

Changes:

  • Add Anthropic (Claude) API provider and Claude/Gemini CLI providers with shared CLI execution utilities.
  • Add provider inference/override logic via LLM_PROVIDER, new env vars, and model/provider mappings.
  • Improve operational logging for GitHub API rate limits and per-section PDF extraction timing.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
requirements.txt Adds Anthropic SDK dependency for Claude API support.
prompt.py Adds Claude model entries, provider explicitness handling, and new env vars for API keys/CLI commands.
pdf.py Adds progress/timing logs while extracting resume sections.
models.py Introduces Claude API + CLI providers, Gemini CLI provider, and shared CLI execution helpers.
llm_utils.py Adds provider resolution (explicit vs inferred) and initializes new providers with fallback behavior.
github.py Improves GitHub rate-limit handling/logging and reduces blocking waits.
README.md Documents new supported providers, config, and CLI setup.
.env.example Updates example configuration for new provider modes and CLI options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .env.example Outdated
Comment thread prompt.py Outdated
Comment thread models.py
Add claude_cli, gemini_cli, and claude (Anthropic API) backends alongside the existing Ollama and Gemini providers. LLM_PROVIDER selects the backend, with a graceful fallback to Ollama when a prerequisite (API key or installed CLI) is missing. The CLI providers run as a lean, non-agentic one-shot and authenticate with the local CLI login.

Also add per-section extraction progress logging, cap the GitHub rate-limit wait instead of blocking for up to an hour, and document GITHUB_TOKEN.
@sp2hari

sp2hari commented Jul 24, 2026

Copy link
Copy Markdown
Member

Thanks for adding Claude support! Since this was opened, #298 made the provider layer fully config-driven — Anthropic ships an OpenAI-compatible endpoint, so Claude now works with zero new code via a providers.json block (see #365). That supersedes the bespoke provider class here. Closing as superseded — genuinely appreciate the contribution.

@sp2hari sp2hari closed this Jul 24, 2026
pull Bot pushed a commit to BeeXD/hiring-agent that referenced this pull request Jul 24, 2026
Add an `anthropic` provider block to providers.json using Anthropic's
OpenAI-compatible endpoint (https://api.anthropic.com/v1). No new code is
needed — the config-driven OpenAICompatibleProvider (from interviewstreet#298) handles it,
the same way Gemini is wired via its OpenAI-compatible endpoint.

Registers claude-opus-4-8, claude-sonnet-5, and claude-haiku-4-5, keyed on
ANTHROPIC_API_KEY. structured_output is set to json_object (Anthropic's
OpenAI-compatible layer has limited json_schema support; the pipeline also
cleans up JSON via extract_json_from_response).

Supersedes the pre-interviewstreet#298 Claude-provider PRs that added bespoke provider
classes: interviewstreet#205, interviewstreet#224, interviewstreet#235, interviewstreet#279, interviewstreet#303, interviewstreet#330, interviewstreet#348.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add Claude/Gemini CLI and Anthropic Claude API as LLM backends

3 participants