Files
triggerdotdev--trigger.dev/integrations/replicate/src/utils.ts
T
nicktrn 6a992a1995 Replicate integration and remote callbacks (#507)
* Support tasks with remote callbacks

* Add common integration tsconfig

* Add Replicate integration

* Basic job catalog example

* Integration catalog entry

* Check for callbackUrl during executeTask

* Fix getAll

* Improve JSDoc

* Bump version

* Remove named queue

* Simplify runTask types

* Trust the types

* Fail tasks on timeout

* Callback timeout as param

* Mess with types

* performRunExecutionV1

* Update runTask docs

* Shorten callback task methods

* Fix run method return type

* Image processing jobs

* Replicate docs

* Text output example

* Changeset

* Version bump

* Roll back ugly types

* Remove missing types

* Quicker return when waiting on remote callback

* Remote callback example

* Bump version

* Remove schema parsing

* Only schedule positive callback timeout

* Decrease callback secret length

* Explicit default timeouts

* Import deployments tasks

* JSDoc

* Deployments docs

* Fix runTask examples, mention wrappers

---------

Co-authored-by: Eric Allam <eric@trigger.dev>
2023-10-04 10:46:17 +01:00

59 lines
1.6 KiB
TypeScript

import { CallbackTimeout } from "./types";
export const createPredictionProperties = (
params: Partial<{
version: string;
stream: boolean;
}>
) => {
return [
...(params.version ? [{ label: "Model Version", text: params.version }] : []),
...streamingProperty(params),
];
};
export const createDeploymentProperties = (
params: Partial<{
deployment_owner: string;
deployment_name: string;
stream: boolean;
}>
) => {
return [
...(params.deployment_owner
? [{ label: "Deployment Owner", text: params.deployment_owner }]
: []),
...(params.deployment_name ? [{ label: "Deployment Name", text: params.deployment_name }] : []),
...streamingProperty(params),
];
};
export const modelProperties = (
params: Partial<{
model_owner: string;
model_name: string;
version_id: string;
destination: string;
}>
) => {
return [
...(params.model_owner ? [{ label: "Model Owner", text: params.model_owner }] : []),
...(params.model_name ? [{ label: "Model Name", text: params.model_name }] : []),
...(params.version_id ? [{ label: "Model Version", text: params.version_id }] : []),
...(params.destination ? [{ label: "Destination Model", text: params.destination }] : []),
];
};
export const streamingProperty = (params: { stream?: boolean }) => {
return [{ label: "Streaming Enabled", text: String(!!params.stream) }];
};
export const callbackProperties = (options: CallbackTimeout) => {
return [
{
label: "Callback Timeout",
text: options.timeoutInSeconds ? `${options.timeoutInSeconds}s` : "default",
},
];
};