runpod-sdk 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,7 +37,7 @@ const status = await endpoint.getStatus(requestId);
37
37
 
38
38
  If the request has been completed, the status object returned will contain the `output` of the request.
39
39
 
40
- If you don't want to manage polling for request completion yourself, you can simply call `runSync`, which will enqueue the request and then poll in a loop (by default, once every 10 seconds) until the request completes, fails or times out.
40
+ If you don't want to manage polling for request completion yourself, you can simply call `runSync`, which will enqueue the request and then poll until the request completes, fails or times out.
41
41
 
42
42
  ```js
43
43
  const result = await endpoint.runSync({
@@ -0,0 +1,104 @@
1
+ export type ExecutionPolicy = {
2
+ ttl?: number;
3
+ executionTimeout?: number;
4
+ };
5
+ export type S3Config = {
6
+ accessId: string;
7
+ accessSecret: string;
8
+ bucketName: string;
9
+ endpointUrl: string;
10
+ };
11
+ export type EndpointInputPayload = {
12
+ input: any;
13
+ webhook?: string;
14
+ s3Config?: S3Config;
15
+ policy?: ExecutionPolicy;
16
+ };
17
+ export type EndpointIncompleteOutput = {
18
+ status: string;
19
+ id: string;
20
+ };
21
+ export type EndpointCompletedOutput = {
22
+ status: string;
23
+ id: string;
24
+ output: any;
25
+ executionTime: number;
26
+ delayTime: number;
27
+ };
28
+ export type EndpointOutput = EndpointCompletedOutput | EndpointIncompleteOutput;
29
+ export type CancelOutput = {
30
+ status: string;
31
+ id: string;
32
+ executionTime: number;
33
+ delayTime: number;
34
+ };
35
+ export type HealthCheck = {
36
+ jobs: {
37
+ completed: number;
38
+ failed: number;
39
+ inProgress: number;
40
+ inQueue: number;
41
+ retried: number;
42
+ };
43
+ workers: {
44
+ idle: number;
45
+ initializing: number;
46
+ ready: number;
47
+ running: number;
48
+ throttled: number;
49
+ };
50
+ };
51
+ export type PurgeQueueOutput = {
52
+ removed: number;
53
+ status: string;
54
+ };
55
+ export declare const runSync: import("ts-toolbelt/out/Function/Curry").Curry<(apiKey: string, endpointId: string, request: EndpointInputPayload) => Promise<{
56
+ started: boolean;
57
+ completed: boolean;
58
+ status: string;
59
+ id: string;
60
+ } | {
61
+ started: boolean;
62
+ completed: boolean;
63
+ status: string;
64
+ id: string;
65
+ output: any;
66
+ executionTime: number;
67
+ delayTime: number;
68
+ } | {
69
+ started: boolean;
70
+ completed: boolean;
71
+ succeeded: boolean;
72
+ status: string;
73
+ id: string;
74
+ } | {
75
+ started: boolean;
76
+ completed: boolean;
77
+ succeeded: boolean;
78
+ status: string;
79
+ id: string;
80
+ output: any;
81
+ executionTime: number;
82
+ delayTime: number;
83
+ }>>;
84
+ export declare const run: import("ts-toolbelt/out/Function/Curry").Curry<(apiKey: string, endpointId: string, request: EndpointInputPayload) => Promise<any>>;
85
+ export declare const getStatus: import("ts-toolbelt/out/Function/Curry").Curry<(apiKey: string, endpointId: string, requestId: string) => Promise<any>>;
86
+ export declare const stream: import("ts-toolbelt/out/Function/Curry").Curry<(apiKey: string, endpointId: string, requestId: string) => Promise<any>>;
87
+ export declare const getHealth: import("ts-toolbelt/out/Function/Curry").Curry<(apiKey: string, endpointId: string) => Promise<any>>;
88
+ export declare const purgeQueue: import("ts-toolbelt/out/Function/Curry").Curry<(apiKey: string, endpointId: string) => Promise<any>>;
89
+ declare class Endpoint {
90
+ endpointId: string;
91
+ private apiKey;
92
+ constructor(apiKey: string, endpointId: string);
93
+ runSync(request: EndpointInputPayload): Promise<EndpointCompletedOutput>;
94
+ run(request: EndpointInputPayload): Promise<string>;
95
+ getStatus(requestId: string): Promise<EndpointOutput>;
96
+ stream(requestId: string): Promise<EndpointOutput>;
97
+ cancel(requestId: string): Promise<CancelOutput>;
98
+ getHealth(): Promise<HealthCheck>;
99
+ purgeQueue(): Promise<PurgeQueueOutput>;
100
+ }
101
+ declare const _default: (apiKey: string) => {
102
+ endpoint: (endpointId: string) => Endpoint;
103
+ };
104
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import runpodSdk from "runpod-sdk"
2
+
3
+ const { RUNPOD_API_KEY, ENDPOINT_ID } = process.env
4
+ if (!(RUNPOD_API_KEY && ENDPOINT_ID)) {
5
+ console.log("please supply RUNPOD_API_KEY and ENDPOINT_ID as environment variables")
6
+ process.exit()
7
+ }
8
+ const runpod = runpodSdk(RUNPOD_API_KEY)
9
+ const endpoint = runpod.endpoint(ENDPOINT_ID)
10
+
11
+ const result = await endpoint.runSync({
12
+ input: {
13
+ prompt: "Hi, what's your name?",
14
+ },
15
+ })
16
+
17
+ console.log(result)
@@ -2,6 +2,7 @@ import runpodSdk from "../dist/index.js"
2
2
 
3
3
  const { RUNPOD_API_KEY, ENDPOINT_ID } = process.env
4
4
  if (!(RUNPOD_API_KEY && ENDPOINT_ID)) {
5
+ console.log("please supply RUNPOD_API_KEY and ENDPOINT_ID as environment variables")
5
6
  process.exit()
6
7
  }
7
8
  //OOP
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "runpod-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "JavaScript SDK for Runpod",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "type": "module",
7
8
  "author": "Runpod",
8
9
  "dependencies": {
package/tsconfig.json CHANGED
@@ -7,7 +7,8 @@
7
7
  "moduleResolution": "node",
8
8
  "lib": ["ES2022", "DOM"],
9
9
  "strict": true,
10
- "esModuleInterop": true
10
+ "esModuleInterop": true,
11
+ "declaration": true
11
12
  },
12
13
  "include": ["src/**/*.ts"]
13
14
  }