feat(llm): add built-in Ollama Cloud provider preset - #1
Conversation
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds support for a new LLM provider, 'ollama-cloud', to the registry, including its configuration details and supported models. It also updates the provider list order test and adds a new unit test to verify the 'ollama-cloud' provider details. There are no review comments, and the changes look correct, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
CodeAnt AI finished reviewing your PR. |
Greptile SummaryAdds an
Confidence Score: 5/5Safe to merge — the change is a pure registry addition with no behavioural changes to existing providers or shared logic. The diff touches only two files: a new struct literal appended to a static slice and its corresponding tests. No shared code paths, authentication logic, or data-handling routines are modified. The new test covers all provider fields and verifies both model names by value, matching the coverage pattern of TestLookupProvider_PreservesModelOrder for anthropic. No files require special attention. Important Files Changed
|
Add an ollama-cloud entry to the provider registry: OpenAI protocol, base URL https://ollama.com/v1, env OLLAMA_API_KEY, models gpt-oss:120b and gpt-oss:20b. Values match Ollama Cloud's OpenAI-compatible endpoint. Tests cover provider order/count and per-field lookup details. Closes alibaba#305
bdb12ad to
c1e3265
Compare
There was a problem hiding this comment.
chethanuk has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
…urce Move the ollama-cloud provider block from the end of the registry slice to immediately after minimax (before baidu-qianfan), per PR alibaba#310 review nit from @lizhengfeng101. ListProviders() already sorts output, so this only affects source layout, not runtime order; TestListProviders_Order stays green. Kept Protocol: "openai" as a string literal to match every sibling entry in the registry (minimax, baidu-qianfan, etc. all use the literal, not the ProtocolOpenAIChatCompletions constant).
|
CodeAnt AI is running Incremental review |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
…ew.py with unit tests (alibaba#539) * refactor(examples): extract GitLab CI heredoc into post_review.py with unit tests Extracts the ~270-line inline heredoc from .gitlab-ci.yml into a standalone, testable post_review.py module, matching the publish() + make_poster() pattern established by gerrit_ci/ and gitflic_ci/. Key design decisions (from spec issue #1 and wayfinder tickets #3, #4, #5): - publish(result, diff_refs, post, config, sleep) — transport-agnostic - make_poster(api_base, token, auth_header, config) — GitLab REST transport - fetch_diff_refs(api_base, token, auth_header, config) — /versions GET with retry - Single config dict built by main() from env vars; no module-level config state - post() returns {success, rate_limit_remaining, is_rate_limit_exhausted} to preserve failure-pacing behavior (rate-limit vs non-rate-limit delays) - _sleep = time.sleep module-level pattern for testability All existing heredoc behavior preserved 1:1: - GitLab suggestion:-0+0 syntax and <details> fallback format - Retry on 429/403-rate-limit/5xx/408 with exponential backoff + ±25% jitter - Retry-After header honoring, MAX_RETRY_DELAY cap - Proactive RateLimit-Remaining throttling (success path only) - Failure pacing: rate-limit-exhausted → SUCCESS_DELAY, other → FAILURE_DELAY - PRIVATE-TOKEN vs JOB-TOKEN auth selection - Inline → fallback → summary ordering - Parse failure → post stderr as error note - All 6 env vars (OCR_RETRY_BASE_DELAY, OCR_MAX_RETRIES, OCR_MAX_RETRY_DELAY, OCR_SUCCESS_DELAY, OCR_FAILURE_DELAY, OCR_RATE_LIMIT_THRESHOLD) 48 unit tests (stdlib unittest, no network, no real time.sleep): - Seam 1: publish() with Recorder fake poster — inline/fallback/summary flow, proactive throttling, failure pacing - Seam 2: make_poster() with mocked urlopen + _sleep — retry/backoff/jitter, Retry-After, delay cap, auth headers, is_rate_limit_exhausted classification - fetch_diff_refs() with mocked urlopen — success/failure/retry - build_config() defaults and env overrides - Dry-run poster — no HTTP calls Implements alibaba#534. * fix(examples): address code review findings on gitlab_ci post_review - Add missing-required check for CI_PROJECT_ID and CI_MERGE_REQUEST_IID in main(), matching gerrit_ci/gitflic_ci pattern. The heredoc used os.environ[...] (KeyError on missing); the extraction silently used env.get(..., "") which constructs a malformed API URL. Now fails fast with a clear error message. - Change transient_base_delay from int 2 to float 2.0 to match spec config-dict type annotation. - Add 5 end-to-end tests for main()'s auth-header env resolution: PRIVATE-TOKEN when GITLAB_API_TOKEN set, JOB-TOKEN when only CI_JOB_TOKEN set, PRIVATE-TOKEN wins when both set, missing CI vars fails fast, missing token fails fast. Addresses review findings: #3 (TP, medium), #4 (Edge), #5 (TP, low). * fix(examples): handle URLError in gitlab_ci post_review retry logic _api_request_with_retry only caught HTTPError, not URLError. Network-layer failures (DNS resolution failure, connection refused, connection reset) raised URLError which propagated uncaught, crashing the script and losing all pending review comments. The original heredoc had the same gap, but the gerrit_ci sibling already handles this correctly (lines 250-259: retry on connection errors, propagate timeouts). This fix follows the gerrit_ci pattern adapted to our return-dict contract: - Add 'except urllib.error.URLError' handler after HTTPError handler - Timeout (socket.timeout/TimeoutError): return failure dict, don't retry (ambiguous — server may have processed the request) - Connection errors (DNS, refused, reset): retry with transient_base_delay backoff + ±25% jitter, same as 5xx/408 handling - Exhaustion: return failure dict with is_rate_limit_exhausted=False 3 new tests: - test_retry_urlerror_then_success: ConnectionRefused → retry → success - test_urlerror_exhausts_retries: 4 ConnectionRefused → failure after 4 attempts - test_urlerror_timeout_not_retried: socket.timeout → immediate failure, no retry Found by OCR (open-code-review) AI code review. * fix(examples): handle non-UTF-8 HTTP error bodies in gitlab_ci post_review e.read().decode('utf-8') raises UnicodeDecodeError when the GitLab server returns a non-UTF-8 error body (e.g., an HTML error page in latin-1 from a misconfigured proxy or load balancer). This exception propagated uncaught, crashing the entire posting loop — no further inline comments, fallback notes, or summary notes would be posted. Both gerrt_ci (line 242: decode('utf-8', 'replace')) and gitflic_ci (line 344: decode('utf-8', 'replace')) siblings already handle this correctly. The original heredoc had the same gap. Fix: add errors='replace' to both decode() calls (success path line 248 + error path line 260). For valid UTF-8 input (the normal case), behavior is identical. The error body is only used for keyword matching and logging, both of which work fine with replacement characters (U+FFFD). 1 new test: - test_non_utf8_error_body_does_not_crash: HTTPError with invalid UTF-8 body → no crash, returns failure dict Found by OCR (open-code-review) AI code review on PR alibaba#539.
User description
Description
Adds a built-in
ollama-cloudprovider preset to the registry ininternal/llm/providers.go, so Ollama Cloud can be selected directly instead of hand-configured as a custom provider.The preset uses the OpenAI-compatible protocol against
https://ollama.com/v1, reading the API key fromOLLAMA_API_KEY(sent asAuthorization: Bearer <key>, the shared default for OpenAI-protocol entries — no per-providerAuthHeader). It ships two models,gpt-oss:120bandgpt-oss:20b. The base URL, env var, and model naming match Ollama Cloud's documented OpenAI-compatible endpoint.Opened against my own fork first as a staging/review step.
Type of Change
How Has This Been Tested?
gofmt -lreports no diffs,go vet ./internal/llm/is clean, andgo test ./internal/llm/passes (176 tests). Coverage includes the existingTestListProviders_Order(updated for the new sorted position) and a newTestLookupProvider_OllamaCloudDetailsthat pins Protocol, BaseURL, EnvVar, empty AuthHeader, and each model name individually.Whether Ollama Cloud's OpenAI endpoint reliably supports the tool-calls flow that
ocr reviewneeds is a runtime/e2e concern, out of scope for this preset addition.make testpasses locallyChecklist
go fmt,go vet)Related Issues
Closes alibaba#305
CodeAnt-AI Description
Add Ollama Cloud as a built-in LLM provider
What Changed
OLLAMA_API_KEYgpt-oss:120bandgpt-oss:20bImpact
✅ Easier Ollama Cloud setup✅ Fewer custom provider configurations✅ Clearer provider selection for Ollama Cloud users💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
New Features
gpt-oss:120bandgpt-oss:20bmodels through Ollama Cloud.Tests