Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: Could not import module aisuite.providers.mistral_provider: No module named 'mistralai'. Please ensure the provider is supported by doing ProviderFactory.get_supported_providers() #132

Open
zhimin-z opened this issue Dec 5, 2024 · 2 comments
Assignees

Comments

@zhimin-z
Copy link

zhimin-z commented Dec 5, 2024

When I attempt with mistral model as follows:

import aisuite as ai
client = ai.Client()

models = ["mistral:mistral-large-latest"]

messages = [
    {"role": "system", "content": "Respond in Pirate English."},
    {"role": "user", "content": "Tell me a joke."},
]

for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=messages,
        temperature=0.75
    )
    print(response.choices[0].message.content)

It throws the above error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:38, in ProviderFactory.create_provider(cls, provider_key, config)
     [37](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:37) try:
---> [38](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:38)     module = importlib.import_module(module_path)
     [39](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:39) except ImportError as e:

File /opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py:90, in import_module(name, package)
     [89](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py:89)         level += 1
---> [90](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/[email protected]/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py:90) return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:935, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:995, in exec_module(self, module)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File ~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/providers/mistral_provider.py:3
      [1](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/providers/mistral_provider.py:1) import os
...
     [42](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:42)     )
     [44](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:44) # Instantiate the provider class
     [45](https://file+.vscode-resource.vscode-cdn.net/Users/jimmy/Documents/GitHub/SE-Arena/~/Documents/GitHub/SE-Arena/.venv/lib/python3.12/site-packages/aisuite/provider.py:45) provider_class = getattr(module, provider_class_name)

ImportError: Could not import module aisuite.providers.mistral_provider: No module named 'mistralai'. Please ensure the provider is supported by doing ProviderFactory.get_supported_providers()

@ksolo @jeffxtang @joaomdmoura @methanet

@ksolo
Copy link
Collaborator

ksolo commented Dec 6, 2024

@zhimin-z With the base install pip install aisuite the library does not come with the various python client SDKs. You can do pip install aisuite[mistralai] if you want only mistral or pip install aisuite[all] to install all the provider SDKs.

For reference:
https://github.com/andrewyng/aisuite?tab=readme-ov-file#installation
https://github.com/andrewyng/aisuite/blob/main/pyproject.toml#L19-L29

@zhimin-z
Copy link
Author

zhimin-z commented Dec 6, 2024

@zhimin-z With the base install pip install aisuite the library does not come with the various python client SDKs. You can do pip install aisuite[mistralai] if you want only mistral or pip install aisuite[all] to install all the provider SDKs.

For reference: https://github.com/andrewyng/aisuite?tab=readme-ov-file#installation https://github.com/andrewyng/aisuite/blob/main/pyproject.toml#L19-L29

Thanks, but I am pretty sure that I have installed aisuite[all], but it still throws the above error. Only if I install aisuite[mistralai] directly could this error not occur. Does that mean mistral is a plugin not included in the complete package? @ksolo

@ksolo ksolo self-assigned this Dec 10, 2024
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

No branches or pull requests

2 participants