|
14 | 14 | ReadmeResourceWithStreamingResponse, |
15 | 15 | AsyncReadmeResourceWithStreamingResponse, |
16 | 16 | ) |
17 | | -from ...types import model_list_params, model_create_params, model_search_params |
| 17 | +from ...types import model_list_params, model_create_params, model_search_params, model_update_params |
18 | 18 | from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given |
19 | 19 | from ..._utils import maybe_transform, async_maybe_transform |
20 | 20 | from .examples import ( |
|
55 | 55 | from ...types.model_list_response import ModelListResponse |
56 | 56 | from ...types.model_create_response import ModelCreateResponse |
57 | 57 | from ...types.model_search_response import ModelSearchResponse |
| 58 | +from ...types.model_update_response import ModelUpdateResponse |
58 | 59 |
|
59 | 60 | __all__ = ["ModelsResource", "AsyncModelsResource"] |
60 | 61 |
|
@@ -206,6 +207,99 @@ def create( |
206 | 207 | cast_to=ModelCreateResponse, |
207 | 208 | ) |
208 | 209 |
|
| 210 | + def update( |
| 211 | + self, |
| 212 | + *, |
| 213 | + model_owner: str, |
| 214 | + model_name: str, |
| 215 | + description: str | Omit = omit, |
| 216 | + github_url: str | Omit = omit, |
| 217 | + license_url: str | Omit = omit, |
| 218 | + paper_url: str | Omit = omit, |
| 219 | + readme: str | Omit = omit, |
| 220 | + weights_url: str | Omit = omit, |
| 221 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 222 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 223 | + extra_headers: Headers | None = None, |
| 224 | + extra_query: Query | None = None, |
| 225 | + extra_body: Body | None = None, |
| 226 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 227 | + ) -> ModelUpdateResponse: |
| 228 | + """ |
| 229 | + Update select properties of an existing model. |
| 230 | + |
| 231 | + You can update the following properties: |
| 232 | + |
| 233 | + - `description` - Model description |
| 234 | + - `readme` - Model README content |
| 235 | + - `github_url` - GitHub repository URL |
| 236 | + - `paper_url` - Research paper URL |
| 237 | + - `weights_url` - Model weights URL |
| 238 | + - `license_url` - License URL |
| 239 | + |
| 240 | + Example cURL request: |
| 241 | + |
| 242 | + ```console |
| 243 | + curl -X PATCH \\ |
| 244 | + https://api.replicate.com/v1/models/your-username/your-model-name \\ |
| 245 | + -H "Authorization: Token $REPLICATE_API_TOKEN" \\ |
| 246 | + -H "Content-Type: application/json" \\ |
| 247 | + -d '{ |
| 248 | + "description": "Detect hot dogs in images", |
| 249 | + "readme": "# Hot Dog Detector\n\n🌭 Ketchup, mustard, and onions...", |
| 250 | + "github_url": "https://github.com/alice/hot-dog-detector", |
| 251 | + "paper_url": "https://arxiv.org/abs/2504.17639", |
| 252 | + "weights_url": "https://huggingface.co/alice/hot-dog-detector", |
| 253 | + "license_url": "https://choosealicense.com/licenses/mit/" |
| 254 | + }' |
| 255 | + ``` |
| 256 | + |
| 257 | + The response will be the updated model object with all of its properties. |
| 258 | + |
| 259 | + Args: |
| 260 | + description: A description of the model. |
| 261 | + |
| 262 | + github_url: A URL for the model's source code on GitHub. |
| 263 | + |
| 264 | + license_url: A URL for the model's license. |
| 265 | + |
| 266 | + paper_url: A URL for the model's paper. |
| 267 | + |
| 268 | + readme: The README content of the model. |
| 269 | + |
| 270 | + weights_url: A URL for the model's weights. |
| 271 | + |
| 272 | + extra_headers: Send extra headers |
| 273 | + |
| 274 | + extra_query: Add additional query parameters to the request |
| 275 | + |
| 276 | + extra_body: Add additional JSON properties to the request |
| 277 | + |
| 278 | + timeout: Override the client-level default timeout for this request, in seconds |
| 279 | + """ |
| 280 | + if not model_owner: |
| 281 | + raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}") |
| 282 | + if not model_name: |
| 283 | + raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") |
| 284 | + return self._patch( |
| 285 | + f"/models/{model_owner}/{model_name}", |
| 286 | + body=maybe_transform( |
| 287 | + { |
| 288 | + "description": description, |
| 289 | + "github_url": github_url, |
| 290 | + "license_url": license_url, |
| 291 | + "paper_url": paper_url, |
| 292 | + "readme": readme, |
| 293 | + "weights_url": weights_url, |
| 294 | + }, |
| 295 | + model_update_params.ModelUpdateParams, |
| 296 | + ), |
| 297 | + options=make_request_options( |
| 298 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 299 | + ), |
| 300 | + cast_to=ModelUpdateResponse, |
| 301 | + ) |
| 302 | + |
209 | 303 | def list( |
210 | 304 | self, |
211 | 305 | *, |
@@ -651,6 +745,99 @@ async def create( |
651 | 745 | cast_to=ModelCreateResponse, |
652 | 746 | ) |
653 | 747 |
|
| 748 | + async def update( |
| 749 | + self, |
| 750 | + *, |
| 751 | + model_owner: str, |
| 752 | + model_name: str, |
| 753 | + description: str | Omit = omit, |
| 754 | + github_url: str | Omit = omit, |
| 755 | + license_url: str | Omit = omit, |
| 756 | + paper_url: str | Omit = omit, |
| 757 | + readme: str | Omit = omit, |
| 758 | + weights_url: str | Omit = omit, |
| 759 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 760 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 761 | + extra_headers: Headers | None = None, |
| 762 | + extra_query: Query | None = None, |
| 763 | + extra_body: Body | None = None, |
| 764 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 765 | + ) -> ModelUpdateResponse: |
| 766 | + """ |
| 767 | + Update select properties of an existing model. |
| 768 | + |
| 769 | + You can update the following properties: |
| 770 | + |
| 771 | + - `description` - Model description |
| 772 | + - `readme` - Model README content |
| 773 | + - `github_url` - GitHub repository URL |
| 774 | + - `paper_url` - Research paper URL |
| 775 | + - `weights_url` - Model weights URL |
| 776 | + - `license_url` - License URL |
| 777 | + |
| 778 | + Example cURL request: |
| 779 | + |
| 780 | + ```console |
| 781 | + curl -X PATCH \\ |
| 782 | + https://api.replicate.com/v1/models/your-username/your-model-name \\ |
| 783 | + -H "Authorization: Token $REPLICATE_API_TOKEN" \\ |
| 784 | + -H "Content-Type: application/json" \\ |
| 785 | + -d '{ |
| 786 | + "description": "Detect hot dogs in images", |
| 787 | + "readme": "# Hot Dog Detector\n\n🌭 Ketchup, mustard, and onions...", |
| 788 | + "github_url": "https://github.com/alice/hot-dog-detector", |
| 789 | + "paper_url": "https://arxiv.org/abs/2504.17639", |
| 790 | + "weights_url": "https://huggingface.co/alice/hot-dog-detector", |
| 791 | + "license_url": "https://choosealicense.com/licenses/mit/" |
| 792 | + }' |
| 793 | + ``` |
| 794 | + |
| 795 | + The response will be the updated model object with all of its properties. |
| 796 | + |
| 797 | + Args: |
| 798 | + description: A description of the model. |
| 799 | + |
| 800 | + github_url: A URL for the model's source code on GitHub. |
| 801 | + |
| 802 | + license_url: A URL for the model's license. |
| 803 | + |
| 804 | + paper_url: A URL for the model's paper. |
| 805 | + |
| 806 | + readme: The README content of the model. |
| 807 | + |
| 808 | + weights_url: A URL for the model's weights. |
| 809 | + |
| 810 | + extra_headers: Send extra headers |
| 811 | + |
| 812 | + extra_query: Add additional query parameters to the request |
| 813 | + |
| 814 | + extra_body: Add additional JSON properties to the request |
| 815 | + |
| 816 | + timeout: Override the client-level default timeout for this request, in seconds |
| 817 | + """ |
| 818 | + if not model_owner: |
| 819 | + raise ValueError(f"Expected a non-empty value for `model_owner` but received {model_owner!r}") |
| 820 | + if not model_name: |
| 821 | + raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") |
| 822 | + return await self._patch( |
| 823 | + f"/models/{model_owner}/{model_name}", |
| 824 | + body=await async_maybe_transform( |
| 825 | + { |
| 826 | + "description": description, |
| 827 | + "github_url": github_url, |
| 828 | + "license_url": license_url, |
| 829 | + "paper_url": paper_url, |
| 830 | + "readme": readme, |
| 831 | + "weights_url": weights_url, |
| 832 | + }, |
| 833 | + model_update_params.ModelUpdateParams, |
| 834 | + ), |
| 835 | + options=make_request_options( |
| 836 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 837 | + ), |
| 838 | + cast_to=ModelUpdateResponse, |
| 839 | + ) |
| 840 | + |
654 | 841 | def list( |
655 | 842 | self, |
656 | 843 | *, |
@@ -956,6 +1143,9 @@ def __init__(self, models: ModelsResource) -> None: |
956 | 1143 | self.create = to_raw_response_wrapper( |
957 | 1144 | models.create, |
958 | 1145 | ) |
| 1146 | + self.update = to_raw_response_wrapper( |
| 1147 | + models.update, |
| 1148 | + ) |
959 | 1149 | self.list = to_raw_response_wrapper( |
960 | 1150 | models.list, |
961 | 1151 | ) |
@@ -993,6 +1183,9 @@ def __init__(self, models: AsyncModelsResource) -> None: |
993 | 1183 | self.create = async_to_raw_response_wrapper( |
994 | 1184 | models.create, |
995 | 1185 | ) |
| 1186 | + self.update = async_to_raw_response_wrapper( |
| 1187 | + models.update, |
| 1188 | + ) |
996 | 1189 | self.list = async_to_raw_response_wrapper( |
997 | 1190 | models.list, |
998 | 1191 | ) |
@@ -1030,6 +1223,9 @@ def __init__(self, models: ModelsResource) -> None: |
1030 | 1223 | self.create = to_streamed_response_wrapper( |
1031 | 1224 | models.create, |
1032 | 1225 | ) |
| 1226 | + self.update = to_streamed_response_wrapper( |
| 1227 | + models.update, |
| 1228 | + ) |
1033 | 1229 | self.list = to_streamed_response_wrapper( |
1034 | 1230 | models.list, |
1035 | 1231 | ) |
@@ -1067,6 +1263,9 @@ def __init__(self, models: AsyncModelsResource) -> None: |
1067 | 1263 | self.create = async_to_streamed_response_wrapper( |
1068 | 1264 | models.create, |
1069 | 1265 | ) |
| 1266 | + self.update = async_to_streamed_response_wrapper( |
| 1267 | + models.update, |
| 1268 | + ) |
1070 | 1269 | self.list = async_to_streamed_response_wrapper( |
1071 | 1270 | models.list, |
1072 | 1271 | ) |
|
0 commit comments