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.32.2 to 0.32.3

38

dist/index.d.ts
import { z } from 'zod';
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;
output(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? Awaited<ReturnType<PrevNode['action']>> : Input;
input: z.output<Input>;
}) => z.output<Output>): FlowBuilder<Input, Output, [...NodeDefinitions, ConcreteNode<z.input<Output>, Awaited<z.output<Output>>>], ConcreteNode<z.input<Output>, Awaited<z.output<Output>>>>;
getNodes(): NodeDefinitions;
}
interface PipelineConf<Input extends z.AnyZodObject, Output extends z.AnyZodObject | ZodReadableStream> {

@@ -47,2 +28,21 @@ id: string;

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;
output(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? Awaited<ReturnType<PrevNode['action']>> : Input;
input: z.output<Input>;
}) => z.output<Output>): FlowBuilder<Input, Output, [...NodeDefinitions, ConcreteNode<z.input<Output>, Awaited<z.output<Output>>>], ConcreteNode<z.input<Output>, Awaited<z.output<Output>>>>;
getNodes(): NodeDefinitions;
}
declare class Pipeline<Input extends z.AnyZodObject, Output extends z.AnyZodObject | ZodReadableStream> {

@@ -49,0 +49,0 @@ readonly conf: PipelineConf<Input, Output>;

@@ -1,2 +0,2 @@

var T=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})},M=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!D.call(n,r)&&r!==t&&T(n,r,{get:()=>e[r],enumerable:!(o=_(e,r))||o.enumerable});return n};var k=n=>M(T({},"__esModule",{value:!0}),n);var be={};K(be,{Pipeline:()=>A,createClient:()=>F,dalleBase64TextToImage:()=>X,dalleUrlTextToImage:()=>Y,enhanceWithKeywords:()=>re,googleImageLabeling:()=>H,googleTextToSpeech:()=>ye,gpt3Prediction:()=>pe,gpt3PredictionStream:()=>ce,inputSchema:()=>O,output:()=>N,outputSchema:()=>se,replaceString:()=>ae,stabilityClipGuidancePreset:()=>C,stabilityModel:()=>R,stabilityTextToImage:()=>ee,stringToArrayBuffer:()=>me,vercelGenericEdge:()=>J,whisperApi:()=>Se});module.exports=k(be);async function N(n){return n}var b=class{constructor(e,t){this.input=e;this.nodes=t}static create(e){return new b(e,[])}node(e,t){let o=this.createDynamicPlaceholders("input"),r=this.nodes.length>0?this.nodes[this.nodes.length-1]:o,i={action:e,input:t({nodes:this.nodes,prev:r.output,input:o}),output:this.createDynamicPlaceholders(this.nodes.length)};return this.nodes.push(i),this}createDynamicPlaceholders(e){let t={},o={get:function(i,c){return`$context.${e}.${c}$`}};return new Proxy(t,o)}output(e){return this.node(N,e)}getNodes(){return this.nodes}};function z(n=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=t.length;for(let r=0;r<n;r++)e+=t.charAt(Math.floor(Math.random()*o));return e}function j(n,e){if(typeof n=="string")return r(n);let t={...n};return o(t);function o(a){let s={};for(let p in a)s[p]=r(a[p]);return s}function r(a){if(Array.isArray(a))return a.map(u=>o(u));if(typeof a=="object"&&a!==null)return o(a);let s=a,p=i(a);for(let u of p){let y=e[u.nodeId][u.property];if(y instanceof ArrayBuffer){s=y;continue}s=s?.replace(new RegExp(c(u.value)),y),s==="undefined"?s=void 0:s!==y&&s===y.toString()&&(s=y)}return s}function i(a){if(typeof a!="string")return[];let s=/\$context\.(\d+|input)\.(\w+)\$/g,p=a.matchAll(s),u=[];for(let l of p)u.push({value:l[0],nodeId:l[1],property:l[2]});return u}function c(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function E(n){return new Promise(e=>setTimeout(e,n))}var B=2,$=350,A=class{constructor(e,t,o){this.conf=e;this.flow=t;this.apiKeys=o;this.onProgressListeners=new Map;this.onStartListeners=new Map;this.onFinishListeners=new Map;this.vercel={invoke:e=>this.invokeRemote(`/api/pipelines/${this.conf.id}?_vercel_no_cache=1`,e),invokeStream:(e,t)=>this.invokeStream(`/api/pipelines/${this.conf.id}?_vercel_no_cache=1`,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(o=>o.json())}async invokeStream(e,t,o){let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(r.statusText);let i=r.body;if(!i)return;let c=i.getReader(),a=new TextDecoder,s=!1;for(;!s;){let{value:p,done:u}=await c.read();s=u;let l=a.decode(p);o(l)}}onProgress(e){let t=z();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=z();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=z();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=o=>{let r=JSON.parse(o.data);r.pipelineId===this.conf.id&&(r.type==="pipeline:start"?this.triggerListeners(this.onStartListeners):r.type==="pipeline:finish"?this.triggerListeners(this.onFinishListeners):(r.type==="node:start"||r.type==="node:finish")&&this.triggerListeners(this.onProgressListeners,{...r.data,type:r.type}))}}triggerListeners(e,...t){for(let o of e.values())o(...t)}async processPipeline(e,t){let o=this.conf.retries??B;try{await this.notifyEvent("pipeline:start");let i={input:e.input.parse(t)},c={},a=this.flow.getNodes(),s;for(let p=0;p<a.length;p++){s=this.notifyEvent("node:start",{node:a[p].name,index:p});let u=0,l=!1;do{u++;try{c=await this.executeAction(a,p,i),i[p]=c,l=!0}catch(y){if(u>o)throw console.log(`Failed retrying action ${a[p].action.name}, failing`),y;console.log(`Failed executing action ${a[p].action.name}, retrying`),await E((this.conf.retryDelayInMs??$)*u)}}while(!l&&u<=o);await s,await this.notifyEvent("node:finish",{node:a[p].name,index:p})}return await this.notifyEvent("pipeline:finish"),c}catch(r){throw console.error(r),r}}async executeAction(e,t,o){let{action:r,input:i}=e[t];t===6&&(console.log("***input",i),delete o.input,console.log("***values",o));let c=j(i,o);return r(c,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 Z=2,W=350,F=n=>{let{apiKeys:e}=n;return{pipeline:{create:t=>{let o={...t,retries:t.retries??Z,retryDelayInMs:t.retryDelayInMs??W},r=t.flow(new b(t.input,[]));return new A(o,r,e)}}}};async function J(n,e){let t=await e.json(),{searchParams:o}=new URL(e.url);if(!o.has("id"))return new Response("Missing id",{status:400});let r=o.get("id"),i=n[r];return{output:await i.invoke(t),pipeline:i}}var x=require("zod"),G=x.z.object({image:x.z.string()}),_e=x.z.object({labels:x.z.array(x.z.string())});async function H(n,e){let t=G.parse(n),o=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,r={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(o,{method:"POST",body:JSON.stringify(r)})).json()).responses[0].labelAnnotations.map(a=>a.description)}}var P=require("zod"),V=P.z.object({prompt:P.z.string(),size:P.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),De=P.z.object({url:P.z.string().url()});async function Y(n,e){let t=V.parse(n),r=await fetch("https://api.openai.com/v1/images/generations",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)}),{data:i}=await r.json();return{url:i[0].url}}var S=require("zod"),q=S.z.object({prompt:S.z.string(),response_format:S.z.literal("b64_json").default("b64_json"),size:S.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),Me=S.z.object({result:S.z.string()});async function X(n,e){let t=q.parse(n),r=await fetch("https://api.openai.com/v1/images/generations",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)}),{data:i}=await r.json();return{result:i[0].b64_json}}var d=require("zod"),R=d.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"]),C=d.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),Q=d.z.object({text_prompts:d.z.array(d.z.object({text:d.z.string(),weight:d.z.number().min(-1).max(1).default(1)})).refine(n=>n.length>0,"Must have at least one text prompt"),model:R.default("stable-diffusion-v1-5"),clip_guidance_preset:C.optional(),steps:d.z.number().min(0).max(150).optional(),sampler:d.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:d.z.number().min(0).max(35).optional(),seed:d.z.number().min(0).optional(),height:d.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:d.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),Be=d.z.object({result:d.z.instanceof(ArrayBuffer)});async function ee(n,e){console.log("***input 1",n);let t=Q.parse(n);console.log("***payload 1",t);let o=`https://api.stability.ai/v1beta/generation/${t.model}/text-to-image`;return{result:await(await fetch(o,{headers:{"Content-Type":"application/json",Accept:"image/png",Authorization:e.stability},method:"POST",body:JSON.stringify(t)})).arrayBuffer()}}var v=require("zod"),te=v.z.object({text:v.z.string(),amount:v.z.number().optional().default(8)}),Ze=v.z.object({text:v.z.string()}),ne={"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 oe(n){return Object.entries(ne).map(([e,t])=>`Title: ${e}
var T=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})},M=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!D.call(n,r)&&r!==t&&T(n,r,{get:()=>e[r],enumerable:!(o=_(e,r))||o.enumerable});return n};var k=n=>M(T({},"__esModule",{value:!0}),n);var be={};K(be,{Pipeline:()=>A,createClient:()=>F,dalleBase64TextToImage:()=>X,dalleUrlTextToImage:()=>Y,enhanceWithKeywords:()=>re,googleImageLabeling:()=>H,googleTextToSpeech:()=>ye,gpt3Prediction:()=>pe,gpt3PredictionStream:()=>ce,inputSchema:()=>O,output:()=>N,outputSchema:()=>se,replaceString:()=>ie,stabilityClipGuidancePreset:()=>C,stabilityModel:()=>R,stabilityTextToImage:()=>ee,stringToArrayBuffer:()=>le,vercelGenericEdge:()=>J,whisperApi:()=>Se});module.exports=k(be);async function N(n){return n}var b=class{constructor(e,t){this.input=e;this.nodes=t}static create(e){return new b(e,[])}node(e,t){let o=this.createDynamicPlaceholders("input"),r=this.nodes.length>0?this.nodes[this.nodes.length-1]:o,a={action:e,input:t({nodes:this.nodes,prev:r.output,input:o}),output:this.createDynamicPlaceholders(this.nodes.length)};return this.nodes.push(a),this}createDynamicPlaceholders(e){let t={},o={get:function(a,c){return`$context.${e}.${c}$`}};return new Proxy(t,o)}output(e){return this.node(N,e)}getNodes(){return this.nodes}};function j(n){return new Promise(e=>setTimeout(e,n))}function E(n,e){if(typeof n=="string")return r(n);let t={...n};return o(t);function o(i){let s={};for(let p in i)s[p]=r(i[p]);return s}function r(i){if(Array.isArray(i))return i.map(u=>o(u));if(typeof i=="object"&&i!==null)return o(i);let s=i,p=a(i);for(let u of p){let y=e[u.nodeId][u.property];if(y instanceof ArrayBuffer){s=y;continue}s=s?.replace(new RegExp(c(u.value)),y),s==="undefined"?s=void 0:s!==y&&s===y.toString()&&(s=y)}return s}function a(i){if(typeof i!="string")return[];let s=/\$context\.(\d+|input)\.(\w+)\$/g,p=i.matchAll(s),u=[];for(let m of p)u.push({value:m[0],nodeId:m[1],property:m[2]});return u}function c(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function z(n=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=t.length;for(let r=0;r<n;r++)e+=t.charAt(Math.floor(Math.random()*o));return e}var B=2,Z=350,A=class{constructor(e,t,o){this.conf=e;this.flow=t;this.apiKeys=o;this.onProgressListeners=new Map;this.onStartListeners=new Map;this.onFinishListeners=new Map;this.vercel={invoke:e=>this.invokeRemote(`/api/pipelines/${this.conf.id}?_vercel_no_cache=1`,e),invokeStream:(e,t)=>this.invokeStream(`/api/pipelines/${this.conf.id}?_vercel_no_cache=1`,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(o=>o.json())}async invokeStream(e,t,o){let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(r.statusText);let a=r.body;if(!a)return;let c=a.getReader(),i=new TextDecoder,s=!1;for(;!s;){let{value:p,done:u}=await c.read();s=u;let m=i.decode(p);o(m)}}onProgress(e){let t=z();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=z();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=z();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=o=>{let r=JSON.parse(o.data);r.pipelineId===this.conf.id&&(r.type==="pipeline:start"?this.triggerListeners(this.onStartListeners):r.type==="pipeline:finish"?this.triggerListeners(this.onFinishListeners):(r.type==="node:start"||r.type==="node:finish")&&this.triggerListeners(this.onProgressListeners,{...r.data,type:r.type}))}}triggerListeners(e,...t){for(let o of e.values())o(...t)}async processPipeline(e,t){let o=this.conf.retries??B;try{await this.notifyEvent("pipeline:start");let a={input:e.input.parse(t)},c={},i=this.flow.getNodes(),s;for(let p=0;p<i.length;p++){s=this.notifyEvent("node:start",{node:i[p].name,index:p});let u=0,m=!1;do{u++;try{c=await this.executeAction(i,p,a),a[p]=c,m=!0}catch(y){if(u>o)throw y;await j((this.conf.retryDelayInMs??Z)*u)}}while(!m&&u<=o);await s,await this.notifyEvent("node:finish",{node:i[p].name,index:p})}return await this.notifyEvent("pipeline:finish"),c}catch(r){throw console.error(r),r}}async executeAction(e,t,o){let{action:r,input:a}=e[t],c=E(a,o);return r(c,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,W=350,F=n=>{let{apiKeys:e}=n;return{pipeline:{create:t=>{let o={...t,retries:t.retries??$,retryDelayInMs:t.retryDelayInMs??W},r=t.flow(new b(t.input,[]));return new A(o,r,e)}}}};async function J(n,e){let t=await e.json(),{searchParams:o}=new URL(e.url);if(!o.has("id"))return new Response("Missing id",{status:400});let r=o.get("id"),a=n[r];return{output:await a.invoke(t),pipeline:a}}var x=require("zod"),G=x.z.object({image:x.z.string()}),_e=x.z.object({labels:x.z.array(x.z.string())});async function H(n,e){let t=G.parse(n),o=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,r={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(o,{method:"POST",body:JSON.stringify(r)})).json()).responses[0].labelAnnotations.map(i=>i.description)}}var P=require("zod"),V=P.z.object({prompt:P.z.string(),size:P.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),De=P.z.object({url:P.z.string().url()});async function Y(n,e){let t=V.parse(n),r=await fetch("https://api.openai.com/v1/images/generations",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)}),{data:a}=await r.json();return{url:a[0].url}}var S=require("zod"),q=S.z.object({prompt:S.z.string(),response_format:S.z.literal("b64_json").default("b64_json"),size:S.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),Me=S.z.object({result:S.z.string()});async function X(n,e){let t=q.parse(n),r=await fetch("https://api.openai.com/v1/images/generations",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)}),{data:a}=await r.json();return{result:a[0].b64_json}}var d=require("zod"),R=d.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"]),C=d.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),Q=d.z.object({text_prompts:d.z.array(d.z.object({text:d.z.string(),weight:d.z.number().min(-1).max(1).default(1)})).refine(n=>n.length>0,"Must have at least one text prompt"),model:R.default("stable-diffusion-v1-5"),clip_guidance_preset:C.optional(),steps:d.z.number().min(0).max(150).optional(),sampler:d.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:d.z.number().min(0).max(35).optional(),seed:d.z.number().min(0).optional(),height:d.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:d.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),Be=d.z.object({result:d.z.instanceof(ArrayBuffer)});async function ee(n,e){let t=Q.parse(n),o=`https://api.stability.ai/v1beta/generation/${t.model}/text-to-image`;return{result:await(await fetch(o,{headers:{"Content-Type":"application/json",Accept:"image/png",Authorization:e.stability},method:"POST",body:JSON.stringify(t)})).arrayBuffer()}}var v=require("zod"),te=v.z.object({text:v.z.string(),amount:v.z.number().optional().default(8)}),$e=v.z.object({text:v.z.string()}),ne={"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 oe(n){return Object.entries(ne).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,n).join(", ")}

@@ -7,2 +7,2 @@ `).join(`

Title: ${e.text}
Description:`}}var g=require("zod"),ie=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),Fe=g.z.object({text:g.z.string()});async function ae(n){let e=ie.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var m=require("zod"),O=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)}),se=m.z.object({text:m.z.string()});async function pe(n,e){let t=O.parse(n);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 U=require("eventsource-parser"),w=require("zod");var ue=O.merge(w.z.object({stream:w.z.literal(!0).optional().default(!0)})),qe=w.z.object({stream:w.z.instanceof(globalThis.ReadableStream??Object)});async function ce(n,e){let t=ue.parse(n),o=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 de(o)}}async function de(n){let e=new TextEncoder,t=new TextDecoder,o=0;return new ReadableStream({async start(i){function c(s){if(s.type==="event"){let p=s.data;if(p==="[DONE]"){i.close();return}try{let l=JSON.parse(p).choices[0].text;if(o<2&&(l.match(/\n/)||[]).length)return;let y=e.encode(l);i.enqueue(y),o++}catch(u){i.error(u)}}}let a=(0,U.createParser)(c);for await(let s of n.body)a.feed(t.decode(s))}})}var I=require("zod"),le=I.z.object({string:I.z.string()}),Qe=I.z.object({arrayBuffer:I.z.instanceof(ArrayBuffer)});async function me(n){let e=le.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var f=require("zod"),fe=f.z.object({text:f.z.string(),speakingRate:f.z.number().min(.25).max(4).optional().default(1),pitch:f.z.number().min(-20).max(20).optional().default(0),encoding:f.z.enum(["MP3","FLAC","LINEAR16","MULAW","AMR","AMR_WB","OGG_OPUS","SPEEX_WITH_HEADER_BYTE","WEBM_OPUS"]).optional().default("MP3"),voice:f.z.object({language:f.z.string().optional().default("en-US"),name:f.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(f.z.string()).optional().default("en-US-Neural2-C")}).optional().default({language:"en-US",name:"en-US-Neural2-C"})}),tt=f.z.object({audio:f.z.string()});async function ye(n,e){let t=fe.parse(n),o=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,r={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(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()).audioContent}}var h=require("zod"),he="https://transcribe.whisperapi.com",ge=h.z.object({audioUrl:h.z.string().url(),language:h.z.string().default("en"),autoDetectLanguage:h.z.boolean().default(!1),fileType:h.z.string().default("mp3"),task:h.z.enum(["transcribe","translate"]).default("transcribe")}),ot=h.z.object({text:h.z.string()});async function Se(n,e){let t=ge.parse(n),o=new FormData;o.append("url",t.audioUrl),t.autoDetectLanguage||o.append("language",t.language),o.append("fileType",t.fileType),o.append("task",t.task);let r=await fetch(he,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:o});if(!r.ok)throw new Error(r.statusText);return{text:(await r.json()).text.trim()}}0&&(module.exports={Pipeline,createClient,dalleBase64TextToImage,dalleUrlTextToImage,enhanceWithKeywords,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,inputSchema,output,outputSchema,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelGenericEdge,whisperApi});
Description:`}}var g=require("zod"),ae=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),Fe=g.z.object({text:g.z.string()});async function ie(n){let e=ae.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),O=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)}),se=l.z.object({text:l.z.string()});async function pe(n,e){let t=O.parse(n);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 U=require("eventsource-parser"),w=require("zod");var ue=O.merge(w.z.object({stream:w.z.literal(!0).optional().default(!0)})),qe=w.z.object({stream:w.z.instanceof(globalThis.ReadableStream??Object)});async function ce(n,e){let t=ue.parse(n),o=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 de(o)}}async function de(n){let e=new TextEncoder,t=new TextDecoder,o=0;return new ReadableStream({async start(a){function c(s){if(s.type==="event"){let p=s.data;if(p==="[DONE]"){a.close();return}try{let m=JSON.parse(p).choices[0].text;if(o<2&&(m.match(/\n/)||[]).length)return;let y=e.encode(m);a.enqueue(y),o++}catch(u){a.error(u)}}}let i=(0,U.createParser)(c);for await(let s of n.body)i.feed(t.decode(s))}})}var I=require("zod"),me=I.z.object({string:I.z.string()}),Qe=I.z.object({arrayBuffer:I.z.instanceof(ArrayBuffer)});async function le(n){let e=me.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var f=require("zod"),fe=f.z.object({text:f.z.string(),speakingRate:f.z.number().min(.25).max(4).optional().default(1),pitch:f.z.number().min(-20).max(20).optional().default(0),encoding:f.z.enum(["MP3","FLAC","LINEAR16","MULAW","AMR","AMR_WB","OGG_OPUS","SPEEX_WITH_HEADER_BYTE","WEBM_OPUS"]).optional().default("MP3"),voice:f.z.object({language:f.z.string().optional().default("en-US"),name:f.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(f.z.string()).optional().default("en-US-Neural2-C")}).optional().default({language:"en-US",name:"en-US-Neural2-C"})}),tt=f.z.object({audio:f.z.string()});async function ye(n,e){let t=fe.parse(n),o=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,r={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(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()).audioContent}}var h=require("zod"),he="https://transcribe.whisperapi.com",ge=h.z.object({audioUrl:h.z.string().url(),language:h.z.string().default("en"),autoDetectLanguage:h.z.boolean().default(!1),fileType:h.z.string().default("mp3"),task:h.z.enum(["transcribe","translate"]).default("transcribe")}),ot=h.z.object({text:h.z.string()});async function Se(n,e){let t=ge.parse(n),o=new FormData;o.append("url",t.audioUrl),t.autoDetectLanguage||o.append("language",t.language),o.append("fileType",t.fileType),o.append("task",t.task);let r=await fetch(he,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:o});if(!r.ok)throw new Error(r.statusText);return{text:(await r.json()).text.trim()}}0&&(module.exports={Pipeline,createClient,dalleBase64TextToImage,dalleUrlTextToImage,enhanceWithKeywords,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,inputSchema,output,outputSchema,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelGenericEdge,whisperApi});
{
"name": "@aigur/client",
"version": "0.32.2",
"version": "0.32.3",
"description": "",

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

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

): Promise<z.infer<typeof outputSchema>> {
console.log(`***input 1`, input);
const payload = inputSchema.parse(input);
console.log(`***payload 1`, payload);
const endpoint = `https://api.stability.ai/v1beta/generation/${payload.model}/text-to-image`;

@@ -84,0 +82,0 @@ const response = await fetch(endpoint, {

import { z } from 'zod';
import { FlowBuilder } from './builder';
import { delay } from './delay';
import { getInputByContext } from './getInputByContext';
import { makeid } from './makeid';
import {

@@ -11,6 +15,2 @@ APIKeys,

} from './types';
import { makeid } from './makeid';
import { getInputByContext } from './getInputByContext';
import { delay } from './delay';
import { FlowBuilder } from './builder';

@@ -188,6 +188,4 @@ const DEFAULT_RETRIES = 2;

if (attemptCount > retriesCount) {
console.log(`Failed retrying action ${nodes[i].action.name}, failing`);
throw e;
}
console.log(`Failed executing action ${nodes[i].action.name}, retrying`);
await delay((this.conf.retryDelayInMs ?? RETRY_DELAY_IN_MS) * attemptCount);

@@ -211,7 +209,2 @@ }

const { action, input } = nodes[index];
if (index === 6) {
console.log(`***input`, input);
delete values.input;
console.log(`***values`, values);
}
const inputByContext = getInputByContext(input, values);

@@ -218,0 +211,0 @@ return action(inputByContext, this.apiKeys);

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