Skip to content

feat(llm): add Mistral as an LLM provider#562

Merged
sicoyle merged 6 commits into
dapr:mainfrom
Rishabh-git10:issue-230-mistral-client
Apr 30, 2026
Merged

feat(llm): add Mistral as an LLM provider#562
sicoyle merged 6 commits into
dapr:mainfrom
Rishabh-git10:issue-230-mistral-client

Conversation

@Rishabh-git10
Copy link
Copy Markdown
Contributor

Description

Adds MistralChatClient to natively support Mistral as an LLM provider via the mistralai SDK. This allows users to configure custom endpoints and utilize multimodal features that are not supported by the generic Conversation API.

Changes included:

  • Implemented MistralClientBase and MistralChatClient.
  • Added fallback logic to use the MISTRAL_MODEL environment variable.
  • Exported the client in dapr_agents/llm/__init__.py.
  • Added mistralai to project dependencies (supports SDK v2 with v1 fallback).
  • Added unit tests in tests/llm/test_mistral.py.

Issue reference

Closes #230

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

Note: We expect contributors to open a corresponding documentation PR in the dapr/docs repository. As the implementer, you are the best person to document your work! Implementation PRs will not be merged until the documentation PR is opened and ready for review.

@sicoyle
Copy link
Copy Markdown
Collaborator

sicoyle commented Apr 8, 2026

Hi 👋 Thank you for your contribution and interest in Dapr Agents 🎉 Can you pls run these commands to make the DCO build step happy:


In your local branch, run: git rebase HEAD~2 --signoff
Force push your changes to overwrite the branch: git push --force-with-lease origin issue-230-mistral-client

Also, if you use git commit -sm "<commit msg>" then it will include your signoff :)

@sicoyle
Copy link
Copy Markdown
Collaborator

sicoyle commented Apr 8, 2026

also, thank you so much for already opening the docs PR - that's amazing!! Also, we have pre-commit hooks for our repo to help avoid linter/build failures at CI time. There should be docs in the dev docs section of the repo with info on this :) It's under docs/development/README.md in the "Pre-Push Hooks" section.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a native Mistral LLM provider to dapr_agents.llm via the mistralai SDK, exposing a MistralChatClient and wiring it into the package exports so users can select Mistral as a first-class provider.

Changes:

  • Introduces MistralClientBase + MistralChatClient with env-var model fallback (MISTRAL_MODEL).
  • Exports MistralChatClient from dapr_agents/llm/__init__.py and adds the mistralai dependency.
  • Adds initial unit tests for initialization and basic generate() behavior.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
dapr_agents/llm/mistral/client.py Adds the provider base client wrapper around the mistralai SDK client creation.
dapr_agents/llm/mistral/chat.py Implements the Mistral chat client and hooks into shared request/response utilities.
dapr_agents/llm/mistral/__init__.py Exposes Mistral client classes at the package level.
dapr_agents/llm/__init__.py Re-exports MistralChatClient as part of the public LLM API surface.
tests/llm/test_mistral.py Adds unit tests for env model fallback and a mocked generate() call.
pyproject.toml Adds mistralai>=2.2.0 to runtime dependencies.
uv.lock Locks mistralai (and transitive deps) into the resolved dependency set.

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

Comment thread dapr_agents/llm/mistral/chat.py Outdated
Comment thread dapr_agents/llm/mistral/chat.py Outdated
Comment thread dapr_agents/llm/mistral/chat.py Outdated
Comment thread dapr_agents/llm/mistral/chat.py Outdated
Comment thread dapr_agents/llm/mistral/chat.py
Comment thread dapr_agents/llm/mistral/__init__.py Outdated
Comment thread tests/llm/test_mistral.py
Comment thread tests/llm/test_mistral.py Outdated
Comment thread tests/llm/test_mistral.py Outdated
Comment thread dapr_agents/llm/mistral/chat.py Outdated
@Rishabh-git10 Rishabh-git10 force-pushed the issue-230-mistral-client branch from aa82609 to 5a73f7e Compare April 9, 2026 07:57
@Rishabh-git10
Copy link
Copy Markdown
Contributor Author

Hi @sicoyle, thanks for the guidance! Pre-commit hooks are run, files are formatted, and all commits are now signed off.

I've also addressed the Copilot review:

  • Added missing Apache 2.0 license headers.
  • Fixed the Pydantic schema mapping for LLMChatResponse.
  • Raised NotImplementedError for unsupported features (streaming, tools).

One question regarding from_prompty: Dapr's core PromptyModelConfig doesn't currently accept mistral as a valid type. I've temporarily raised a NotImplementedError to prevent upstream validation crashes. Would you prefer we expand the core types to fully support Mistral Prompty in this PR, or should we tackle that in a follow-up?

Ready for another look!

@CasperGN
Copy link
Copy Markdown
Contributor

CasperGN commented Apr 13, 2026

@Rishabh-git10 looks like there's 3 files still missing the license header :-)

Edit: Scratch that, UI just didn't show

values["model"] = env_model
elif not values.get("model"):
values["model"] = "mistral-large-latest"
return values
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sure this is well documented in dapr-docs but also that docstring reflect this for consumers of the MistralChatClient

Copy link
Copy Markdown
Contributor Author

@Rishabh-git10 Rishabh-git10 Apr 13, 2026

Choose a reason for hiding this comment

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

Done!

  • Added class and method docstrings to MistralChatClient.
  • Updated the dapr/docs PR to document the MISTRAL_MODEL fallback inline on the Core Concepts page.

Copy link
Copy Markdown
Collaborator

@sicoyle sicoyle left a comment

Choose a reason for hiding this comment

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

two final comments from me pls and then this is g2g - thank you! 🚀 @CasperGN do you have any other feedback here by chance?

Comment thread dapr_agents/llm/mistral/client.py Outdated
Comment thread dapr_agents/llm/mistral/client.py Outdated
Comment on lines +18 to +27
try:
# Mistral SDK v1.x
from mistralai import Mistral
except ImportError:
try:
# Mistral SDK v2.x
from mistralai.client import Mistral
except ImportError:
# Mistral SDK v0.x (Fallback)
from mistralai.client import MistralClient as Mistral
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.

the pyproject toml file pins to v2.X.X. Can you pls rm the fallback and try/except setup here and just keep the import sitting alongside the other imports for logging, typing and such above? That way it's consistent too with the imports setup that the other LLM provider clients use :)

@sicoyle
Copy link
Copy Markdown
Collaborator

sicoyle commented Apr 14, 2026

One question regarding from_prompty: Dapr's core PromptyModelConfig doesn't currently accept mistral as a valid type. I've temporarily raised a NotImplementedError to prevent upstream validation crashes. Would you prefer we expand the core types to fully support Mistral Prompty in this PR, or should we tackle that in a follow-up?

This is great! Full Mistral Prompty support can be done in a follow up PR :)

@Rishabh-git10
Copy link
Copy Markdown
Contributor Author

Rishabh-git10 commented Apr 15, 2026

@sicoyle I've made both requested changes. I'll tackle the full Mistral Prompty support in a follow-up PR after this merges. Thanks!

sicoyle
sicoyle previously approved these changes Apr 15, 2026
Copy link
Copy Markdown
Collaborator

@sicoyle sicoyle left a comment

Choose a reason for hiding this comment

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

This is great - thank you so much for your contribution! 🙌

@sicoyle sicoyle requested a review from CasperGN April 15, 2026 15:45
CasperGN
CasperGN previously approved these changes Apr 15, 2026
Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>
Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>
Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>
Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>
Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>
@Rishabh-git10 Rishabh-git10 dismissed stale reviews from CasperGN and sicoyle via 94084a0 April 25, 2026 19:32
@Rishabh-git10 Rishabh-git10 force-pushed the issue-230-mistral-client branch from cf00e55 to 94084a0 Compare April 25, 2026 19:32
@Rishabh-git10
Copy link
Copy Markdown
Contributor Author

@sicoyle @CasperGN
Rebased against main to resolve the uv.lock conflict.
Please check!

CasperGN
CasperGN previously approved these changes Apr 27, 2026
yaron2
yaron2 previously approved these changes Apr 30, 2026
@yaron2
Copy link
Copy Markdown
Member

yaron2 commented Apr 30, 2026

Please resolve the conflicts and we can then merge

Signed-off-by: Casper Nielsen <casper@diagrid.io>
@CasperGN CasperGN dismissed stale reviews from yaron2 and themself via 9f35124 April 30, 2026 14:36
@CasperGN CasperGN requested review from CasperGN, Copilot and yaron2 April 30, 2026 14:38
@CasperGN
Copy link
Copy Markdown
Contributor

I did not mean to re-request Copilot. Disregard whatever it may find. The PR is GTG 🚀

Copy link
Copy Markdown
Collaborator

@sicoyle sicoyle left a comment

Choose a reason for hiding this comment

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

thank you so much!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment on lines +72 to +76
env_model = os.environ.get("MISTRAL_MODEL")
if env_model:
values["model"] = env_model
elif not values.get("model"):
values["model"] = "mistral-large-latest"
Comment on lines +143 to +147
return LLMChatResponse(
id=resp.id,
model=resp.model,
results=[
{
Comment on lines +18 to +21
from mistralai.client import Mistral

from dapr_agents.llm.base import LLMClientBase
from dapr_agents.types.llm import MistralClientConfig
Comment thread tests/llm/test_mistral.py
Comment on lines +21 to +22
client = MistralChatClient()
assert client.model == "mistral-large-latest"
Comment thread pyproject.toml
"wrapt>=1.14.0,<2.0.0",
"openinference-instrumentation>=0.1.0,<1.0.0",
"openinference-semantic-conventions>=0.1.0,<1.0.0",
"mistralai>=2.2.0",
@sicoyle sicoyle merged commit aee7881 into dapr:main Apr 30, 2026
13 checks passed
@Rishabh-git10 Rishabh-git10 deleted the issue-230-mistral-client branch April 30, 2026 19:45
1Ninad pushed a commit to 1Ninad/dapr-agents that referenced this pull request May 3, 2026
* feat(llm): add Mistral as an LLM provider

Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>

* test(llm): add unit tests for Mistral provider

Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>

* fix(llm): address PR review feedback and formatting for Mistral

Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>

* docs(llm): clarify Mistral model fallback behavior in docstrings

Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>

* refactor(llm): simplify Mistral imports and add config class

Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>

---------

Signed-off-by: Rishabh Dewangan <107680241+Rishabh-git10@users.noreply.github.com>
Signed-off-by: Casper Nielsen <casper@diagrid.io>
Co-authored-by: Casper Nielsen <casper@diagrid.io>
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.

Add Mistral as additional LLM provider

5 participants