Skip to content

Conversation

@mattt
Copy link
Contributor

@mattt mattt commented Jul 18, 2024

This PR extends #325 to add the prediction object itself to ModelError, as opposed to just its ID. This makes it convenient to introspect logs and other information to determine how to handle the failure.

import replicate
from replicate.exceptions import ModelError

try:
  output = replicate.run("stability-ai/stable-diffusion-3", { "prompt": "..." })
except ModelError as e
  if "(some known issue)" in e.prediction.logs:
    pass

  print("Failed prediction: " + e.prediction.id)

@mattt mattt merged commit 71c124d into main Jul 18, 2024
@mattt mattt deleted the mattt/modelerror-prediction branch July 18, 2024 11:24
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