Skip to content

Add support for models.get and models.list endpoints #161

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

Merged
merged 6 commits into from
Oct 4, 2023
Merged

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 added 2 commits October 4, 2023 02:50
…formation

Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@mattt mattt requested a review from a team October 4, 2023 09:57
mattt added 4 commits October 4, 2023 03:01
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@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
Resolves
#161 (comment)

Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@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.

2 participants