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

Simple Hello World example does not work, already fails when importing RailsConfig #353

Closed
gingters opened this issue Feb 23, 2024 · 4 comments
Assignees

Comments

@gingters
Copy link

I tried building the simple hello world demo, but I get errors as soon as I import RailsConfig:

rails.py

from nemoguardrails import RailsConfig

config = RailsConfig.from_path("./config")

from nemoguardrails import LLMRails
rails = LLMRails(config)

response = rails.generate(messages=[{
    "role": "user",
    "content": "Hello!",
}])
print (response)

/config/config.yml

models:
  - type: main
    engine: openai
    model: gpt-3.5-turbo-instruct

Error:

python ./rails.py                            
Traceback (most recent call last):
  File "/home/sebastian/python-playground/./rails.py", line 1, in <module>
    from nemoguardrails import RailsConfig
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/site-packages/nemoguardrails/__init__.py", line 20, in <module>
    from .rails import LLMRails, RailsConfig
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/site-packages/nemoguardrails/rails/__init__.py", line 17, in <module>
    from .llm.llmrails import LLMRails
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/site-packages/nemoguardrails/rails/llm/llmrails.py", line 35, in <module>
    from nemoguardrails.llm.providers import get_llm_provider, get_llm_provider_names
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/site-packages/nemoguardrails/llm/providers/__init__.py", line 16, in <module>
    from .providers import (
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/site-packages/nemoguardrails/llm/providers/providers.py", line 133, in <module>
    discover_langchain_providers()
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/site-packages/nemoguardrails/llm/providers/providers.py", line 127, in discover_langchain_providers
    if issubclass(provider_cls, LLM) and "_acall" not in provider_cls.__dict__:
  File "/home/sebastian/miniconda3/envs/python-playground/lib/python3.10/abc.py", line 123, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class

As you can see, it already fails when importing the RailsConfig. It's not even executing a single line of the actual code in my file.
I'm on Windows 11 WSL2 Ubuntu 20.04.03 LTS. I have installed pip install nemoguardrails[all].

These are all packages currently installed in my conda virtual environment:

aiohttp==3.9.3
aiosignal==1.3.1
annotated-types==0.6.0
annoy==1.17.3
anyio==4.3.0
async-timeout==4.0.3
attrs==23.2.0
blis==0.7.11
catalogue==2.0.10
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
cloudpathlib==0.16.0
coloredlogs==15.0.1
confection==0.1.4
cymem==2.0.8
dataclasses-json==0.6.4
distro==1.9.0
exceptiongroup==1.2.0
fastapi==0.109.2
fastembed==0.2.2
filelock==3.13.1
flatbuffers==23.5.26
frozenlist==1.4.1
fsspec==2024.2.0
greenlet==3.0.3
h11==0.14.0
httpcore==1.0.4
httpx==0.27.0
huggingface-hub==0.20.3
humanfriendly==10.0
idna==3.6
Jinja2==3.1.3
jsonpatch==1.33
jsonpointer==2.4
langchain==0.1.9
langchain-community==0.0.22
langchain-core==0.1.26
langchain-openai==0.0.7
langcodes==3.3.0
langsmith==0.1.5
loguru==0.7.2
MarkupSafe==2.1.5
marshmallow==3.20.2
mpmath==1.3.0
multidict==6.0.5
murmurhash==1.0.10
mypy-extensions==1.0.0
nemoguardrails==0.7.1
nest-asyncio==1.6.0
numpy==1.26.4
onnx==1.15.0
onnxruntime==1.17.0
openai==1.12.0
packaging==23.2
phonenumbers==8.13.30
pip==23.3.1
preshed==3.0.9
presidio-analyzer==2.2.353
presidio-anonymizer==2.2.353
protobuf==4.25.3
pycryptodome==3.20.0
pydantic==2.6.1
pydantic_core==2.16.2
python-dotenv==1.0.1
PyYAML==6.0.1
quantities==0.15.0
regex==2023.12.25
requests==2.31.0
requests-file==2.0.0
router==0.1
semantic==1.0.3
setuptools==68.2.2
simpleeval==0.9.13
smart-open==6.4.0
sniffio==1.3.0
spacy==3.7.4
spacy-legacy==3.0.12
spacy-loggers==1.0.5
SQLAlchemy==2.0.27
srsly==2.4.8
starlette==0.36.3
sympy==1.12
tenacity==8.2.3
thinc==8.2.3
tiktoken==0.6.0
tldextract==5.1.1
tokenizers==0.15.2
tqdm==4.66.2
typer==0.9.0
typing_extensions==4.9.0
typing-inspect==0.9.0
urllib3==2.2.1
uvicorn==0.27.1
wasabi==1.1.2
watchdog==4.0.0
weasel==0.3.4
websocket-client==1.7.0
wheel==0.41.2
yarl==1.9.4
@drazvan
Copy link
Collaborator

drazvan commented Feb 23, 2024

Hi @gingters!

I think this is related to a bug that was introduced in the latest langchain version a few hours ago. In the develop branch we've already updated the requirements to include:

"langchain>=0.1.0,<0.2.0,!=0.1.9",
"langchain-core>=0.1.0,!=0.1.26",

It seems you have langchain==0.1.9 and langchain-core==0.1.26.

The bug was introduced here: langchain-ai/langchain#17702 (see my comment).

Let me know if manually updating the langchain versions fixes it.

@drazvan drazvan self-assigned this Feb 23, 2024
@trebedea
Copy link
Collaborator

Hi @gingters ,

There is an issue with langchain-core==0.1.26 that was released earlier today. At the moment, the fix is not to use this version so we have just updated the .toml file in the develop branch to highlight this:
287022e

@baskaryan
Copy link

Hey all, fix should be out. As far as I can tell the issue is with langchain-community==0.0.22 and then this line in nemo:

if issubclass(provider_cls, LLM) and "_acall" not in provider_cls.__dict__:

(something that was expected to be a class was being returned as an object by langchain-community)

If you update to langchain-community>0.0.22 this should be resolved.

Apologies for the issue!

@gingters
Copy link
Author

Hi. I just checked with the new dependencies and it works again 👍

Thanks for the swift response.

I mean, on one side it's extremely cool that all that stuff is moving so fast.
On the other side it's a bit frustrating when you try things out for the first time and just because your timing is a bit unfortunate (i.E. a few hours "too late") some upstream update breaks stuff 😅

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

4 participants