Skip to content

feat(llm): add built-in Mistral AI provider preset - #781

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
xavierpestel-ai:feat/add-mistral-provider
Aug 8, 2026
Merged

feat(llm): add built-in Mistral AI provider preset#781
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
xavierpestel-ai:feat/add-mistral-provider

Conversation

@xavierpestel-ai

@xavierpestel-ai xavierpestel-ai commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

Draft companion to #780. Not requesting review until maintainers confirm the direction on the discovery issue. Opened as a draft so the concrete diff is available for inspection alongside the proposal.

Description

Adds Mistral AI as a built-in LLM provider preset, so that users would be able to select it with:

ocr config set provider mistral
ocr config set model codestral-latest
export MISTRAL_API_KEY=...
ocr review

Design

Mistral's Chat Completions endpoint at https://api.mistral.ai/v1 is OpenAI-compatible (verified — see the testing section below), so this is a registry-only addition using the existing ProtocolOpenAIChatCompletions. It mirrors the pattern of the recently merged provider presets: Eden AI (#346), Ollama Cloud (#375), and LiteLLM (#385).

Scope guardrails

No changes to any of:

  • internal/llm/client.go
  • internal/llm/protocol.go
  • internal/llm/resolver.go
  • cmd/opencodereview/config_cmd.go
  • cmd/opencodereview/provider_cmd.go
  • action.yml
  • go.mod / go.sum

The diff is one new entry in internal/llm/providers.go and one new test in internal/llm/providers_test.go. Total: 52 additions, 1 deletion.

Model list rationale

Kept deliberately minimal — the preset only seeds the interactive picker; users can select any Mistral model via ocr config set model <name>.

  • codestral-latest
  • mistral-large-latest
  • mistral-small-latest

Disclosure

I work at Mistral AI. This is a personal contribution submitted under the same preset pattern as PRs #346, #375, #385.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (described below)

Local verification

Check Result
make check (license, gofmt, go vet, go mod tidy) passes
go test -race ./internal/llm/ passes
TestLookupProvider_MistralDetails (new) passes
TestListProviders_Order (updated to include mistral in sorted position) passes
TestProviders_AllProtocolsCanonical passes
make build passes
internal/llm coverage 94.3 % overall, 100 % on providers.go

Live smoke test against api.mistral.ai

POST https://api.mistral.ai/v1/chat/completions with an OpenAI-shape request body returned an OpenAI-shape response containing id, object, created, model, choices[0].message.{role,content}, finish_reason, usage.{prompt_tokens,completion_tokens,total_tokens}, and tool_calls. The existing OpenAIClient parses this without modification.

End-to-end ocr review against Mistral

Built the ocr binary with this change, set provider=mistral, model=codestral-latest, ran ocr review on a scratch git repo whose staged diff introduced a SQL injection (db.Exec("DELETE FROM users WHERE id = " + id)). The review produced a single finding at the correct line with severity security · high and a parameterized-query suggested fix. Command exited cleanly.

Paths not exercised

To be transparent about what was and was not verified:

  • Streaming responses — the smoke-test diff was below the threshold that triggers streaming. Mistral's SSE format is documented as OpenAI-compatible, and other OpenAI-compatible presets in this repo already exercise the streaming path, but I did not personally observe a streamed response from Mistral in this run.
  • Only codestral-latest was exercised end-to-end. mistral-large-latest and mistral-small-latest were only exercised at the registry-lookup level.

Checklist

Related Issues

Companion to #780 (direction check). Do not auto-close on merge — #780 is for direction confirmation, not a bug to close.

Add Mistral AI to the provider registry using the existing OpenAI-compatible
chat completions protocol. Mistral's endpoint at https://api.mistral.ai/v1
speaks the same request/response shape, so no client code or new protocol
constant is required — this is a registry-only addition matching the pattern
established by the recently merged Eden AI (alibaba#346), Ollama Cloud (alibaba#375), and
LiteLLM (alibaba#385) provider presets.

Auth via MISTRAL_API_KEY. Curated model list kept deliberately minimal
(codestral-latest, mistral-large-latest, mistral-small-latest); users can
select any other Mistral model via `ocr config set model <name>`.

Tested end-to-end against api.mistral.ai with codestral-latest against a
staged diff — review returned an accurate high-severity SQL injection
finding with a correct parameterized-query fix suggestion.
@CLAassistant

CLAassistant commented Aug 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@xavierpestel-ai
xavierpestel-ai marked this pull request as ready for review August 7, 2026 21:49

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 266ca29 into alibaba:main Aug 8, 2026
12 checks passed
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.

3 participants