Skip to content

"error 3 validation errors for Prediction" when running "replicate.run()" #112

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

Closed
waelmansourx opened this issue Jul 3, 2023 · 7 comments · Fixed by #113
Closed

"error 3 validation errors for Prediction" when running "replicate.run()" #112

waelmansourx opened this issue Jul 3, 2023 · 7 comments · Fixed by #113

Comments

@waelmansourx
Copy link

Everytime I use this command, with any model

replicate.run(
        "stability-ai/stable-diffusion:<api-code>",
        input={"prompt": "a 19th century portrait of a wombat gentleman"}
    )

I recieve this error:

Field required [type=missing, input_value={'id': ''}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.0.1/v/missing
@Mig29github
Copy link

got the same error

@SCUTlihaoyu
Copy link

It should be the problem of updating the pydantic package to 2.0.Just reinstall version 1.9 will fix it. such as:

pip install pydantic==1.9

@waelmansourx
Copy link
Author

@SCUTlihaoyu This worked well. Thank you!

@mattt
Copy link
Contributor

mattt commented Jul 3, 2023

Hi @waelmansourx. Thanks for reporting this. Apologies for the inconvenience. As @SCUTlihaoyu mentioned, these are due to breaking changes in Pydantic 2.0 which was released a few days ago.

I'm looking into what it'd take to support both 1.x and 2.0. But in the meantime, pinning to 1.9 as @SCUTlihaoyu suggested should do the trick.

@mattt
Copy link
Contributor

mattt commented Jul 4, 2023

@waelmansourx @Mig29github @SCUTlihaoyu I just released version 0.8.4, which pins Pydantic to 1.x. This should solve the immediate problem you encountered with Pydantic 2 incompatibility.

As mentioned in #113, my goal is to update this library to support both Pydantic 1.x and 2.x in a future release.

Please let me know if you have any other issues with this. Thanks!

@simonw
Copy link
Contributor

simonw commented Jul 18, 2023

From https://pypi.org/project/pydantic/2.0/

Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects: from pydantic import v1 as pydantic_v1.

simonw added a commit to simonw/replicate-python that referenced this issue Jul 18, 2023
simonw added a commit to simonw/replicate-python that referenced this issue Jul 18, 2023
mattt added a commit that referenced this issue Jul 19, 2023
* Work with both Pydantic 1 and 2

Refs #112

Signed-off-by: Simon Willison <[email protected]>

* Ignore type checking on pydantic import statements

---------

Signed-off-by: Simon Willison <[email protected]>
Co-authored-by: Mattt Zmuda <[email protected]>
@mattt
Copy link
Contributor

mattt commented Jul 20, 2023

@simonw Thanks for pointing that out, and for #121. Curious that this V1 shim doesn't seem to be mentioned anywhere on https://docs.pydantic.dev/latest/.

Chris000102 added a commit to Chris000102/replicate-python that referenced this issue May 3, 2024
* Work with both Pydantic 1 and 2

Refs replicate/replicate-python#112

Signed-off-by: Simon Willison <[email protected]>

* Ignore type checking on pydantic import statements

---------

Signed-off-by: Simon Willison <[email protected]>
Co-authored-by: Mattt Zmuda <[email protected]>
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 a pull request may close this issue.

5 participants