Skip to content

Conversation

@mattt
Copy link
Contributor

@mattt mattt commented Oct 4, 2023

See https://replicate.com/docs/reference/http#models.get
See https://replicate.com/docs/reference/http#models.list

Currently, the Model class has only username and name, and the ModelCollection.get method constructs a new instance with the provided username and name arguments.

This PR makes the following changes to bring it more in line with the replicate-javascript and the other official clients:

  • Adds url, description, visibility, and other fields to Model
  • Adds owner field and reimplements existing username field to deprecated property that aliases this field
  • Updates ModelCollection.get to fetch information about the named model from Replicate's API
  • Adds ModelCollection.list to fetch public models from Replicate's API
  • Refactors run to avoid making an additional fetch for the model
  • Updates predictions.create to support creating a prediction by version ID string

@mattt mattt requested a review from a team October 4, 2023 09:57
@mattt mattt changed the title Add models.get and models.list methods Add support for models.get and models.list endpoints Oct 4, 2023
@mattt mattt merged commit 2ed90d2 into main Oct 4, 2023
@mattt mattt deleted the mattt/models branch October 4, 2023 10:56
@awerks
Copy link

awerks commented Oct 4, 2023

model = replicate.models.get(MODEL)

File "/usr/local/lib/python3.10/dist-packages/replicate/model.py", line 136, in get

return self.prepare_model(resp.json())

File "/usr/local/lib/python3.10/dist-packages/replicate/model.py", line 146, in prepare_model

attrs.get("default_example", {}).pop("version", None)

AttributeError: 'NoneType' object has no attribute 'pop'

@mattt
Copy link
Contributor Author

mattt commented Oct 4, 2023

Thanks for reporting, @awerks. PR with a fix here: #162

mattt added a commit that referenced this pull request Oct 4, 2023
@mattt
Copy link
Contributor Author

mattt commented Oct 4, 2023

Chris000102 added a commit to Chris000102/replicate-python that referenced this pull request May 3, 2024
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