PrefectHQ / marvin

✨ Build AI interfaces that spark joy
https://askmarvin.ai
Apache License 2.0
5.29k stars 347 forks source link

ValueError: Unknown provider: ProsusAI when importing marvin module #637

Open justquick opened 1 year ago

justquick commented 1 year ago

First check

Bug summary

Using latest 1.5.6 release, im having issues doing the quickstart guide and simply doing import marvin blows up. The error is related to the ProsusAI which i do not use.

Reproduction

import marvin

Error

Traceback (most recent call last):
  File "/Users/jquick/Projects/marv/main.py", line 2, in <module>
    import marvin
  File "/Users/jquick/.local/share/virtualenvs/marv-60bvcKe7/lib/python3.10/site-packages/marvin/__init__.py", line 3, in <module>
    from .components import (
  File "/Users/jquick/.local/share/virtualenvs/marv-60bvcKe7/lib/python3.10/site-packages/marvin/components/__init__.py", line 7, in <module>
    from .ai_classifier import ai_classifier
  File "/Users/jquick/.local/share/virtualenvs/marv-60bvcKe7/lib/python3.10/site-packages/marvin/components/ai_classifier.py", line 88, in <module>
    class AIEnumMeta(EnumMeta):
  File "/Users/jquick/.local/share/virtualenvs/marv-60bvcKe7/lib/python3.10/site-packages/marvin/components/ai_classifier.py", line 97, in AIEnumMeta
    __metadata__ = AIEnumMetaData()
  File "/Users/jquick/.local/share/virtualenvs/marv-60bvcKe7/lib/python3.10/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
  File "/Users/jquick/.local/share/virtualenvs/marv-60bvcKe7/lib/python3.10/site-packages/marvin/core/ChatCompletion/__init__.py", line 56, in ChatCompletion
    raise ValueError(f"Unknown provider: {provider}")
ValueError: Unknown provider: ProsusAI

Versions

`marvin version` fails w/ error also

OSX 12.6 intel
Python 3.10.8
pipenv, version 2023.10.24

packages from pip freeze

marvin==1.5.6
pydantic==2.4.2
openai==0.28.1

Additional context

No response

aaazzam commented 1 year ago

hey @justquick we're pretty confused about this one

there's no reference of ProsusAI anywhere in Marvin

not sure if there's some weird config or virtualenv thing going on - I don't think we're colliding with some env variable you might have set. Is there a world where you can try in a fresh venv?

justquick commented 1 year ago

Yea this is def very weird. It happens in every venv no matter whether it's pip, pipenv, hatch, poetry, etc. For some reason openai? is looking for ProsusAI/finbert model probably from huggingface but nothing in my env defines prosus and i cant find anything mentioning it in ~/.config or ~/Library/Application Suppor. The confusing thing is that why is it trying to load a model when it's hitting pydantic directly and not going through the openai package first?

Anyway it's curious but i think you can safely close this ticket as im sure it's related to my rats nest of a dev env. If you are still curios here are a few more details

Im also seeing a warning related to dotenv on the pip install:

$ mkvirtualenv marv  # virtualenvwrapper shortcut
...
$ pip install marvin
...
WARNING: pydantic 2.4.2 does not provide the extra 'dotenv'
...

install passes but the first roadblock i hit is w/ dotenv after install running marvin

$ marvin
Traceback (most recent call last):
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 330, in read_env_file
    from dotenv import dotenv_values
ModuleNotFoundError: No module named 'dotenv'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jquick/.local/share/virtualenvs/marv/bin/marvin", line 5, in <module>
    from marvin.cli import app
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/marvin/__init__.py", line 1, in <module>
    from .settings import settings
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/marvin/settings.py", line 131, in <module>
    class Settings(MarvinBaseSettings):
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/marvin/settings.py", line 152, in Settings
    openai: OpenAISettings = OpenAISettings()
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 41, in __init__
    **__pydantic_self__._build_values(
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 76, in _build_values
    return deep_update(*reversed([source(self) for source in sources]))
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 76, in <listcomp>
    return deep_update(*reversed([source(self) for source in sources]))
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 177, in __call__
    dotenv_vars = self._read_env_files(settings.__config__.case_sensitive)
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 226, in _read_env_files
    read_env_file(env_path, encoding=self.env_file_encoding, case_sensitive=case_sensitive)
  File "/Users/jquick/.local/share/virtualenvs/marv/lib/python3.10/site-packages/pydantic/v1/env_settings.py", line 332, in read_env_file
    raise ImportError('python-dotenv is not installed, run `pip install pydantic[dotenv]`') from e
ImportError: python-dotenv is not installed, run `pip install pydantic[dotenv]`

running pip install pydantic[dotenv] doesnt fix the issue so i run pip install python-dotenv instead

zzstoatzz commented 9 months ago

hi @justquick - are you fine with us closing this issue?