An AI Agent that interacts with Windows OS at GUI level.
Python
fix(mistral): support both the 1.x and the 2.x+ client layouts
Hussainf4dab3c2be78
diff --git a/tests/unit/providers/test_mistral.py b/tests/unit/providers/test_mistral.pynew file mode 100644index 0000000..e2fad5f--- /dev/null+++ b/tests/unit/providers/test_mistral.py@@ -0,0 +1,22 @@+"""The Mistral provider must import on every supported mistralai layout.++mistralai 1.x exports ``Mistral`` from the top level and keeps a deprecated+stub in ``mistralai.client``. mistralai 2.x and later dropped the top level+package and moved the client into ``mistralai.client``. The two layouts have+mutually exclusive import paths, so the provider has to try both.++Because ``windows_use/providers/__init__.py`` imports every provider+eagerly, a broken import here takes down ``import windows_use`` completely.+"""++from windows_use.providers.mistral import ChatMistral+++def test_mistral_provider_imports():+ assert ChatMistral is not None+++def test_mistral_provider_has_a_client_class():+ import windows_use.providers.mistral.llm as mistral_llm++ assert hasattr(mistral_llm, "Mistral")diff --git a/windows_use/providers/mistral/llm.py b/windows_use/providers/mistral/llm.pyindex 808c6bf..2287ffc 100644--- a/windows_use/providers/mistral/llm.py+++ b/windows_use/providers/mistral/llm.py@@ -4,7 +4,10 @@ import osfrom collections.abc import AsyncIterator, Iteratorfrom typing import Any, overload-from mistralai.client import Mistral+try: # mistralai 2.x moved the client into the mistralai.client package+ from mistralai.client import Mistral+except ImportError: # mistralai 1.x exports it from the top level+ from mistralai import Mistralfrom pydantic import BaseModelfrom windows_use.messages import (