-
Couldn't load subscription status.
- Fork 240
feat: update types to match OpenAPI schema #363
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
Conversation
This PR updates TypeScript types to match the OpenAPI schema from https://api.replicate.com/openapi.json Changes: - Account: add avatar_url field - Status: remove "aborted" status (not in OpenAPI schema) - FileObject: replace name, etag, checksum with checksums object - Prediction: add data_removed, deadline, deployment fields; change version to support "hidden"; update metrics to use total_time; add web URL - Training: convert from type alias to full interface with proper output structure - ModelVersion: make cog_version and openapi_schema nullable
| @@ -1,5 +1,5 @@ | |||
| declare module "replicate" { | |||
| type Status = "starting" | "processing" | "succeeded" | "failed" | "canceled" | "aborted"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we still using aborted, @erbridge? Just noticed it because we were discussing statuses today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's defined and used in replicate/api, but not yet documented in the OpenAPI schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using it, so we should probably update the schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝🏼 Shipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this PR: d702154
Per the OpenAPI schema, both predictions and trainings can have an "aborted" status, which indicates the task was terminated before it started running (e.g., when a deadline is reached before execution begins).
|
This is ready for another look. |
| }; | ||
| } | ||
|
|
||
| export type Training = Prediction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zeke Do we want to move to training being a standalone type? Currently it mirrors Prediction, so I'm not sure what this will do, if anything, to linting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Training and Prediction have different fields according to the OpenAPI schema, so I think they should be separate types:
Fields in Prediction but NOT in Training:
data_removed: booleandeadline?: stringdeployment?: string
Type differences:
version: Prediction isstring | "hidden", Training is juststringoutput: Prediction isany, Training is{ version?: string; weights?: string }urls: Prediction hasstream?, Training does not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these are also just inconsistencies between Training and Prediction in the OpenAPI schema, but I don't actually know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fair! I'm not sure. 😔 I wouldn't be surprised if there were inconsistencies there. Good to clean it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment, but looking good!
Per the OpenAPI schema, Training objects include a web URL in their urls object, matching the Prediction interface.
This PR updates TypeScript types to match the OpenAPI schema from https://api.replicate.com/openapi.json
Changes
Account
avatar_url?: stringfieldStatus
"aborted"status (not in OpenAPI schema)"starting" | "processing" | "succeeded" | "failed" | "canceled"FileObject
name: stringfieldetag: stringfieldchecksum: stringtochecksums: { sha256: string }Prediction
version: stringtoversion: string | "hidden"(for official models)data_removed: booleanfielddeadline?: stringfielddeployment?: stringfieldmetrics.predict_timetometrics.total_timeurls.web?: stringfieldTraining
type Training = Predictionto a full interfaceoutput?: { version?: string; weights?: string }structurepredict_timeandtotal_timegetandcancel(nostreamorweb)ModelVersion
cog_version: stringtocog_version: string | nullopenapi_schema: objecttoopenapi_schema: object | nullTesting locally
Prompts