guardrails-ai / guardrails

Adding guardrails to large language models.
https://www.guardrailsai.com/docs
Apache License 2.0
4.19k stars 318 forks source link

SQLAlchemy Error while running guardrails text2sql application #163

Closed RamiAwar closed 1 year ago

RamiAwar commented 1 year ago

Describe the bug Installed guardrails-ai, happened with both sqlalchemy versions 1.4.x and 2.x after I updated to try and fix this.

    179 class SqlDocument(Base):
    180     __tablename__ = "documents"
--> 182     id: orm.Mapped[int] = orm.mapped_column(primary_key=True)
    183     page_num: orm.Mapped[int] = orm.mapped_column(
    184         sqlalchemy.Integer, primary_key=True
    185     )
    186     text: orm.Mapped[str] = orm.mapped_column(sqlalchemy.String)

AttributeError: module 'sqlalchemy.orm' has no attribute 'mapped_column'

To Reproduce Steps to reproduce the behavior:

  1. Simply import from guardrails.document_store import DocumentStoreBase, EphemeralDocumentStore

Expected behavior No exception

Library version: Version 0.1.6 (latest)

RamiAwar commented 1 year ago

Will try to fix this when I have a chance

ShreyaR commented 1 year ago

@RamiAwar what's your SQLAlchemy version?

Can you try running:

pip uninstall -y sqlalchemy
pip install sqlalchemy>=2.0.9

and see if that fixes the issue?

RamiAwar commented 1 year ago

Hey Shreya, interestingly, I just cloned the repo and installed it as an editable package and it now works fine.. My IDE also detected the mapping fine.

I have sqlalchemy set to ^2.0.13. Maybe I forgot to restart my kernel after updating sqlalchemy or something like this, I think it's a not an issue anymore, you can close this!

Thanks for the quick response! I'm planning to re-write my Text2SQL app https://dataline.app using guardrails instead of manual prompts, so I'm excited to contribute where I can!

ShreyaR commented 1 year ago

That's amazing, really glad to hear it!

Feel free to create more issues/post on the discord if you run into any issues with Text2SQL.