Class: Client<SessionType>
Type Parameters
Type Parameter | Default type |
---|---|
|
|
Constructors
new Client()
new Client<SessionType>(config: SessionType["config"], session?: SessionType): Client<SessionType>
Parameters
Parameter | Type |
---|---|
|
|
|
|
Returns
Client
<SessionType
>
Properties
session
session: SessionType;
Methods
buildContext()
buildContext(): Promise<Context>
Get a new and well initialized context for this deployment.
Returns
Promise
<Context
>
A promise that resolves to a new context
getWorkflow()
getWorkflow(): Promise<Workflow>
Return deployment's workflow.
Returns
Promise
<Workflow
>
A promise that resolves to the workflow
run()
run(params: XOR<{
context: Context;
}, {
parameters: Record<string, string | number | boolean>;
taskName: string;
}, {
parameters: Record<string, string | number | boolean>;
taskId: number;
}> & XOR<{
image: ImageType | ImageIO | undefined;
}, {
images: ImageType | ImageIO[];
}, {
input: TaskIO<string, any>;
}, {
inputs: Results | TaskIO<string, any>[];
}> & {
onProgress: OnProgressCallback;
}): Promise<Results>
Run the deployment with the given parameters.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Parameters for the deployment. You can provide an |
Returns
Promise
<Results
>
A promise that resolves to the results of the deployment
Example
// Run a deployment with a single image input
await client.run({
image: 'https://example.com/image.jpg',
});
// Run a deployment with multiple images inputs
await client.run({
images: ['https://example.com/image1.jpg', 'https://example.com/image2.jpg'],
});
// Run a deployment with a context
const context = await client.buildContext();
context.setOutput('custom_output_task_name', 1);
context.setParameters('custom_task_name', {param1: 'value1', param2: 42});
await client.run({context, image: 'https://example.com/image.jpg'});
runStream()
runStream(params: undefined | XOR<{ context?: Context | undefined; }, { taskName?: string | undefined; parameters?: Record<string, string | number | boolean> | undefined; }, { taskId?: number | undefined; parameters?: Record<...> | undefined; }> & XOR<...> & { ...; }): AsyncGenerator<SessionState, void, unknown>
Same as run
, but returns an async generator that yields the state of the session at each polling iteration.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Parameters for the deployment. You can provide an |
Returns
AsyncGenerator
<SessionState
, void
, unknown
>
Yields
The state of the session at each polling iteration