Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aigur/client

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aigur/client - npm Package Compare versions

Comparing version 0.31.0 to 0.32.0

src/nodes/image/labeling/googleImageLabeling.ts

657

dist/index.d.ts
import { z } from 'zod';
declare class Builder<Input extends z.ZodObject<any, any, any>, Output extends z.ZodObject<any, any, any> | ZodReadableStream, NodeDefinitions extends ConcreteNode<any, any>[], PrevNode extends ConcreteNode<any, any> | null> {
private input;
private nodes;
constructor(input: Input, nodes: NodeDefinitions);
static create<Input extends z.ZodObject<any, any, any>, Output extends z.ZodObject<any, any, any> | ZodReadableStream>(input: Input): Builder<Input, Output, [], null>;
private nodeFactory;
private setPlaceholderValues;
custom<I extends z.AnyZodObject, O extends z.AnyZodObject | ZodReadableStream>(node: NodeDefinition<I, O>): <NextNode extends ConcreteNode<I, O>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
voice: {
textToSpeech: {
google: <NextNode extends ConcreteNode<z.ZodObject<{
text: z.ZodString;
speakingRate: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
pitch: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
encoding: z.ZodDefault<z.ZodOptional<z.ZodEnum<["MP3", "FLAC", "LINEAR16", "MULAW", "AMR", "AMR_WB", "OGG_OPUS", "SPEEX_WITH_HEADER_BYTE", "WEBM_OPUS"]>>>;
voice: z.ZodDefault<z.ZodOptional<z.ZodObject<{
language: z.ZodDefault<z.ZodOptional<z.ZodString>>;
name: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodEnum<["en-US-Standard-A", "en-US-Standard-C", "en-US-Standard-D", "en-US-Standard-E", "en-US-Standard-F", "en-US-Standard-G", "en-US-Standard-H", "en-US-Standard-I", "en-US-Standard-J", "en-US-Studio-M", "en-US-Studio-O", "en-US-Wavenet-A", "en-US-Wavenet-B", "en-US-Wavenet-C", "en-US-Wavenet-D", "en-US-Wavenet-E", "en-US-Wavenet-F", "en-US-Wavenet-G", "en-US-Wavenet-H", "en-US-Wavenet-I", "en-US-Wavenet-J", "en-US-News-K", "en-US-News-L", "en-US-News-M", "en-US-News-N", "en-US-Standard-A", "en-US-Standard-B", "en-US-Standard-C", "en-US-Standard-D", "en-US-Standard-E", "en-US-Standard-F", "en-US-Standard-G", "en-US-Standard-H", "en-US-Standard-I", "en-US-Standard-J"]>, z.ZodString]>>>;
}, "strip", z.ZodTypeAny, {
language: string;
name: string;
}, {
language?: string | undefined;
name?: string | undefined;
}>>>;
}, "strip", z.ZodTypeAny, {
text: string;
speakingRate: number;
pitch: number;
encoding: "MP3" | "FLAC" | "LINEAR16" | "MULAW" | "AMR" | "AMR_WB" | "OGG_OPUS" | "SPEEX_WITH_HEADER_BYTE" | "WEBM_OPUS";
voice: {
language: string;
name: string;
};
}, {
speakingRate?: number | undefined;
pitch?: number | undefined;
encoding?: "MP3" | "FLAC" | "LINEAR16" | "MULAW" | "AMR" | "AMR_WB" | "OGG_OPUS" | "SPEEX_WITH_HEADER_BYTE" | "WEBM_OPUS" | undefined;
voice?: {
language?: string | undefined;
name?: string | undefined;
} | undefined;
text: string;
}>, z.ZodObject<{
audio: z.ZodString;
}, "strip", z.ZodTypeAny, {
audio: string;
}, {
audio: string;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
};
transcribe: {
whisper: {
whisperapi: <NextNode_1 extends ConcreteNode<z.ZodObject<{
audioUrl: z.ZodString;
language: z.ZodDefault<z.ZodString>;
autoDetectLanguage: z.ZodDefault<z.ZodBoolean>;
fileType: z.ZodDefault<z.ZodString>;
task: z.ZodDefault<z.ZodEnum<["transcribe", "translate"]>>;
}, "strip", z.ZodTypeAny, {
audioUrl: string;
language: string;
autoDetectLanguage: boolean;
fileType: string;
task: "transcribe" | "translate";
}, {
language?: string | undefined;
autoDetectLanguage?: boolean | undefined;
fileType?: string | undefined;
task?: "transcribe" | "translate" | undefined;
audioUrl: string;
}>, z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode_1["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode_1], NextNode_1>;
};
};
};
text: {
modify: {
enhanceWithKeywords: <NextNode extends ConcreteNode<z.ZodObject<{
text: z.ZodString;
amount: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
text: string;
amount: number;
}, {
amount?: number | undefined;
text: string;
}>, z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
simple: <NextNode_1 extends ConcreteNode<z.ZodObject<{
text: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
modifier: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string | string[];
modifier: string;
}, {
text: string | string[];
modifier: string;
}>, z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode_1["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode_1], NextNode_1>;
};
prediction: {
gpt3: <NextNode_2 extends ConcreteNode<z.ZodObject<{
prompt: z.ZodString;
model: z.ZodDefault<z.ZodEnum<["text-davinci-003", "text-curie-001", "text-babbage-001", "text-ada-001", "code-davinci-002", "code-cushman-002"]>>;
temperature: z.ZodDefault<z.ZodNumber>;
top_p: z.ZodDefault<z.ZodNumber>;
frequency_penalty: z.ZodDefault<z.ZodNumber>;
presence_penalty: z.ZodDefault<z.ZodNumber>;
max_tokens: z.ZodDefault<z.ZodNumber>;
n: z.ZodDefault<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
prompt: string;
model: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002";
temperature: number;
top_p: number;
frequency_penalty: number;
presence_penalty: number;
max_tokens: number;
n: number;
}, {
model?: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002" | undefined;
temperature?: number | undefined;
top_p?: number | undefined;
frequency_penalty?: number | undefined;
presence_penalty?: number | undefined;
max_tokens?: number | undefined;
n?: number | undefined;
prompt: string;
}>, z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode_2["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode_2], NextNode_2>;
gpt3Stream: <NextNode_3 extends ConcreteNode<z.ZodObject<z.extendShape<{
prompt: z.ZodString;
model: z.ZodDefault<z.ZodEnum<["text-davinci-003", "text-curie-001", "text-babbage-001", "text-ada-001", "code-davinci-002", "code-cushman-002"]>>;
temperature: z.ZodDefault<z.ZodNumber>;
top_p: z.ZodDefault<z.ZodNumber>;
frequency_penalty: z.ZodDefault<z.ZodNumber>;
presence_penalty: z.ZodDefault<z.ZodNumber>;
max_tokens: z.ZodDefault<z.ZodNumber>;
n: z.ZodDefault<z.ZodNumber>;
}, {
stream: z.ZodDefault<z.ZodOptional<z.ZodLiteral<true>>>;
}>, "strip", z.ZodTypeAny, {
prompt: string;
model: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002";
temperature: number;
top_p: number;
frequency_penalty: number;
presence_penalty: number;
max_tokens: number;
n: number;
stream: true;
}, {
model?: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002" | undefined;
temperature?: number | undefined;
top_p?: number | undefined;
frequency_penalty?: number | undefined;
presence_penalty?: number | undefined;
max_tokens?: number | undefined;
n?: number | undefined;
stream?: true | undefined;
prompt: string;
}>, z.ZodObject<{
stream: z.ZodType<ReadableStream<unknown>, z.ZodTypeDef, ReadableStream<unknown>>;
}, "strip", z.ZodTypeAny, {
stream: ReadableStream<unknown>;
}, {
stream: ReadableStream<unknown>;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode_3["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode_3], NextNode_3>;
};
};
image: {
textToImage: {
stableDiffusion: {
stability: <NextNode extends ConcreteNode<z.ZodObject<{
text_prompts: z.ZodArray<z.ZodObject<{
text: z.ZodString;
weight: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
text: string;
weight: number;
}, {
weight?: number | undefined;
text: string;
}>, "atleastone">;
model: z.ZodDefault<z.ZodOptional<z.ZodEnum<["stable-diffusion-v1-5", "stable-diffusion-512-v2-0", "stable-diffusion-768-v2-0", "stable-diffusion-512-v2-1", "stable-diffusion-768-v2-1"]>>>;
clip_guidance_preset: z.ZodOptional<z.ZodEnum<["NONE", "FAST_BLUE", "FAST_GREEN", "SIMPLE", "SLOW", "SLOWER", "SLOWEST"]>>;
steps: z.ZodOptional<z.ZodNumber>;
sampler: z.ZodOptional<z.ZodEnum<["DDIM", "DDPM", "K_DPMPP_2M", "K_DPMPP_2S_ANCESTRAL", "K_DPM_2", "K_DPM_2_ANCESTRAL", "K_EULER", "K_EULER_ANCESTRAL", "K_HEUN", "K_LMS"]>>;
cfg_scale: z.ZodOptional<z.ZodNumber>;
seed: z.ZodOptional<z.ZodNumber>;
height: z.ZodEffects<z.ZodOptional<z.ZodNumber>, number | undefined, number | undefined>;
width: z.ZodEffects<z.ZodOptional<z.ZodNumber>, number | undefined, number | undefined>;
}, "strip", z.ZodTypeAny, {
clip_guidance_preset?: "NONE" | "FAST_BLUE" | "FAST_GREEN" | "SIMPLE" | "SLOW" | "SLOWER" | "SLOWEST" | undefined;
steps?: number | undefined;
sampler?: "DDIM" | "DDPM" | "K_DPMPP_2M" | "K_DPMPP_2S_ANCESTRAL" | "K_DPM_2" | "K_DPM_2_ANCESTRAL" | "K_EULER" | "K_EULER_ANCESTRAL" | "K_HEUN" | "K_LMS" | undefined;
cfg_scale?: number | undefined;
seed?: number | undefined;
height?: number | undefined;
width?: number | undefined;
model: "stable-diffusion-v1-5" | "stable-diffusion-512-v2-0" | "stable-diffusion-768-v2-0" | "stable-diffusion-512-v2-1" | "stable-diffusion-768-v2-1";
text_prompts: [{
text: string;
weight: number;
}, ...{
text: string;
weight: number;
}[]];
}, {
model?: "stable-diffusion-v1-5" | "stable-diffusion-512-v2-0" | "stable-diffusion-768-v2-0" | "stable-diffusion-512-v2-1" | "stable-diffusion-768-v2-1" | undefined;
clip_guidance_preset?: "NONE" | "FAST_BLUE" | "FAST_GREEN" | "SIMPLE" | "SLOW" | "SLOWER" | "SLOWEST" | undefined;
steps?: number | undefined;
sampler?: "DDIM" | "DDPM" | "K_DPMPP_2M" | "K_DPMPP_2S_ANCESTRAL" | "K_DPM_2" | "K_DPM_2_ANCESTRAL" | "K_EULER" | "K_EULER_ANCESTRAL" | "K_HEUN" | "K_LMS" | undefined;
cfg_scale?: number | undefined;
seed?: number | undefined;
height?: number | undefined;
width?: number | undefined;
text_prompts: [{
weight?: number | undefined;
text: string;
}, ...{
weight?: number | undefined;
text: string;
}[]];
}>, z.ZodObject<{
result: z.ZodType<ArrayBuffer, z.ZodTypeDef, ArrayBuffer>;
}, "strip", z.ZodTypeAny, {
result: ArrayBuffer;
}, {
result: ArrayBuffer;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
};
};
labeling: {
google: <NextNode_1 extends ConcreteNode<z.ZodObject<{
image: z.ZodString;
}, "strip", z.ZodTypeAny, {
image: string;
}, {
image: string;
}>, z.ZodObject<{
labels: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
labels: string[];
}, {
labels: string[];
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode_1["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode_1], NextNode_1>;
};
};
output: <NextNode extends ConcreteNode<Output, Output>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
transformation: {
stringToArrayBuffer: <NextNode extends ConcreteNode<z.ZodObject<{
string: z.ZodString;
}, "strip", z.ZodTypeAny, {
string: string;
}, {
string: string;
}>, z.ZodObject<{
arrayBuffer: z.ZodType<ArrayBuffer, z.ZodTypeDef, ArrayBuffer>;
}, "strip", z.ZodTypeAny, {
arrayBuffer: ArrayBuffer;
}, {
arrayBuffer: ArrayBuffer;
}>>>(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode["output"] : Input;
input: z.output<Input>;
}) => z.input<NextNode["schema"]["input"]>) => Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
};
getNodes(): NodeDefinitions;
}
interface PipelineConf<Input extends z.AnyZodObject, Output extends z.AnyZodObject | ZodReadableStream> {

@@ -340,3 +7,3 @@ id: string;

output: Output;
flow: (builder: Builder<Input, Output, [], null>) => Builder<Input, Output, any, ConcreteNode<Output, Output>>;
flow: (builder: FlowBuilder<Input, Output, [], null>) => FlowBuilder<Input, Output, any, ConcreteNode<z.input<Output>, z.output<Output>>>;
retries?: number;

@@ -347,14 +14,8 @@ stream?: boolean;

}
type NodeDefinition<Input extends z.AnyZodObject | ZodReadableStream, Output extends z.AnyZodObject | ZodReadableStream> = {
id: string;
schema: {
input: Input;
output: Output;
};
action: (input: z.output<Input>, apiKeys: Record<string, string>) => Promise<z.output<Output>>;
type NodeAction<Input extends Record<string, unknown> | ReadableStream, Output extends Record<string, unknown> | ReadableStream> = (input: Input, apiKeys: Record<string, string>) => Promise<Output>;
type ConcreteNode<Input extends Record<string, unknown> | ReadableStream, Output extends Record<string, unknown> | ReadableStream> = {
action: NodeAction<Input, Output>;
input: Input;
output: Output;
};
type ConcreteNode<Input extends z.AnyZodObject | ZodReadableStream, Output extends z.AnyZodObject | ZodReadableStream> = NodeDefinition<Input, Output> & {
input: z.output<Input>;
output: z.output<Output>;
};
type ProgressEventType = 'node:start' | 'node:finish' | 'node:stream';

@@ -369,5 +30,21 @@ type ZodReadableStream = z.ZodType<InstanceType<typeof ReadableStream>, z.ZodTypeDef, InstanceType<typeof ReadableStream>>;

declare class FlowBuilder<Input extends z.ZodObject<any, any, any>, Output extends z.ZodObject<any, any, any> | ZodReadableStream, NodeDefinitions extends ConcreteNode<any, any>[], PrevNode extends ConcreteNode<any, any> | null> {
private input;
private nodes;
constructor(input: Input, nodes: NodeDefinitions);
static create<Input extends z.ZodObject<any, any, any>, Output extends z.ZodObject<any, any, any> | ZodReadableStream>(input: Input): FlowBuilder<Input, Output, [], null>;
node<NodeDef extends NodeAction<any, any>>(nodeDefinition: NodeDef, getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? Awaited<ReturnType<PrevNode['action']>> : Input;
input: z.output<Input>;
}) => Parameters<NodeDef>['0']): FlowBuilder<Input, Output, [...NodeDefinitions, ConcreteNode<Parameters<NodeDef>["0"], Awaited<ReturnType<NodeDef>>>], ConcreteNode<Parameters<NodeDef>["0"], Awaited<ReturnType<NodeDef>>>>;
private createDynamicPlaceholders;
private setPlaceholderValues;
output: any;
getNodes(): NodeDefinitions;
}
declare class Pipeline<Input extends z.AnyZodObject, Output extends z.AnyZodObject | ZodReadableStream> {
readonly conf: PipelineConf<Input, Output>;
readonly flow: Builder<z.AnyZodObject, z.AnyZodObject | ZodReadableStream, any, any>;
readonly flow: FlowBuilder<z.AnyZodObject, z.AnyZodObject | ZodReadableStream, any, any>;
private readonly apiKeys;

@@ -381,3 +58,3 @@ readonly onProgressListeners: Map<string, (args: {

readonly onFinishListeners: Map<string, () => void>;
constructor(conf: PipelineConf<Input, Output>, flow: Builder<z.AnyZodObject, z.AnyZodObject | ZodReadableStream, any, any>, apiKeys: APIKeys);
constructor(conf: PipelineConf<Input, Output>, flow: FlowBuilder<z.AnyZodObject, z.AnyZodObject | ZodReadableStream, any, any>, apiKeys: APIKeys);
invoke(input: z.input<Input>): Promise<z.output<Output>>;

@@ -419,2 +96,286 @@ invokeRemote(endpoint: string, input: z.input<Input>): Promise<z.output<Output>>;

export { Aigur, Pipeline, createClient, vercelGenericEdge };
declare const inputSchema$8: z.ZodObject<{
image: z.ZodString;
}, "strip", z.ZodTypeAny, {
image: string;
}, {
image: string;
}>;
declare const outputSchema$8: z.ZodObject<{
labels: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
labels: string[];
}, {
labels: string[];
}>;
declare function googleImageLabeling(input: z.input<typeof inputSchema$8>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$8>>;
declare const stabilityModel: z.ZodEnum<["stable-diffusion-v1-5", "stable-diffusion-512-v2-0", "stable-diffusion-768-v2-0", "stable-diffusion-512-v2-1", "stable-diffusion-768-v2-1"]>;
declare const stabilityClipGuidancePreset: z.ZodEnum<["NONE", "FAST_BLUE", "FAST_GREEN", "SIMPLE", "SLOW", "SLOWER", "SLOWEST"]>;
declare const inputSchema$7: z.ZodObject<{
text_prompts: z.ZodEffects<z.ZodArray<z.ZodObject<{
text: z.ZodString;
weight: z.ZodDefault<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
text: string;
weight: number;
}, {
weight?: number | undefined;
text: string;
}>, "many">, {
text: string;
weight: number;
}[], {
weight?: number | undefined;
text: string;
}[]>;
model: z.ZodDefault<z.ZodEnum<["stable-diffusion-v1-5", "stable-diffusion-512-v2-0", "stable-diffusion-768-v2-0", "stable-diffusion-512-v2-1", "stable-diffusion-768-v2-1"]>>;
clip_guidance_preset: z.ZodOptional<z.ZodEnum<["NONE", "FAST_BLUE", "FAST_GREEN", "SIMPLE", "SLOW", "SLOWER", "SLOWEST"]>>;
steps: z.ZodOptional<z.ZodNumber>;
sampler: z.ZodOptional<z.ZodEnum<["DDIM", "DDPM", "K_DPMPP_2M", "K_DPMPP_2S_ANCESTRAL", "K_DPM_2", "K_DPM_2_ANCESTRAL", "K_EULER", "K_EULER_ANCESTRAL", "K_HEUN", "K_LMS"]>>;
cfg_scale: z.ZodOptional<z.ZodNumber>;
seed: z.ZodOptional<z.ZodNumber>;
height: z.ZodEffects<z.ZodOptional<z.ZodNumber>, number | undefined, number | undefined>;
width: z.ZodEffects<z.ZodOptional<z.ZodNumber>, number | undefined, number | undefined>;
}, "strip", z.ZodTypeAny, {
clip_guidance_preset?: "NONE" | "FAST_BLUE" | "FAST_GREEN" | "SIMPLE" | "SLOW" | "SLOWER" | "SLOWEST" | undefined;
steps?: number | undefined;
sampler?: "DDIM" | "DDPM" | "K_DPMPP_2M" | "K_DPMPP_2S_ANCESTRAL" | "K_DPM_2" | "K_DPM_2_ANCESTRAL" | "K_EULER" | "K_EULER_ANCESTRAL" | "K_HEUN" | "K_LMS" | undefined;
cfg_scale?: number | undefined;
seed?: number | undefined;
height?: number | undefined;
width?: number | undefined;
text_prompts: {
text: string;
weight: number;
}[];
model: "stable-diffusion-v1-5" | "stable-diffusion-512-v2-0" | "stable-diffusion-768-v2-0" | "stable-diffusion-512-v2-1" | "stable-diffusion-768-v2-1";
}, {
model?: "stable-diffusion-v1-5" | "stable-diffusion-512-v2-0" | "stable-diffusion-768-v2-0" | "stable-diffusion-512-v2-1" | "stable-diffusion-768-v2-1" | undefined;
clip_guidance_preset?: "NONE" | "FAST_BLUE" | "FAST_GREEN" | "SIMPLE" | "SLOW" | "SLOWER" | "SLOWEST" | undefined;
steps?: number | undefined;
sampler?: "DDIM" | "DDPM" | "K_DPMPP_2M" | "K_DPMPP_2S_ANCESTRAL" | "K_DPM_2" | "K_DPM_2_ANCESTRAL" | "K_EULER" | "K_EULER_ANCESTRAL" | "K_HEUN" | "K_LMS" | undefined;
cfg_scale?: number | undefined;
seed?: number | undefined;
height?: number | undefined;
width?: number | undefined;
text_prompts: {
weight?: number | undefined;
text: string;
}[];
}>;
declare const outputSchema$7: z.ZodObject<{
result: z.ZodType<ArrayBuffer, z.ZodTypeDef, ArrayBuffer>;
}, "strip", z.ZodTypeAny, {
result: ArrayBuffer;
}, {
result: ArrayBuffer;
}>;
declare function stabilityTextToImage(input: z.input<typeof inputSchema$7>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$7>>;
declare function output<PipelineOutput extends z.AnyZodObject | ZodReadableStream>(input: z.input<PipelineOutput>): Promise<z.output<PipelineOutput>>;
declare const inputSchema$6: z.ZodObject<{
text: z.ZodString;
amount: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
text: string;
amount: number;
}, {
amount?: number | undefined;
text: string;
}>;
declare const outputSchema$6: z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>;
declare function enhanceWithKeywords(input: z.input<typeof inputSchema$6>): Promise<z.infer<typeof outputSchema$6>>;
declare const inputSchema$5: z.ZodObject<{
text: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
modifier: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string | string[];
modifier: string;
}, {
text: string | string[];
modifier: string;
}>;
declare const outputSchema$5: z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>;
declare function replaceString(input: z.input<typeof inputSchema$5>): Promise<z.infer<typeof outputSchema$5>>;
declare const inputSchema$4: z.ZodObject<{
prompt: z.ZodString;
model: z.ZodDefault<z.ZodEnum<["text-davinci-003", "text-curie-001", "text-babbage-001", "text-ada-001", "code-davinci-002", "code-cushman-002"]>>;
temperature: z.ZodDefault<z.ZodNumber>;
top_p: z.ZodDefault<z.ZodNumber>;
frequency_penalty: z.ZodDefault<z.ZodNumber>;
presence_penalty: z.ZodDefault<z.ZodNumber>;
max_tokens: z.ZodDefault<z.ZodNumber>;
n: z.ZodDefault<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
model: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002";
prompt: string;
temperature: number;
top_p: number;
frequency_penalty: number;
presence_penalty: number;
max_tokens: number;
n: number;
}, {
model?: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002" | undefined;
temperature?: number | undefined;
top_p?: number | undefined;
frequency_penalty?: number | undefined;
presence_penalty?: number | undefined;
max_tokens?: number | undefined;
n?: number | undefined;
prompt: string;
}>;
declare const outputSchema$4: z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>;
declare function gpt3Prediction(input: z.input<typeof inputSchema$4>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$4>>;
declare const inputSchema$3: z.ZodObject<z.extendShape<{
prompt: z.ZodString;
model: z.ZodDefault<z.ZodEnum<["text-davinci-003", "text-curie-001", "text-babbage-001", "text-ada-001", "code-davinci-002", "code-cushman-002"]>>;
temperature: z.ZodDefault<z.ZodNumber>;
top_p: z.ZodDefault<z.ZodNumber>;
frequency_penalty: z.ZodDefault<z.ZodNumber>;
presence_penalty: z.ZodDefault<z.ZodNumber>;
max_tokens: z.ZodDefault<z.ZodNumber>;
n: z.ZodDefault<z.ZodNumber>;
}, {
stream: z.ZodDefault<z.ZodOptional<z.ZodLiteral<true>>>;
}>, "strip", z.ZodTypeAny, {
model: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002";
prompt: string;
temperature: number;
top_p: number;
frequency_penalty: number;
presence_penalty: number;
max_tokens: number;
n: number;
stream: true;
}, {
model?: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002" | undefined;
temperature?: number | undefined;
top_p?: number | undefined;
frequency_penalty?: number | undefined;
presence_penalty?: number | undefined;
max_tokens?: number | undefined;
n?: number | undefined;
stream?: true | undefined;
prompt: string;
}>;
declare const outputSchema$3: z.ZodObject<{
stream: z.ZodType<ReadableStream<unknown>, z.ZodTypeDef, ReadableStream<unknown>>;
}, "strip", z.ZodTypeAny, {
stream: ReadableStream<unknown>;
}, {
stream: ReadableStream<unknown>;
}>;
declare function gpt3PredictionStream(input: z.input<typeof inputSchema$3>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$3>>;
declare const inputSchema$2: z.ZodObject<{
string: z.ZodString;
}, "strip", z.ZodTypeAny, {
string: string;
}, {
string: string;
}>;
declare const outputSchema$2: z.ZodObject<{
arrayBuffer: z.ZodType<ArrayBuffer, z.ZodTypeDef, ArrayBuffer>;
}, "strip", z.ZodTypeAny, {
arrayBuffer: ArrayBuffer;
}, {
arrayBuffer: ArrayBuffer;
}>;
declare function stringToArrayBuffer(input: z.input<typeof inputSchema$2>): Promise<z.infer<typeof outputSchema$2>>;
declare const inputSchema$1: z.ZodObject<{
text: z.ZodString;
speakingRate: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
pitch: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
encoding: z.ZodDefault<z.ZodOptional<z.ZodEnum<["MP3", "FLAC", "LINEAR16", "MULAW", "AMR", "AMR_WB", "OGG_OPUS", "SPEEX_WITH_HEADER_BYTE", "WEBM_OPUS"]>>>;
voice: z.ZodDefault<z.ZodOptional<z.ZodObject<{
language: z.ZodDefault<z.ZodOptional<z.ZodString>>;
name: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodEnum<["en-US-Standard-A", "en-US-Standard-C", "en-US-Standard-D", "en-US-Standard-E", "en-US-Standard-F", "en-US-Standard-G", "en-US-Standard-H", "en-US-Standard-I", "en-US-Standard-J", "en-US-Studio-M", "en-US-Studio-O", "en-US-Wavenet-A", "en-US-Wavenet-B", "en-US-Wavenet-C", "en-US-Wavenet-D", "en-US-Wavenet-E", "en-US-Wavenet-F", "en-US-Wavenet-G", "en-US-Wavenet-H", "en-US-Wavenet-I", "en-US-Wavenet-J", "en-US-News-K", "en-US-News-L", "en-US-News-M", "en-US-News-N", "en-US-Standard-A", "en-US-Standard-B", "en-US-Standard-C", "en-US-Standard-D", "en-US-Standard-E", "en-US-Standard-F", "en-US-Standard-G", "en-US-Standard-H", "en-US-Standard-I", "en-US-Standard-J"]>, z.ZodString]>>>;
}, "strip", z.ZodTypeAny, {
language: string;
name: string;
}, {
language?: string | undefined;
name?: string | undefined;
}>>>;
}, "strip", z.ZodTypeAny, {
text: string;
speakingRate: number;
pitch: number;
encoding: "MP3" | "FLAC" | "LINEAR16" | "MULAW" | "AMR" | "AMR_WB" | "OGG_OPUS" | "SPEEX_WITH_HEADER_BYTE" | "WEBM_OPUS";
voice: {
language: string;
name: string;
};
}, {
speakingRate?: number | undefined;
pitch?: number | undefined;
encoding?: "MP3" | "FLAC" | "LINEAR16" | "MULAW" | "AMR" | "AMR_WB" | "OGG_OPUS" | "SPEEX_WITH_HEADER_BYTE" | "WEBM_OPUS" | undefined;
voice?: {
language?: string | undefined;
name?: string | undefined;
} | undefined;
text: string;
}>;
declare const outputSchema$1: z.ZodObject<{
audio: z.ZodString;
}, "strip", z.ZodTypeAny, {
audio: string;
}, {
audio: string;
}>;
declare function googleTextToSpeech(input: z.input<typeof inputSchema$1>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$1>>;
declare const inputSchema: z.ZodObject<{
audioUrl: z.ZodString;
language: z.ZodDefault<z.ZodString>;
autoDetectLanguage: z.ZodDefault<z.ZodBoolean>;
fileType: z.ZodDefault<z.ZodString>;
task: z.ZodDefault<z.ZodEnum<["transcribe", "translate"]>>;
}, "strip", z.ZodTypeAny, {
language: string;
audioUrl: string;
autoDetectLanguage: boolean;
fileType: string;
task: "transcribe" | "translate";
}, {
language?: string | undefined;
autoDetectLanguage?: boolean | undefined;
fileType?: string | undefined;
task?: "transcribe" | "translate" | undefined;
audioUrl: string;
}>;
declare const outputSchema: z.ZodObject<{
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
text: string;
}, {
text: string;
}>;
declare function whisperApi(input: z.input<typeof inputSchema>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema>>;
export { Aigur, Pipeline, createClient, enhanceWithKeywords, googleImageLabeling, googleTextToSpeech, gpt3Prediction, gpt3PredictionStream, inputSchema$4 as inputSchema, output, outputSchema$4 as outputSchema, replaceString, stabilityClipGuidancePreset, stabilityModel, stabilityTextToImage, stringToArrayBuffer, vercelGenericEdge, whisperApi };

@@ -1,7 +0,7 @@

var T=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var X=(i,e)=>{for(var t in e)T(i,t,{get:e[t],enumerable:!0})},Q=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y(e))!q.call(i,o)&&o!==t&&T(i,o,{get:()=>e[o],enumerable:!(n=H(e,o))||n.enumerable});return i};var ee=i=>Q(T({},"__esModule",{value:!0}),i);var Ee={};X(Ee,{Pipeline:()=>N,createClient:()=>Ie,vercelGenericEdge:()=>Oe});module.exports=ee(Ee);function A(i=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length;for(let o=0;o<i;o++)e+=t.charAt(Math.floor(Math.random()*n));return e}function D(i,e){if(typeof i=="string")return o(i);let t={...i};return n(t);function n(r){for(let a in r)r[a]=o(r[a]);return r}function o(r){if(Array.isArray(r))return r.map(p=>n(p));if(typeof r=="object"&&r!==null)return n(r);let a=r,d=s(r);for(let p of d){let h=e[p.nodeId][p.property];if(h instanceof ArrayBuffer){a=h;continue}a=a?.replace(new RegExp(c(p.value)),h),a==="undefined"?a=void 0:a!==h&&a===h.toString()&&(a=h)}return a}function s(r){if(typeof r!="string")return[];let a=/\$context\.(\d+|input)\.(\w+)\$/g,d=r.matchAll(a),p=[];for(let f of d)p.push({value:f[0],nodeId:f[1],property:f[2]});return p}function c(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function K(i){return new Promise(e=>setTimeout(e,i))}var te=2,ne=350,N=class{constructor(e,t,n){this.conf=e;this.flow=t;this.apiKeys=n;this.onProgressListeners=new Map;this.onStartListeners=new Map;this.onFinishListeners=new Map;this.vercel={invoke:e=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e),invokeStream:(e,t)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t)};this.listenToEvents()}invoke(e){return this.processPipeline(this.conf,e)}invokeRemote(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(n=>n.json())}async invokeStream(e,t,n){let o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok)throw new Error(o.statusText);let s=o.body;if(!s)return;let c=s.getReader(),r=new TextDecoder,a=!1;for(;!a;){let{value:d,done:p}=await c.read();a=p;let f=r.decode(d);n(f)}}onProgress(e){let t=A();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=A();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=A();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}listenToEvents(){if(!this.conf.updateProgress||typeof window>"u"||!this.apiKeys?.ablySubscribe)return;let e=`https://realtime.ably.io/event-stream?channels=aigur-client&v=1.2&key=${this.apiKeys.ablySubscribe}&enveloped=false`,t=new EventSource(e);t.onmessage=n=>{let o=JSON.parse(n.data);o.type==="pipeline:start"?this.triggerListeners(this.onStartListeners):o.type==="pipeline:finish"?this.triggerListeners(this.onFinishListeners):(o.type==="node:start"||o.type==="node:finish")&&this.triggerListeners(this.onProgressListeners,{...o.data,type:o.type})}}triggerListeners(e,...t){for(let n of e.values())n(...t)}async processPipeline(e,t){let n=this.conf.retries??te;try{await this.notifyEvent("pipeline:start"),e.input.parse(t);let o={input:t},s={},c=this.flow.getNodes(),r;for(let a=0;a<c.length;a++){r=this.notifyEvent("node:start",{node:c[a],index:a});let d=0,p=!1;do{d++;try{s=await this.executeAction(c,a,o),o[a]=s,p=!0}catch(f){if(d>n)throw f;await K((this.conf.retryDelayInMs??ne)*d)}}while(!p&&d<=n);await r,await this.notifyEvent("node:finish",{node:c[a],index:a})}return await this.notifyEvent("pipeline:finish"),s}catch(o){throw console.error(o),o}}async executeAction(e,t,n){let{action:o,schema:s,input:c}=e[t],r=D(c,n);return o(r,this.apiKeys)}notifyEvent(e,t){if(!(!this.conf.updateProgress||!this.apiKeys.ablyPublish))return fetch("https://rest.ably.io/channels/aigur-client/messages?enveloped=false ",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${btoa(this.apiKeys.ablyPublish)}`},body:JSON.stringify({type:e,data:t})})}};var v=require("zod"),_=require("eventsource-parser");var m=require("zod"),w=m.z.object({prompt:m.z.string(),model:m.z.enum(["text-davinci-003","text-curie-001","text-babbage-001","text-ada-001","code-davinci-002","code-cushman-002"]).default("text-davinci-003"),temperature:m.z.number().min(0).max(2).default(.7),top_p:m.z.number().min(0).max(1).default(1),frequency_penalty:m.z.number().min(-2).max(2).default(0),presence_penalty:m.z.number().min(-2).max(2).default(0),max_tokens:m.z.number().default(200),n:m.z.number().default(1)}),oe=m.z.object({text:m.z.string()});async function ie(i,e){let t=w.parse(i);return{text:(await(await fetch("https://api.openai.com/v1/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)})).json()).choices[0]?.text.replace(/^(?:\n)+/gm,"")}}var I={id:"text.prediction.gpt3",schema:{input:w,output:oe},action:ie};var M=w.merge(v.z.object({stream:v.z.literal(!0).optional().default(!0)})),ae=v.z.object({stream:v.z.instanceof(globalThis.ReadableStream??Object)});async function re(i,e){let t=M.parse(i),n=await fetch("https://api.openai.com/v1/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)});return{stream:await se(n)}}var k={id:"text.prediction.gpt3.stream",schema:{input:M,output:ae},action:re};async function se(i){let e=new TextEncoder,t=new TextDecoder,n=0;return new ReadableStream({async start(s){function c(a){if(a.type==="event"){let d=a.data;if(d==="[DONE]"){s.close();return}try{let f=JSON.parse(d).choices[0].text;if(n<2&&(f.match(/\n/)||[]).length)return;let h=e.encode(f);s.enqueue(h),n++}catch(p){s.error(p)}}}let r=(0,_.createParser)(c);for await(let a of i.body)r.feed(t.decode(a))}})}var O=require("zod"),B=()=>({id:"output",schema:{input:O.z.object({}),output:O.z.object({})},async action(i){return i}});var S=require("zod"),F=S.z.object({image:S.z.string()}),pe=S.z.object({labels:S.z.array(S.z.string())});async function ue(i,e){let t=F.parse(i),n=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,o={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(n,{method:"POST",body:JSON.stringify(o)})).json()).responses[0].labelAnnotations.map(r=>r.description)}}var E={id:"image.labeling.googleVision",schema:{input:F,output:pe},action:ue};var u=require("zod"),Z=u.z.object({text_prompts:u.z.array(u.z.object({text:u.z.string(),weight:u.z.number().min(-1).max(1).optional().default(1)})).nonempty(),model:u.z.enum(["stable-diffusion-v1-5","stable-diffusion-512-v2-0","stable-diffusion-768-v2-0","stable-diffusion-512-v2-1","stable-diffusion-768-v2-1"]).optional().default("stable-diffusion-v1-5").describe("beep boop"),clip_guidance_preset:u.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]).optional(),steps:u.z.number().min(0).max(150).optional(),sampler:u.z.enum(["DDIM","DDPM","K_DPMPP_2M","K_DPMPP_2S_ANCESTRAL","K_DPM_2","K_DPM_2_ANCESTRAL","K_EULER","K_EULER_ANCESTRAL","K_HEUN","K_LMS"]).optional(),cfg_scale:u.z.number().min(0).max(35).optional(),seed:u.z.number().min(0).optional(),height:u.z.number().min(128).optional().refine(i=>typeof i<"u"?i%64===0:!0,"Must be a multiple of 64"),width:u.z.number().min(128).optional().refine(i=>typeof i<"u"?i%64===0:!0,"Must be a multiple of 64")}),ce=u.z.object({result:u.z.instanceof(ArrayBuffer)});async function de(i,e){let t=Z.parse(i),n=`https://api.stability.ai/v1beta/generation/${t.model}/text-to-image`;return{result:await(await fetch(n,{headers:{"Content-Type":"application/json",Accept:"image/png",Authorization:e.stability},method:"POST",body:JSON.stringify(t)})).arrayBuffer()}}var z={id:"image.textToImage.stableDiffusion.stability",schema:{input:Z,output:ce},action:de};var b=require("zod"),W=b.z.object({text:b.z.string(),amount:b.z.number().optional().default(8)}),me=b.z.object({text:b.z.string()}),le={"Colonial-style home":"Colonial, traditional, classic, historical, timeless, elegant, regal, grand, spacious, architectural, wood-framed, brick-exterior, symmetrical, gabled roof, columns, portico, fireplace, formal, ornate, landscaped".split(", "),"High-end penthouse apartment":"Luxury, high-end, penthouse, apartment, upscale, contemporary, modern, stylish, designer, elite, high-rise, rooftop, panoramic, views, spacious, open-plan, top-floor, amenities, concierge, service, exclusive".split(", ")};function fe(i){return Object.entries(le).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,i).join(", ")}
var O=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var D=(r,e)=>{for(var t in e)O(r,t,{get:e[t],enumerable:!0})},_=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!L.call(r,o)&&o!==t&&O(r,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return r};var M=r=>_(O({},"__esModule",{value:!0}),r);var me={};D(me,{Pipeline:()=>P,createClient:()=>B,enhanceWithKeywords:()=>X,googleImageLabeling:()=>J,googleTextToSpeech:()=>ue,gpt3Prediction:()=>ne,gpt3PredictionStream:()=>re,inputSchema:()=>I,output:()=>T,outputSchema:()=>te,replaceString:()=>ee,stabilityClipGuidancePreset:()=>R,stabilityModel:()=>N,stabilityTextToImage:()=>H,stringToArrayBuffer:()=>se,vercelGenericEdge:()=>W,whisperApi:()=>le});module.exports=M(me);async function T(r){return r}var S=class{constructor(e,t){this.input=e;this.nodes=t;this.output=this.node.bind(this,T)}static create(e){return new S(e,[])}node(e,t){let n=this.createDynamicPlaceholders("input"),o=this.nodes.length>0?this.nodes[this.nodes.length-1]:n,s={action:e,input:t({nodes:this.nodes,prev:o.output,input:n}),output:this.createDynamicPlaceholders(this.nodes.length)};return this.nodes.push(s),this}createDynamicPlaceholders(e){let t={},n={get:function(s,p){return`$context.${e}.${p}$`}};return new Proxy(t,n)}setPlaceholderValues(e,t){let n={};for(let o of e)n[o]=`$context.${t}.${o}$`;return n}getNodes(){return this.nodes}};function E(r){return new Promise(e=>setTimeout(e,r))}function z(r,e){if(typeof r=="string")return o(r);let t={...r};return n(t);function n(a){for(let i in a)a[i]=o(a[i]);return a}function o(a){if(Array.isArray(a))return a.map(u=>n(u));if(typeof a=="object"&&a!==null)return n(a);let i=a,d=s(a);for(let u of d){let h=e[u.nodeId][u.property];if(h instanceof ArrayBuffer){i=h;continue}i=i?.replace(new RegExp(p(u.value)),h),i==="undefined"?i=void 0:i!==h&&i===h.toString()&&(i=h)}return i}function s(a){if(typeof a!="string")return[];let i=/\$context\.(\d+|input)\.(\w+)\$/g,d=a.matchAll(i),u=[];for(let f of d)u.push({value:f[0],nodeId:f[1],property:f[2]});return u}function p(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function A(r=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length;for(let o=0;o<r;o++)e+=t.charAt(Math.floor(Math.random()*n));return e}var K=2,k=350,P=class{constructor(e,t,n){this.conf=e;this.flow=t;this.apiKeys=n;this.onProgressListeners=new Map;this.onStartListeners=new Map;this.onFinishListeners=new Map;this.vercel={invoke:e=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e),invokeStream:(e,t)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t)};this.listenToEvents()}invoke(e){return this.processPipeline(this.conf,e)}invokeRemote(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(n=>n.json())}async invokeStream(e,t,n){let o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok)throw new Error(o.statusText);let s=o.body;if(!s)return;let p=s.getReader(),a=new TextDecoder,i=!1;for(;!i;){let{value:d,done:u}=await p.read();i=u;let f=a.decode(d);n(f)}}onProgress(e){let t=A();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=A();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=A();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}listenToEvents(){if(!this.conf.updateProgress||typeof window>"u"||!this.apiKeys?.ablySubscribe)return;let e=`https://realtime.ably.io/event-stream?channels=aigur-client&v=1.2&key=${this.apiKeys.ablySubscribe}&enveloped=false`,t=new EventSource(e);t.onmessage=n=>{let o=JSON.parse(n.data);o.pipelineId===this.conf.id&&(o.type==="pipeline:start"?this.triggerListeners(this.onStartListeners):o.type==="pipeline:finish"?this.triggerListeners(this.onFinishListeners):(o.type==="node:start"||o.type==="node:finish")&&this.triggerListeners(this.onProgressListeners,{...o.data,type:o.type}))}}triggerListeners(e,...t){for(let n of e.values())n(...t)}async processPipeline(e,t){let n=this.conf.retries??K;try{await this.notifyEvent("pipeline:start"),e.input.parse(t);let o={input:t},s={},p=this.flow.getNodes(),a;for(let i=0;i<p.length;i++){a=this.notifyEvent("node:start",{node:p[i],index:i});let d=0,u=!1;do{d++;try{s=await this.executeAction(p,i,o),o[i]=s,u=!0}catch(f){if(d>n)throw f;await E((this.conf.retryDelayInMs??k)*d)}}while(!u&&d<=n);await a,await this.notifyEvent("node:finish",{node:p[i],index:i})}return await this.notifyEvent("pipeline:finish"),s}catch(o){throw console.error(o),o}}async executeAction(e,t,n){let{action:o,schema:s,input:p}=e[t],a=z(p,n);return o(a,this.apiKeys)}notifyEvent(e,t){if(!(!this.conf.updateProgress||!this.apiKeys.ablyPublish))return fetch("https://rest.ably.io/channels/aigur-client/messages?enveloped=false ",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${btoa(this.apiKeys.ablyPublish)}`},body:JSON.stringify({type:e,data:t,pipelineId:this.conf.id})})}};var $=2,Z=350,B=r=>{let{apiKeys:e}=r;return{pipeline:{create:t=>{let n={...t,retries:t.retries??$,retryDelayInMs:t.retryDelayInMs??Z},o=t.flow(new S(t.input,[]));return new P(n,o,e)}}}};async function W(r,e){let t=await e.json(),{searchParams:n}=new URL(e.url);if(!n.has("id"))return new Response("Missing id",{status:400});let o=n.get("id"),s=r[o];return{output:await s.invoke(t),pipeline:s}}var b=require("zod"),F=b.z.object({image:b.z.string()}),ze=b.z.object({labels:b.z.array(b.z.string())});async function J(r,e){let t=F.parse(r),n=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,o={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(n,{method:"POST",body:JSON.stringify(o)})).json()).responses[0].labelAnnotations.map(a=>a.description)}}var c=require("zod"),N=c.z.enum(["stable-diffusion-v1-5","stable-diffusion-512-v2-0","stable-diffusion-768-v2-0","stable-diffusion-512-v2-1","stable-diffusion-768-v2-1"]),R=c.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),G=c.z.object({text_prompts:c.z.array(c.z.object({text:c.z.string(),weight:c.z.number().min(-1).max(1).default(1)})).refine(r=>r.length>0,"Must have at least one text prompt"),model:N.default("stable-diffusion-v1-5"),clip_guidance_preset:R.optional(),steps:c.z.number().min(0).max(150).optional(),sampler:c.z.enum(["DDIM","DDPM","K_DPMPP_2M","K_DPMPP_2S_ANCESTRAL","K_DPM_2","K_DPM_2_ANCESTRAL","K_EULER","K_EULER_ANCESTRAL","K_HEUN","K_LMS"]).optional(),cfg_scale:c.z.number().min(0).max(35).optional(),seed:c.z.number().min(0).optional(),height:c.z.number().min(128).optional().refine(r=>typeof r<"u"?r%64===0:!0,"Must be a multiple of 64"),width:c.z.number().min(128).optional().refine(r=>typeof r<"u"?r%64===0:!0,"Must be a multiple of 64")}),Re=c.z.object({result:c.z.instanceof(ArrayBuffer)});async function H(r,e){let t=G.parse(r),n=`https://api.stability.ai/v1beta/generation/${t.model}/text-to-image`;return{result:await(await fetch(n,{headers:{"Content-Type":"application/json",Accept:"image/png",Authorization:e.stability},method:"POST",body:JSON.stringify(t)})).arrayBuffer()}}var x=require("zod"),V=x.z.object({text:x.z.string(),amount:x.z.number().optional().default(8)}),Ue=x.z.object({text:x.z.string()}),Y={"Colonial-style home":"Colonial, traditional, classic, historical, timeless, elegant, regal, grand, spacious, architectural, wood-framed, brick-exterior, symmetrical, gabled roof, columns, portico, fireplace, formal, ornate, landscaped".split(", "),"High-end penthouse apartment":"Luxury, high-end, penthouse, apartment, upscale, contemporary, modern, stylish, designer, elite, high-rise, rooftop, panoramic, views, spacious, open-plan, top-floor, amenities, concierge, service, exclusive".split(", ")};function q(r){return Object.entries(Y).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,r).join(", ")}
`).join(`
`)}async function ye(i){let e=W.parse(i);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${fe(e.amount)}
`)}async function X(r){let e=V.parse(r);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${q(e.amount)}
Title: ${e.text}
Description:`}}var j={id:"text.modify.enhanceWithKeywords",schema:{input:W,output:me},action:ye};var g=require("zod"),$=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),he=g.z.object({text:g.z.string()});async function ge(i){let e=$.parse(i);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var R={id:"text.modify.simple",schema:{input:$,output:he},action:ge};var y=require("zod"),Se="https://transcribe.whisperapi.com",J=y.z.object({audioUrl:y.z.string().url(),language:y.z.string().default("en"),autoDetectLanguage:y.z.boolean().default(!1),fileType:y.z.string().default("mp3"),task:y.z.enum(["transcribe","translate"]).default("transcribe")}),be=y.z.object({text:y.z.string()});async function xe(i,e){let t=J.parse(i),n=new FormData;n.append("url",t.audioUrl),t.autoDetectLanguage||n.append("language",t.language),n.append("fileType",t.fileType),n.append("task",t.task);let o=await fetch(Se,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:n});if(!o.ok)throw new Error(o.statusText);return{text:(await o.json()).text.trim()}}var U={id:"voice.transcribe.whisper.whisperapi",schema:{input:J,output:be},action:xe};var P=require("zod"),V=P.z.object({string:P.z.string()}),Ne=P.z.object({arrayBuffer:P.z.instanceof(ArrayBuffer)});async function ve(i){let e=V.parse(i);return{arrayBuffer:Uint8Array.from(atob(e.string),n=>n.charCodeAt(0)).buffer}}var C={id:"text.transformation.stringToArrayBuffer",schema:{input:V,output:Ne},action:ve};var l=require("zod"),G=l.z.object({text:l.z.string(),speakingRate:l.z.number().min(.25).max(4).optional().default(1),pitch:l.z.number().min(-20).max(20).optional().default(0),encoding:l.z.enum(["MP3","FLAC","LINEAR16","MULAW","AMR","AMR_WB","OGG_OPUS","SPEEX_WITH_HEADER_BYTE","WEBM_OPUS"]).optional().default("MP3"),voice:l.z.object({language:l.z.string().optional().default("en-US"),name:l.z.enum(["en-US-Standard-A","en-US-Standard-C","en-US-Standard-D","en-US-Standard-E","en-US-Standard-F","en-US-Standard-G","en-US-Standard-H","en-US-Standard-I","en-US-Standard-J","en-US-Studio-M","en-US-Studio-O","en-US-Wavenet-A","en-US-Wavenet-B","en-US-Wavenet-C","en-US-Wavenet-D","en-US-Wavenet-E","en-US-Wavenet-F","en-US-Wavenet-G","en-US-Wavenet-H","en-US-Wavenet-I","en-US-Wavenet-J","en-US-News-K","en-US-News-L","en-US-News-M","en-US-News-N","en-US-Standard-A","en-US-Standard-B","en-US-Standard-C","en-US-Standard-D","en-US-Standard-E","en-US-Standard-F","en-US-Standard-G","en-US-Standard-H","en-US-Standard-I","en-US-Standard-J"]).or(l.z.string()).optional().default("en-US-Neural2-C")}).optional().default({language:"en-US",name:"en-US-Neural2-C"})}),Pe=l.z.object({audio:l.z.string()});async function Ae(i,e){let t=G.parse(i),n=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,o={input:{text:t.text},voice:{languageCode:t.voice.language,name:t.voice.name},audioConfig:{audioEncoding:t.encoding,speakingRate:t.speakingRate,pitch:t.pitch}};return{audio:(await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json()).audioContent}}var L={id:"voice.textToSpeech.google",schema:{input:G,output:Pe},action:Ae};var x=class{constructor(e,t){this.input=e;this.nodes=t;this.voice={textToSpeech:{google:this.nodeFactory(L)},transcribe:{whisper:{whisperapi:this.nodeFactory(U)}}};this.text={modify:{enhanceWithKeywords:this.nodeFactory(j),simple:this.nodeFactory(R)},prediction:{gpt3:this.nodeFactory(I),gpt3Stream:this.nodeFactory(k)}};this.image={textToImage:{stableDiffusion:{stability:this.nodeFactory(z)}},labeling:{google:this.nodeFactory(E)}};this.output=this.nodeFactory(B());this.transformation={stringToArrayBuffer:this.nodeFactory(C)}}static create(e){return new x(e,[])}nodeFactory(e){return t=>{let n=this.setPlaceholderValues(this.input.keyof().options,"input"),o=this.nodes.length>0?this.nodes[this.nodes.length-1]:n,s={...e,input:t({nodes:this.nodes,prev:o.output,input:n}),output:e.schema.output.keyof?this.setPlaceholderValues(e.schema.output.keyof().options,this.nodes.length):e.schema.output};return this.nodes.push(s),this}}setPlaceholderValues(e,t){let n={};for(let o of e)n[o]=`$context.${t}.${o}$`;return n}custom(e){return this.nodeFactory(e)}getNodes(){return this.nodes}};var we=2,Te=350,Ie=i=>{let{apiKeys:e}=i;return{pipeline:{create:t=>{let n={...t,retries:t.retries??we,retryDelayInMs:t.retryDelayInMs??Te},o=t.flow(new x(t.input,[]));return new N(n,o,e)}}}};async function Oe(i,e){let t=await e.json(),{searchParams:n}=new URL(e.url);if(!n.has("id"))return new Response("Missing id",{status:400});let o=n.get("id"),s=i[o];return{output:await s.invoke(t),pipeline:s}}0&&(module.exports={Pipeline,createClient,vercelGenericEdge});
Description:`}}var g=require("zod"),Q=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),Le=g.z.object({text:g.z.string()});async function ee(r){let e=Q.parse(r);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),I=l.z.object({prompt:l.z.string(),model:l.z.enum(["text-davinci-003","text-curie-001","text-babbage-001","text-ada-001","code-davinci-002","code-cushman-002"]).default("text-davinci-003"),temperature:l.z.number().min(0).max(2).default(.7),top_p:l.z.number().min(0).max(1).default(1),frequency_penalty:l.z.number().min(-2).max(2).default(0),presence_penalty:l.z.number().min(-2).max(2).default(0),max_tokens:l.z.number().default(200),n:l.z.number().default(1)}),te=l.z.object({text:l.z.string()});async function ne(r,e){let t=I.parse(r);return{text:(await(await fetch("https://api.openai.com/v1/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)})).json()).choices[0]?.text.replace(/^(?:\n)+/gm,"")}}var j=require("eventsource-parser"),v=require("zod");var oe=I.merge(v.z.object({stream:v.z.literal(!0).optional().default(!0)})),$e=v.z.object({stream:v.z.instanceof(globalThis.ReadableStream??Object)});async function re(r,e){let t=oe.parse(r),n=await fetch("https://api.openai.com/v1/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)});return{stream:await ie(n)}}async function ie(r){let e=new TextEncoder,t=new TextDecoder,n=0;return new ReadableStream({async start(s){function p(i){if(i.type==="event"){let d=i.data;if(d==="[DONE]"){s.close();return}try{let f=JSON.parse(d).choices[0].text;if(n<2&&(f.match(/\n/)||[]).length)return;let h=e.encode(f);s.enqueue(h),n++}catch(u){s.error(u)}}}let a=(0,j.createParser)(p);for await(let i of r.body)a.feed(t.decode(i))}})}var w=require("zod"),ae=w.z.object({string:w.z.string()}),Be=w.z.object({arrayBuffer:w.z.instanceof(ArrayBuffer)});async function se(r){let e=ae.parse(r);return{arrayBuffer:Uint8Array.from(atob(e.string),n=>n.charCodeAt(0)).buffer}}var m=require("zod"),pe=m.z.object({text:m.z.string(),speakingRate:m.z.number().min(.25).max(4).optional().default(1),pitch:m.z.number().min(-20).max(20).optional().default(0),encoding:m.z.enum(["MP3","FLAC","LINEAR16","MULAW","AMR","AMR_WB","OGG_OPUS","SPEEX_WITH_HEADER_BYTE","WEBM_OPUS"]).optional().default("MP3"),voice:m.z.object({language:m.z.string().optional().default("en-US"),name:m.z.enum(["en-US-Standard-A","en-US-Standard-C","en-US-Standard-D","en-US-Standard-E","en-US-Standard-F","en-US-Standard-G","en-US-Standard-H","en-US-Standard-I","en-US-Standard-J","en-US-Studio-M","en-US-Studio-O","en-US-Wavenet-A","en-US-Wavenet-B","en-US-Wavenet-C","en-US-Wavenet-D","en-US-Wavenet-E","en-US-Wavenet-F","en-US-Wavenet-G","en-US-Wavenet-H","en-US-Wavenet-I","en-US-Wavenet-J","en-US-News-K","en-US-News-L","en-US-News-M","en-US-News-N","en-US-Standard-A","en-US-Standard-B","en-US-Standard-C","en-US-Standard-D","en-US-Standard-E","en-US-Standard-F","en-US-Standard-G","en-US-Standard-H","en-US-Standard-I","en-US-Standard-J"]).or(m.z.string()).optional().default("en-US-Neural2-C")}).optional().default({language:"en-US",name:"en-US-Neural2-C"})}),Fe=m.z.object({audio:m.z.string()});async function ue(r,e){let t=pe.parse(r),n=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,o={input:{text:t.text},voice:{languageCode:t.voice.language,name:t.voice.name},audioConfig:{audioEncoding:t.encoding,speakingRate:t.speakingRate,pitch:t.pitch}};return{audio:(await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json()).audioContent}}var y=require("zod"),ce="https://transcribe.whisperapi.com",de=y.z.object({audioUrl:y.z.string().url(),language:y.z.string().default("en"),autoDetectLanguage:y.z.boolean().default(!1),fileType:y.z.string().default("mp3"),task:y.z.enum(["transcribe","translate"]).default("transcribe")}),Ge=y.z.object({text:y.z.string()});async function le(r,e){let t=de.parse(r),n=new FormData;n.append("url",t.audioUrl),t.autoDetectLanguage||n.append("language",t.language),n.append("fileType",t.fileType),n.append("task",t.task);let o=await fetch(ce,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:n});if(!o.ok)throw new Error(o.statusText);return{text:(await o.json()).text.trim()}}0&&(module.exports={Pipeline,createClient,enhanceWithKeywords,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,inputSchema,output,outputSchema,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelGenericEdge,whisperApi});
{
"name": "@aigur/client",
"version": "0.31.0",
"version": "0.32.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

import { z } from 'zod';
import { FlowBuilder } from './builder';
import { Pipeline } from './Pipeline';
import { APIKeys, PipelineConf, ZodReadableStream } from './types';
import { Pipeline } from './Pipeline';
import { Builder } from './builder';

@@ -28,3 +28,3 @@ interface AigurConfiguration {

};
const flow = conf.flow(new Builder<Input, Output, [], null>(conf.input, []));
const flow = conf.flow(new FlowBuilder<Input, Output, [], null>(conf.input, []));
return new Pipeline(pipelineConf, flow, apiKeys);

@@ -31,0 +31,0 @@ },

import { z } from 'zod';
import { ConcreteNode, NodeDefinition, ZodReadableStream } from './types';
import { gpt3PredictionStreamNode } from './nodes/text/prediction/gpt3.stream';
import { outputNode } from './nodes/output/output';
import {
enhanceWithKeywordsNode, googleTextToSpeechNode, googleVisionNode, gpt3PredictionNode,
simpleModificationNode, stabilityTextToImageNode, stringToArrayBufferNode, whisperApiNode
} from './nodes/nodesDefinitions';
import { ConcreteNode, NodeAction, ZodReadableStream } from './types';
import { output } from './nodes/output/output';
export class Builder<
export class FlowBuilder<
Input extends z.ZodObject<any, any, any>,

@@ -23,33 +18,54 @@ Output extends z.ZodObject<any, any, any> | ZodReadableStream,

>(input: Input) {
return new Builder<Input, Output, [], null>(input, []);
return new FlowBuilder<Input, Output, [], null>(input, []);
}
private nodeFactory<NodeDef extends NodeDefinition<any, any>>(nodeDefinition: NodeDef) {
return <NextNode extends ConcreteNode<NodeDef['schema']['input'], NodeDef['schema']['output']>>(
getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? PrevNode['output'] : Input;
input: z.output<Input>;
}) => z.input<NextNode['schema']['input']>
): Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode> => {
const input = this.setPlaceholderValues(this.input.keyof().options, 'input');
const prev = this.nodes.length > 0 ? this.nodes[this.nodes.length - 1] : input;
const node = {
...nodeDefinition,
input: getUserInput({
nodes: this.nodes,
prev: prev.output,
input,
}),
output: nodeDefinition.schema.output.keyof
? this.setPlaceholderValues<NextNode>(
nodeDefinition.schema.output.keyof().options,
this.nodes.length
)
: nodeDefinition.schema.output,
} as ConcreteNode<NodeDef['schema']['input'], NodeDef['schema']['output']>;
public node<NodeDef extends NodeAction<any, any>>(
nodeDefinition: NodeDef,
getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any>
? Awaited<ReturnType<PrevNode['action']>>
: Input;
input: z.output<Input>;
}) => Parameters<NodeDef>['0']
) {
// param 0 is the action input
// return <NewNode extends ConcreteNode<Parameters<NodeDef>['0'], Awaited<ReturnType<NodeDef>>>>(
// getUserInput: (data: {
// nodes: NodeDefinitions;
// prev: PrevNode extends ConcreteNode<any, any>
// ? Awaited<ReturnType<PrevNode['action']>>
// : Input;
// input: z.output<Input>;
// }) => Parameters<NodeDef>['0']
// ): FlowBuilder<Input, Output, [...NodeDefinitions, NewNode], NewNode> => {
this.nodes.push(node);
return this as unknown as Builder<Input, Output, [...NodeDefinitions, NextNode], NextNode>;
type NewNode = ConcreteNode<Parameters<NodeDef>['0'], Awaited<ReturnType<NodeDef>>>;
const input = this.createDynamicPlaceholders('input');
const prev = this.nodes.length > 0 ? this.nodes[this.nodes.length - 1] : input;
const node = {
action: nodeDefinition,
input: getUserInput({
nodes: this.nodes,
prev: prev.output,
input,
}),
output: this.createDynamicPlaceholders(this.nodes.length),
} as NewNode;
this.nodes.push(node);
return this as unknown as FlowBuilder<Input, Output, [...NodeDefinitions, NewNode], NewNode>;
}
private createDynamicPlaceholders(nodeIndex: number | 'input') {
const output = {};
const safeNotInstanciatedWarningProxy = {
get: function (object, prop) {
return `$context.${nodeIndex}.${prop}$`;
},
};
const dynamicOutput = new Proxy(output, safeNotInstanciatedWarningProxy);
return dynamicOutput;
}

@@ -68,47 +84,11 @@

custom<I extends z.AnyZodObject, O extends z.AnyZodObject | ZodReadableStream>(
node: NodeDefinition<I, O>
) {
return this.nodeFactory(node);
}
// node2<
// I extends Record<string, any> | ReadableStream,
// O extends Record<string, any> | ReadableStream
// >(node: NodeAction<I, O>) {
// return this.nodeFactory(node);
// }
voice = {
textToSpeech: {
google: this.nodeFactory(googleTextToSpeechNode),
},
transcribe: {
whisper: {
whisperapi: this.nodeFactory(whisperApiNode),
},
},
};
output = this.node.bind(this, output<Output>);
text = {
modify: {
enhanceWithKeywords: this.nodeFactory(enhanceWithKeywordsNode),
simple: this.nodeFactory(simpleModificationNode),
},
prediction: {
gpt3: this.nodeFactory(gpt3PredictionNode),
gpt3Stream: this.nodeFactory(gpt3PredictionStreamNode),
},
};
image = {
textToImage: {
stableDiffusion: {
stability: this.nodeFactory(stabilityTextToImageNode),
},
},
labeling: {
google: this.nodeFactory(googleVisionNode),
},
};
output = this.nodeFactory(outputNode<Output>());
transformation = {
stringToArrayBuffer: this.nodeFactory(stringToArrayBufferNode),
};
getNodes() {

@@ -115,0 +95,0 @@ return this.nodes;

export * from './Aigur';
export * from './Pipeline';
export * from './vercelGenericEdge';
export * from './nodes/nodesDefinitions';

@@ -5,2 +5,20 @@ import { z } from 'zod';

export const stabilityModel = z.enum([
'stable-diffusion-v1-5',
'stable-diffusion-512-v2-0',
'stable-diffusion-768-v2-0',
'stable-diffusion-512-v2-1',
'stable-diffusion-768-v2-1',
]);
export const stabilityClipGuidancePreset = z.enum([
'NONE',
'FAST_BLUE',
'FAST_GREEN',
'SIMPLE',
'SLOW',
'SLOWER',
'SLOWEST',
]);
const inputSchema = z.object({

@@ -11,21 +29,9 @@ text_prompts: z

text: z.string(),
weight: z.number().min(-1).max(1).optional().default(1),
weight: z.number().min(-1).max(1).default(1),
})
)
.nonempty(),
.refine((val) => val.length > 0, 'Must have at least one text prompt'),
model: z
.enum([
'stable-diffusion-v1-5',
'stable-diffusion-512-v2-0',
'stable-diffusion-768-v2-0',
'stable-diffusion-512-v2-1',
'stable-diffusion-768-v2-1',
])
.optional()
.default('stable-diffusion-v1-5')
.describe('beep boop'),
clip_guidance_preset: z
.enum(['NONE', 'FAST_BLUE', 'FAST_GREEN', 'SIMPLE', 'SLOW', 'SLOWER', 'SLOWEST'])
.optional(),
model: stabilityModel.default('stable-diffusion-v1-5'),
clip_guidance_preset: stabilityClipGuidancePreset.optional(),
steps: z.number().min(0).max(150).optional(),

@@ -71,3 +77,3 @@ sampler: z

async function action(
export async function stabilityTextToImage(
input: z.input<typeof inputSchema>,

@@ -94,10 +100,1 @@ apiKeys: APIKeys

}
export const stabilityTextToImageNode = {
id: 'image.textToImage.stableDiffusion.stability',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};

@@ -1,8 +0,10 @@

export { googleVisionNode } from './image/labeling/googleVision';
export { stabilityTextToImageNode } from './image/textToImage/stability';
export { enhanceWithKeywordsNode } from './text/modify/enhanceWithKeywords';
export { simpleModificationNode } from './text/modify/simple';
export { gpt3PredictionNode } from './text/prediction/gpt3';
export { whisperApiNode } from './voice/transcribe/whisper/whisperapi';
export { stringToArrayBufferNode } from './transformation/stringToArrayBuffer';
export { googleTextToSpeechNode } from './voice/textToSpeech/googleTextToSpeech';
export * from './image/labeling/googleImageLabeling';
export * from './image/textToImage/stability';
export * from './output/output';
export * from './text/modify/enhanceWithKeywords';
export * from './text/modify/replaceString';
export * from './text/prediction/gpt3';
export * from './text/prediction/gpt3.stream';
export * from './transformation/stringToArrayBuffer';
export * from './voice/textToSpeech/googleTextToSpeech';
export * from './voice/transcribe/whisper/whisperapi';

@@ -0,12 +1,8 @@

import { ZodReadableStream } from '#/types';
import { z } from 'zod';
export const outputNode = <InputOutput>() => ({
id: 'output',
schema: {
input: z.object({}) as InputOutput,
output: z.object({}) as InputOutput,
},
async action(input: InputOutput): Promise<InputOutput> {
return input;
},
});
export async function output<PipelineOutput extends z.AnyZodObject | ZodReadableStream>(
input: z.input<PipelineOutput>
): Promise<z.output<PipelineOutput>> {
return input;
}

@@ -31,3 +31,5 @@ import { z } from 'zod';

async function action(input: z.input<typeof inputSchema>): Promise<z.infer<typeof outputSchema>> {
export async function enhanceWithKeywords(
input: z.input<typeof inputSchema>
): Promise<z.infer<typeof outputSchema>> {
const payload = inputSchema.parse(input);

@@ -43,10 +45,1 @@ const enhancedText = `Write a maximum of ${

}
export const enhanceWithKeywordsNode = {
id: 'text.modify.enhanceWithKeywords',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};

@@ -0,3 +1,3 @@

import { createParser, ParsedEvent, ReconnectInterval } from 'eventsource-parser';
import { z } from 'zod';
import { createParser, ParsedEvent, ReconnectInterval } from 'eventsource-parser';

@@ -16,3 +16,3 @@ import { inputSchema as gpt3BaseInputSchema } from './gpt3';

async function action(
export async function gpt3PredictionStream(
input: z.input<typeof inputSchema>,

@@ -35,12 +35,3 @@ apiKeys: APIKeys

export const gpt3PredictionStreamNode = {
id: 'text.prediction.gpt3.stream',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};
export async function OpenAIStream(response: Response) {
async function OpenAIStream(response: Response) {
const encoder = new TextEncoder();

@@ -47,0 +38,0 @@ const decoder = new TextDecoder();

@@ -29,3 +29,3 @@ import { z } from 'zod';

export async function action(
export async function gpt3Prediction(
input: z.input<typeof inputSchema>,

@@ -47,10 +47,1 @@ apiKeys: APIKeys

}
export const gpt3PredictionNode = {
id: 'text.prediction.gpt3',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};

@@ -11,3 +11,5 @@ import { z } from 'zod';

async function action(input: z.input<typeof inputSchema>): Promise<z.infer<typeof outputSchema>> {
export async function stringToArrayBuffer(
input: z.input<typeof inputSchema>
): Promise<z.infer<typeof outputSchema>> {
const payload = inputSchema.parse(input);

@@ -20,10 +22,1 @@ const typedArray = Uint8Array.from(atob(payload.string), (c) => c.charCodeAt(0));

}
export const stringToArrayBufferNode = {
id: 'text.transformation.stringToArrayBuffer',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};

@@ -79,3 +79,3 @@ import { z } from 'zod';

async function action(
export async function googleTextToSpeech(
input: z.input<typeof inputSchema>,

@@ -113,10 +113,1 @@ apiKeys: APIKeys

}
export const googleTextToSpeechNode = {
id: 'voice.textToSpeech.google',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};

@@ -19,3 +19,8 @@ import { z } from 'zod';

async function action(
// const x: z.input<typeof inputSchema> = {
// audioUrl: '',
// task: y,
// };
export async function whisperApi(
input: z.input<typeof inputSchema>,

@@ -49,10 +54,1 @@ apiKeys: APIKeys

}
export const whisperApiNode = {
id: 'voice.transcribe.whisper.whisperapi',
schema: {
input: inputSchema,
output: outputSchema,
},
action,
};
import { z } from 'zod';
import { FlowBuilder } from './builder';
import { delay } from './delay';
import { getInputByContext } from './getInputByContext';
import { makeid } from './makeid';
import {
APIKeys, ConcreteNode, EventType, PipelineConf, ProgressEventType, ZodReadableStream
APIKeys,
ConcreteNode,
EventType,
PipelineConf,
ProgressEventType,
ZodReadableStream,
} from './types';
import { makeid } from './makeid';
import { getInputByContext } from './getInputByContext';
import { delay } from './delay';
import { Builder } from './builder';

@@ -27,3 +32,3 @@ const DEFAULT_RETRIES = 2;

public readonly conf: PipelineConf<Input, Output>,
public readonly flow: Builder<z.AnyZodObject, z.AnyZodObject | ZodReadableStream, any, any>,
public readonly flow: FlowBuilder<z.AnyZodObject, z.AnyZodObject | ZodReadableStream, any, any>,
private readonly apiKeys: APIKeys

@@ -135,3 +140,8 @@ ) {

eventSource.onmessage = (event) => {
const e: { type: EventType; data: Record<any, any> } = JSON.parse(event.data);
const e: { pipelineId: string; type: EventType; data: Record<any, any> } = JSON.parse(
event.data
);
if (e.pipelineId !== this.conf.id) {
return;
}
if (e.type === 'pipeline:start') {

@@ -217,2 +227,3 @@ this.triggerListeners(this.onStartListeners);

data,
pipelineId: this.conf.id,
}),

@@ -219,0 +230,0 @@ });

import { z } from 'zod';
import { Builder } from './builder';
import { FlowBuilder } from './builder';

@@ -13,4 +13,4 @@ export interface PipelineConf<

flow: (
builder: Builder<Input, Output, [], null>
) => Builder<Input, Output, any, ConcreteNode<Output, Output>>;
builder: FlowBuilder<Input, Output, [], null>
) => FlowBuilder<Input, Output, any, ConcreteNode<z.input<Output>, z.output<Output>>>;
retries?: number;

@@ -22,20 +22,26 @@ stream?: boolean;

export type NodeDefinition<
Input extends z.AnyZodObject | ZodReadableStream,
Output extends z.AnyZodObject | ZodReadableStream
> = {
id: string;
schema: {
input: Input;
output: Output;
};
action: (input: z.output<Input>, apiKeys: Record<string, string>) => Promise<z.output<Output>>;
};
// export type NodeDefinition<
// Input extends z.AnyZodObject | ZodReadableStream,
// Output extends z.AnyZodObject | ZodReadableStream
// > = {
// id: string;
// schema: {
// input: Input;
// output: Output;
// };
// action: (input: z.output<Input>, apiKeys: Record<string, string>) => Promise<z.output<Output>>;
// };
export type NodeAction<
Input extends Record<string, unknown> | ReadableStream,
Output extends Record<string, unknown> | ReadableStream
> = (input: Input, apiKeys: Record<string, string>) => Promise<Output>;
export type ConcreteNode<
Input extends z.AnyZodObject | ZodReadableStream,
Output extends z.AnyZodObject | ZodReadableStream
> = NodeDefinition<Input, Output> & {
input: z.output<Input>;
output: z.output<Output>;
Input extends Record<string, unknown> | ReadableStream,
Output extends Record<string, unknown> | ReadableStream
> = {
action: NodeAction<Input, Output>;
input: Input;
output: Output;
};

@@ -42,0 +48,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc