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.
Are we still using aborted, @erbridge? Just noticed it because we were discussing statuses today.
There was a problem hiding this comment.
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.
We are using it, so we should probably update the schema.
There was a problem hiding this comment.
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.
@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.
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.
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.
Yeah, fair! I'm not sure. 😔 I wouldn't be surprised if there were inconsistencies there. Good to clean it up.
superhighfives
left a comment
There was a problem hiding this comment.
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