Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = off

[*.js]
[*.{js,ts}]
quote_type = single

[CHANGELOG.md]
Expand Down
83 changes: 34 additions & 49 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
type Identifier = `${string}/${string}:${string}`;
type WebhookEventType = "start" | "output" | "logs" | "completed";
type WebhookEventType = 'start' | 'output' | 'logs' | 'completed';

declare module "replicate" {
export interface ReplicateOptions {
auth: string;
userAgent?: string;
baseUrl?: string;
}
interface Page<T> {
previous?: string;
next?: string;
results: T[];
}

declare module 'replicate' {
export interface Collection {
id: string;
name: string;
Expand Down Expand Up @@ -43,39 +43,17 @@ declare module "replicate" {
updated: string;
}

export interface CollectionsGetOptions {
collection_slug: string;
}

export interface ModelsGetOptions {
model_owner: string;
model_name: string;
}

export interface ModelsVersionsListOptions {
model_owner: string;
model_name: string;
}
export default class Replicate {
constructor(options: {
auth: string;
userAgent?: string;
baseUrl?: string;
});

export interface ModelsVersionsGetOptions {
model_owner: string;
model_name: string;
id: string;
}

export interface PredictionsCreateOptions {
version: string;
input: any;
webhook?: string;
webhook_events_filter?: WebhookEventType[];
}

export interface PredictionsGetOptions {
predictionId: string;
}

export class Replicate {
constructor(options: ReplicateOptions);
auth: string;
userAgent?: string;
baseUrl?: string;
private instance: any;

run(
identifier: Identifier,
Expand All @@ -87,7 +65,7 @@ declare module "replicate" {
}
): Promise<object>;
request(route: string, parameters: any): Promise<any>;
paginate<T>(endpoint: () => Promise<T>): AsyncGenerator<T[]>;
paginate<T>(endpoint: () => Promise<Page<T>>): AsyncGenerator<[T]>;
wait(
prediction: Prediction,
options: {
Expand All @@ -97,23 +75,30 @@ declare module "replicate" {
): Promise<Prediction>;

collections: {
get(options: CollectionsGetOptions): Promise<Collection>;
get(collection_slug: string): Promise<Collection>;
};

models: {
get(options: ModelsGetOptions): Promise<Model>;
get(model_owner: string, model_name: string): Promise<Model>;
versions: {
list(options: ModelsVersionsListOptions): Promise<ModelVersion[]>;
get(options: ModelsVersionsGetOptions): Promise<ModelVersion>;
list(model_owner: string, model_name: string): Promise<ModelVersion[]>;
get(
model_owner: string,
model_name: string,
version_id: string
): Promise<ModelVersion>;
};
};

predictions: {
create(options: PredictionsCreateOptions): Promise<Prediction>;
get(options: PredictionsGetOptions): Promise<Prediction>;
list(): Promise<Prediction[]>;
create(options: {
version: string;
input: any;
webhook?: string;
webhook_events_filter?: WebhookEventType[];
}): Promise<Prediction>;
get(prediction_id: string): Promise<Prediction>;
list(): Promise<Page<Prediction>>;
};
}

export default Replicate;
}
153 changes: 0 additions & 153 deletions index.test.js

This file was deleted.

Loading