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

fixes for pydantic in gpt_langchain.py #1722

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

one-lithe-rune
Copy link
Contributor

@one-lithe-rune one-lithe-rune commented Aug 4, 2023

Motivation

Just before a686d7d which temporarily disabled DocuChat/langchain I was getting the following error, when running the ui/web after manually installing the langchain dependency:

Traceback (most recent call last):
  File "C:\develop\SHARK\apps\stable_diffusion\web\index.py", line 94, in <module>
    from apps.stable_diffusion.web.ui.utils import create_custom_models_folders
  File "C:\develop\SHARK\apps\stable_diffusion\web\ui\__init__.py", line 82, in <module>
    from apps.stable_diffusion.web.ui.h2ogpt import h2ogpt_upload, h2ogpt_web
  File "C:\develop\SHARK\apps\stable_diffusion\web\ui\h2ogpt.py", line 15, in <module>
    from gpt_langchain import (
  File "C:\develop\SHARK\apps\language_models\langchain\gpt_langchain.py", line 418, in <module>
    class GradioInference(LLM):
  File "pydantic\main.py", line 186, in pydantic.main.ModelMetaclass.__new__
  File "pydantic\utils.py", line 167, in pydantic.utils.validate_field_name

NameError: Field name "stream" shadows a BaseModel attribute; use a different field name with "alias='stream'".

Possibly DNM, because I don't know how relevant this is in real life.

Changes

  • Follow the advice in the above error and change 'stream' instance variables to 'stream_output' and aliased them back to 'stream' to clear clash with Pydantic BaseModel.

Problems/Concerns

  • May not be relevant with this disabled.
  • May have been a dependency issue on my part.
  • My first use of pydantic was on an internal work project today, so I'm not familiar with it at all.

* change 'stream' instance variables to 'stream_output' and aliased them
back to 'stream' to clear clash with Pydantic BaseModel.
@powderluv
Copy link
Contributor

@vivekkhandelwal1 please review if we need this

@vivekkhandelwal1
Copy link
Collaborator

@vivekkhandelwal1 please review if we need this

Sure, I will first locally test this patch and then review it.

Copy link
Collaborator

@vivekkhandelwal1 vivekkhandelwal1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@powderluv powderluv merged commit 9b8c440 into nod-ai:main Aug 7, 2023
2 of 6 checks passed
Eliasj42 pushed a commit that referenced this pull request Aug 8, 2023
dan-garvey pushed a commit that referenced this pull request Aug 8, 2023
* download all mlirs

* fixed install method

* download all mlirs (#1727)

Co-authored-by: Elias Joseph <[email protected]>

* added taggs

* fix name check for file existence

* Remove SD from all_models.csv (#1706)

Removes SD from pytests as it has its own test suite.

* gpt_langchain.py fixes for pydantic (#1722)

* removed dead code

---------

Co-authored-by: Elias Joseph <[email protected]>
Co-authored-by: PhaneeshB <[email protected]>
Co-authored-by: Ean Garvey <[email protected]>
Co-authored-by: Stefan Kapusniak <[email protected]>
AyaanShah2204 pushed a commit to AyaanShah2204/SHARK that referenced this pull request Aug 8, 2023
* download all mlirs

* fixed install method

* download all mlirs (nod-ai#1727)

Co-authored-by: Elias Joseph <[email protected]>

* added taggs

* fix name check for file existence

* Remove SD from all_models.csv (nod-ai#1706)

Removes SD from pytests as it has its own test suite.

* gpt_langchain.py fixes for pydantic (nod-ai#1722)

* removed dead code

---------

Co-authored-by: Elias Joseph <[email protected]>
Co-authored-by: PhaneeshB <[email protected]>
Co-authored-by: Ean Garvey <[email protected]>
Co-authored-by: Stefan Kapusniak <[email protected]>
@one-lithe-rune one-lithe-rune deleted the langchain_add_pydantic_alias branch December 30, 2023 14:54
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

Successfully merging this pull request may close these issues.

3 participants