Skip to content

refactor: adopt any-llm providers - #41

Merged
IceCodeNew merged 1 commit into
masterfrom
codex/any-llm-providers
Jul 16, 2026
Merged

refactor: adopt any-llm providers#41
IceCodeNew merged 1 commit into
masterfrom
codex/any-llm-providers

Conversation

@IceCodeNew

@IceCodeNew IceCodeNew commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace hand-written LLM wire protocol with any-llm and a strict structured-output adapter
  • pass any-llm provider IDs directly while retaining only DeepSeek environment-name compatibility
  • install all provider extras for development and leave production extras selectable
  • document the dependency boundary and add the repository rule against reimplementing maintained SDK behavior

Verification

  • 540 tests passed with branch coverage enabled
  • prek run passed all configured hooks
  • any-llm completion factory contract exercised for every registered completion provider

Local-only audit

  • repository audit risks are kept in docs/audit-risks.local.md, which is ignored and not included in this PR

Summary by CodeRabbit

  • New Features

    • Added support for configuring multiple LLM providers through a unified provider and model setup.
    • Added strict structured-output validation for more reliable briefing generation.
    • Improved compatibility with DeepSeek configuration, including fallback environment variables.
    • Enhanced request logging to preserve provider and operation context.
  • Documentation

    • Updated setup instructions and architecture requirements for the unified LLM configuration.
    • Clarified authentication, privacy, provider, and deployment configuration guidance.
  • Tests

    • Expanded coverage for provider selection, structured responses, configuration precedence, logging, and validation errors.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@IceCodeNew, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87ad9450-a863-42d3-97df-a7bcd7abca2a

📥 Commits

Reviewing files that changed from the base of the PR and between 82d3ef0 and 3cb0570.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • AGENTS.md
  • README.md
  • docs/design.md
  • docs/notes.md
  • docs/requirements.md
  • env.example
  • pyproject.toml
  • tests/test_any_llm_provider.py
  • tests/test_api_client.py
  • tests/test_cli.py
  • tests/test_config.py
  • tests/test_deepseek_provider.py
  • tests/test_llm.py
  • tests/test_openai_compatible_provider.py
  • tests/test_service.py
  • weather_briefing/api_client.py
  • weather_briefing/cli.py
  • weather_briefing/config.py
  • weather_briefing/llm.py
📝 Walkthrough

Walkthrough

The PR replaces provider-specific LLM HTTP adapters with any-llm SDK integration, adds strict structured-output validation, updates configuration and CLI wiring, introduces context-based API identity logging, and revises related tests, documentation, dependencies, and environment examples.

Changes

Any-LLM migration

Layer / File(s) Summary
Structured provider and parsing contract
weather_briefing/llm.py, tests/test_llm.py, tests/test_any_llm_provider.py, pyproject.toml
Strict Pydantic models validate structured LLM responses, AnyLLMStructuredProvider performs completions through any-llm, and parse_result maps validated data into domain models.
Configuration and CLI wiring
weather_briefing/config.py, weather_briefing/cli.py, env.example, README.md, docs/design.md, docs/requirements.md, tests/test_config.py, tests/test_cli.py
Configuration validates any-llm provider capabilities, preserves DeepSeek model and API-base fallbacks, and delegates provider construction to create_any_llm_provider.
SDK request identity instrumentation
weather_briefing/api_client.py, tests/test_api_client.py
api_call_context provides fallback provider and operation identity when request extensions are absent, while request extensions override the context.
Service validation and repository support
tests/test_service.py, AGENTS.md, .gitignore
Service fixtures include the required should_publish field, character-limit tests inspect the underlying error, and repository guidance and local audit ignores are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant create_any_llm_provider
  participant AnyLLMStructuredProvider
  participant LoggedAsyncClient
  CLI->>create_any_llm_provider: Pass provider, model, and API options
  create_any_llm_provider->>AnyLLMStructuredProvider: Build SDK-backed adapter
  AnyLLMStructuredProvider->>LoggedAsyncClient: Send structured completion request
  LoggedAsyncClient-->>AnyLLMStructuredProvider: Return completion response
  AnyLLMStructuredProvider-->>CLI: Return validated structured data
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: refactoring LLM integration to adopt any-llm providers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/any-llm-providers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@IceCodeNew
IceCodeNew requested a review from Copilot July 16, 2026 12:25

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.62%. Comparing base (6fe3e06) to head (3cb0570).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #41   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files          39       38    -1     
  Lines        5881     5944   +63     
  Branches      334      323   -11     
=======================================
+ Hits         5859     5922   +63     
  Misses         15       15           
  Partials        7        7           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@IceCodeNew
IceCodeNew force-pushed the codex/any-llm-providers branch 2 times, most recently from db065ea to 82d3ef0 Compare July 16, 2026 13:13
@IceCodeNew
IceCodeNew marked this pull request as ready for review July 16, 2026 13:21
@IceCodeNew
IceCodeNew force-pushed the codex/any-llm-providers branch from 82d3ef0 to 4f12170 Compare July 16, 2026 13:25

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
weather_briefing/api_client.py (1)

30-40: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a brief comment to clarify the side-effect.

Since the return value of api_call_extensions is ignored here, consider adding a brief comment clarifying that it is called intentionally to validate the provider and operation labels. This helps prevent future maintainers from mistakenly removing it as dead code.

💡 Proposed comment
 `@contextmanager`
 def api_call_context(provider: str, operation: str) -> Iterator[None]:
     """Classify requests made by an SDK that cannot set HTTPX extensions."""
-    api_call_extensions(provider, operation)
+    api_call_extensions(provider, operation)  # Validates label formats
     token = _CURRENT_API_CALL.set((provider, operation))
     try:
         yield
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@weather_briefing/api_client.py` around lines 30 - 40, Add a brief inline
comment immediately before the api_call_extensions call in api_call_context
explaining that the call is intentional and validates the provider and operation
labels, even though its return value is ignored.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/design.md`:
- Line 11: Update the dependency-boundary section in docs/design.md to reconcile
its statement about vendor SDKs with the installation model described near the
provider-loading guidance: clarify that model-vendor SDKs are selectively
supplied through any-llm extras rather than introduced as direct project
dependencies. Also revise the later statement around the “no model-vendor SDKs”
decision so both sections consistently reflect the changed dependency boundary.

---

Nitpick comments:
In `@weather_briefing/api_client.py`:
- Around line 30-40: Add a brief inline comment immediately before the
api_call_extensions call in api_call_context explaining that the call is
intentional and validates the provider and operation labels, even though its
return value is ignored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 03657e66-30a1-4c22-afb4-01d3c4a8f7c4

📥 Commits

Reviewing files that changed from the base of the PR and between 9f5cb8c and 82d3ef0.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • .gitignore
  • AGENTS.md
  • README.md
  • docs/design.md
  • docs/requirements.md
  • env.example
  • pyproject.toml
  • tests/test_any_llm_provider.py
  • tests/test_api_client.py
  • tests/test_cli.py
  • tests/test_config.py
  • tests/test_deepseek_provider.py
  • tests/test_llm.py
  • tests/test_openai_compatible_provider.py
  • tests/test_service.py
  • weather_briefing/api_client.py
  • weather_briefing/cli.py
  • weather_briefing/config.py
  • weather_briefing/llm.py
💤 Files with no reviewable changes (2)
  • tests/test_deepseek_provider.py
  • tests/test_openai_compatible_provider.py

Comment thread docs/design.md
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.

2 participants