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 1.7.0 to 1.8.0

6

CHANGELOG.md
# @aigur/client
## 1.8.0
### Minor Changes
- 416c2676: add output to pipeline:finish event
## 1.7.0

@@ -4,0 +10,0 @@

2

dist/index.js

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

var j=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ce=(n,e)=>{for(var t in e)j(n,t,{get:e[t],enumerable:!0})},de=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pe(e))!ue.call(n,r)&&r!==t&&j(n,r,{get:()=>e[r],enumerable:!(o=se(e,r))||o.enumerable});return n};var me=n=>de(j({},"__esModule",{value:!0}),n);var Be={};ce(Be,{Pipeline:()=>T,cleanContextVars:()=>G,createClient:()=>Se,dalleBase64TextToImage:()=>F,dalleUrlTextToImage:()=>J,enhanceWithKeywords:()=>q,googleImageLabeling:()=>W,googleTextToSpeech:()=>re,gpt3Prediction:()=>X,gpt3PredictionStream:()=>ne,gpt3TurboPrediction:()=>Q,gpt3TurboPredictionStream:()=>ee,output:()=>E,replaceMultipleStrings:()=>H,replaceString:()=>Y,stabilityTextToImage:()=>V,stringToArrayBuffer:()=>oe,vercelEdgeFunction:()=>$e,vercelGenericEdge:()=>k,whisperApi:()=>ae});module.exports=me(Be);function D(n,e){if(typeof n=="string")return o(n);return t({...n});function t(a){let i={};for(let p in a)i[p]=o(a[p]);return i}function o(a){if(Array.isArray(a))return a.map(s=>t(s));if(typeof a=="object"&&a!==null)return t(a);let i=a,p=z(a);for(let s of p){let u=e[s.nodeId].output;if(u==null)continue;let c=u[s.property];if(c instanceof ArrayBuffer){i=c;continue}i=i?.replace(new RegExp(r(s.value)),c),i==="undefined"?i=void 0:i!==c&&i===c.toString()&&(i=c)}return i}function r(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function z(n){if(typeof n!="string")return[];let e=/\$context\.(\d+|input|memory|pipeline)\.(\w+)\$/g,t=n.matchAll(e),o=[];for(let r of t)o.push({value:r[0],nodeId:r[1],property:r[2]});return o}async function K(n,e){let{memoryToSave:t}=e;if(!t)return;let o=D(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let p=z(t[r]),[s,u]=i.tee();n.values[p[0].nodeId].output=s;let c=await le(u);o[a]=c}}return o}function le(n){return new Promise(async e=>{let t=n.getReader(),o=new TextDecoder,r=!1,a="";for(;!r;){let{value:i,done:p}=await t.read();r=p;let s=o.decode(i);a+=s}e(a)})}function $(n){let e={input:{input:n.input,output:n.input},memory:{input:n.memory,output:n.memory},pipeline:{input:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId},output:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId}}};return{pipelineInstanceId:n.pipelineInstanceId,input:n.input,output:{},values:e,memory:n.memory,userId:n.userId}}function w(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 B(n){return new Promise(e=>setTimeout(e,n))}var fe=2,ye=350,T=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.pipelineInstanceId=w(16);this.eventIndex=0;this.vercel={invoke:(e,t)=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e,{userId:t?.userId}),invokeStream:(e,t,o)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t,{userId:o?.userId})};this.listenToEvents()}async invoke(e,t){let o=await this.loadMemory(t?.userId),r=$({input:e,pipelineInstanceId:t?.pipelineInstanceId??this.pipelineInstanceId,userId:t?.userId??"",memory:o});return await this.processPipeline(r),r.output}async saveMemory(e,t){let o=await t;!this.conf.memoryManager||!o||this.conf.memoryManager.saveMemory(this.getMemoryId(e.userId),o)}getMemoryId(e){return`${this.conf.id}${e?`-${e}`:""}`}loadMemory(e){return this.conf.memoryManager?this.conf.memoryManager.loadMemory(this.getMemoryId(e)):Promise.resolve(null)}invokeRemote(e,t,o){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:o?.userId??""})}).then(r=>r.json())}async invokeStream(e,t,o,r){let a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:r?.userId??""})});if(!a.ok)throw new Error(a.statusText);let i=a.body;if(!i)return;let p=i.getReader(),s=new TextDecoder,u=!1;for(;!u;){let{value:c,done:y}=await p.read();u=y;let v=s.decode(c);o(v)}}onProgress(e){let t=w();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=w();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=w();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??fe;try{let o=this.notifyEvent({type:"pipeline:start",context:e});if(this.conf.stream||await o,this.conf.validateInput){let i=this.conf.validateInput(e.input);if(!i.valid)throw new Error(i.message)}let r=this.flow.getNodes();for(let i=0;i<r.length;i++){let p=this.notifyEvent({type:"node:start",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await p;let s=0,u=!1;do{s++;try{let{action:y,input:v}=r[i],C=e.values[i]={input:null,output:null};C.input=D(v,e.values),C.output=await y(C.input,this.apiKeys);let ie=K(e,r[i]);this.saveMemory(e,ie),u=!0}catch(y){if(s>t)throw y;await B((this.conf.retryDelayInMs??ye)*s)}}while(!u&&s<=t);let c=this.notifyEvent({type:"node:finish",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await c}let a=this.notifyEvent({type:"pipeline:finish",context:e});return this.conf.stream||await a,e.output=e.values[r.length-1].output,e}catch(o){throw console.error(o),o}}listenToEvents(){!this.conf.updateProgress||typeof window>"u"||!this.conf.eventListener||this.conf.eventListener(this.pipelineInstanceId,e=>{e.pipelineId===this.conf.id&&(e.type==="node:start"||e.type==="node:finish"?this.triggerListeners(this.onProgressListeners,e):e.type==="pipeline:start"?this.triggerListeners(this.onStartListeners,e):e.type==="pipeline:finish"&&this.triggerListeners(this.onFinishListeners,e))})}triggerListeners(e,...t){for(let o of e.values())o(...t)}notifyEvent(e){if(!(!this.conf.updateProgress||!this.conf.eventPublisher))return this.conf.eventPublisher(e.context.pipelineInstanceId,{pipelineId:this.conf.id,eventIndex:this.eventIndex++,type:e.type,data:e.data})}};async function E(n){return n}var O=class{constructor(e){this.nodes=e}node(e,t,o){let r=this.createDynamicPlaceholders("memory"),a=this.createDynamicPlaceholders("input"),i=this.createDynamicPlaceholders(this.nodes.length),p=this.nodes.length>0?this.nodes[this.nodes.length-1]:a,s="$context.pipeline.userId$",u={action:e,input:t({nodes:this.nodes,prev:p.output,input:a,memory:r,userId:s}),output:this.createDynamicPlaceholders(this.nodes.length),memoryToSave:o?o({nodes:this.nodes,prev:p.output,output:i,input:a,memory:r,userId:s}):null};return this.nodes.push(u),this}createDynamicPlaceholders(e){let t={},o={get:function(a,i){return`$context.${e}.${i}$`}};return new Proxy(t,o)}output(e,t){return this.node(E,e,t)}getNodes(){return this.nodes}};var he=2,ge=350,Se=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??he,retryDelayInMs:t.retryDelayInMs??ge,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new O([]));return new T(o,r,e)}}}};var I=require("zod"),xe=I.z.object({image:I.z.string()}),pt=I.z.object({labels:I.z.array(I.z.string())});async function W(n,e){let t=xe.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(p=>p.description)}}var x=require("zod"),Ie=x.z.object({prompt:x.z.string(),response_format:x.z.literal("b64_json").default("b64_json"),size:x.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),ct=x.z.object({result:x.z.string()});async function F(n,e){let t=Ie.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 b=require("zod"),be=b.z.object({prompt:b.z.string(),size:b.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),mt=b.z.object({url:b.z.string().url()});async function J(n,e){let t=be.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 d=require("zod"),Pe=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"]),ve=d.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),we=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:Pe.default("stable-diffusion-v1-5"),clip_guidance_preset:ve.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")}),ft=d.z.object({result:d.z.instanceof(ArrayBuffer)});async function V(n,e){let t=we.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 A=require("zod"),Te=A.z.object({text:A.z.string()}),ht=A.z.object({text:A.z.string()});async function G(n){return{text:Te.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var P=require("zod"),Ae=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),St=P.z.object({text:P.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 Re(n){return Object.entries(Ne).map(([e,t])=>`Title: ${e}
var j=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ce=(n,e)=>{for(var t in e)j(n,t,{get:e[t],enumerable:!0})},de=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pe(e))!ue.call(n,r)&&r!==t&&j(n,r,{get:()=>e[r],enumerable:!(o=se(e,r))||o.enumerable});return n};var me=n=>de(j({},"__esModule",{value:!0}),n);var Be={};ce(Be,{Pipeline:()=>T,cleanContextVars:()=>G,createClient:()=>Se,dalleBase64TextToImage:()=>F,dalleUrlTextToImage:()=>J,enhanceWithKeywords:()=>q,googleImageLabeling:()=>W,googleTextToSpeech:()=>re,gpt3Prediction:()=>X,gpt3PredictionStream:()=>ne,gpt3TurboPrediction:()=>Q,gpt3TurboPredictionStream:()=>ee,output:()=>E,replaceMultipleStrings:()=>H,replaceString:()=>Y,stabilityTextToImage:()=>V,stringToArrayBuffer:()=>oe,vercelEdgeFunction:()=>$e,vercelGenericEdge:()=>k,whisperApi:()=>ae});module.exports=me(Be);function K(n){return new Promise(e=>setTimeout(e,n))}function D(n,e){if(typeof n=="string")return o(n);return t({...n});function t(a){let i={};for(let p in a)i[p]=o(a[p]);return i}function o(a){if(Array.isArray(a))return a.map(s=>t(s));if(typeof a=="object"&&a!==null)return t(a);let i=a,p=z(a);for(let s of p){let u=e[s.nodeId].output;if(u==null)continue;let c=u[s.property];if(c instanceof ArrayBuffer){i=c;continue}i=i?.replace(new RegExp(r(s.value)),c),i==="undefined"?i=void 0:i!==c&&i===c.toString()&&(i=c)}return i}function r(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function z(n){if(typeof n!="string")return[];let e=/\$context\.(\d+|input|memory|pipeline)\.(\w+)\$/g,t=n.matchAll(e),o=[];for(let r of t)o.push({value:r[0],nodeId:r[1],property:r[2]});return o}function w(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 $(n){let e={input:{input:n.input,output:n.input},memory:{input:n.memory,output:n.memory},pipeline:{input:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId},output:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId}}};return{pipelineInstanceId:n.pipelineInstanceId,input:n.input,output:{},values:e,memory:n.memory,userId:n.userId}}async function B(n,e){let{memoryToSave:t}=e;if(!t)return;let o=D(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let p=z(t[r]),[s,u]=i.tee();n.values[p[0].nodeId].output=s;let c=await le(u);o[a]=c}}return o}function le(n){return new Promise(async e=>{let t=n.getReader(),o=new TextDecoder,r=!1,a="";for(;!r;){let{value:i,done:p}=await t.read();r=p;let s=o.decode(i);a+=s}e(a)})}var fe=2,ye=350,T=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.pipelineInstanceId=w(16);this.eventIndex=0;this.vercel={invoke:(e,t)=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e,{userId:t?.userId}),invokeStream:(e,t,o)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t,{userId:o?.userId})};this.listenToEvents()}async invoke(e,t){let o=await this.loadMemory(t?.userId),r=$({input:e,pipelineInstanceId:t?.pipelineInstanceId??this.pipelineInstanceId,userId:t?.userId??"",memory:o});return await this.processPipeline(r),r.output}async saveMemory(e,t){let o=await t;!this.conf.memoryManager||!o||this.conf.memoryManager.saveMemory(this.getMemoryId(e.userId),o)}getMemoryId(e){return`${this.conf.id}${e?`-${e}`:""}`}loadMemory(e){return this.conf.memoryManager?this.conf.memoryManager.loadMemory(this.getMemoryId(e)):Promise.resolve(null)}invokeRemote(e,t,o){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:o?.userId??""})}).then(r=>r.json())}async invokeStream(e,t,o,r){let a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:r?.userId??""})});if(!a.ok)throw new Error(a.statusText);let i=a.body;if(!i)return;let p=i.getReader(),s=new TextDecoder,u=!1;for(;!u;){let{value:c,done:y}=await p.read();u=y;let v=s.decode(c);o(v)}}onProgress(e){let t=w();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=w();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=w();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??fe;try{let o=this.notifyEvent({type:"pipeline:start",context:e});if(this.conf.stream||await o,this.conf.validateInput){let i=this.conf.validateInput(e.input);if(!i.valid)throw new Error(i.message)}let r=this.flow.getNodes();for(let i=0;i<r.length;i++){let p=this.notifyEvent({type:"node:start",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await p;let s=0,u=!1;do{s++;try{let{action:y,input:v}=r[i],C=e.values[i]={input:null,output:null};C.input=D(v,e.values),C.output=await y(C.input,this.apiKeys);let ie=B(e,r[i]);this.saveMemory(e,ie),u=!0}catch(y){if(s>t)throw y;await K((this.conf.retryDelayInMs??ye)*s)}}while(!u&&s<=t);let c=this.notifyEvent({type:"node:finish",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await c}e.output=e.values[r.length-1].output,console.log("sending pipeline finish",{output:e.output instanceof ReadableStream?"Stream":e.output});let a=this.notifyEvent({type:"pipeline:finish",context:e,data:{output:e.output instanceof ReadableStream?"Stream":e.output}});return this.conf.stream||await a,e}catch(o){throw console.error(o),o}}listenToEvents(){!this.conf.updateProgress||typeof window>"u"||!this.conf.eventListener||this.conf.eventListener(this.pipelineInstanceId,e=>{e.pipelineId===this.conf.id&&(e.type==="node:start"||e.type==="node:finish"?this.triggerListeners(this.onProgressListeners,e):e.type==="pipeline:start"?this.triggerListeners(this.onStartListeners,e):e.type==="pipeline:finish"&&this.triggerListeners(this.onFinishListeners,e))})}triggerListeners(e,...t){for(let o of e.values())o(...t)}notifyEvent(e){if(!(!this.conf.updateProgress||!this.conf.eventPublisher))return this.conf.eventPublisher(e.context.pipelineInstanceId,{pipelineId:this.conf.id,eventIndex:this.eventIndex++,type:e.type,data:e.data})}};async function E(n){return n}var O=class{constructor(e){this.nodes=e}node(e,t,o){let r=this.createDynamicPlaceholders("memory"),a=this.createDynamicPlaceholders("input"),i=this.createDynamicPlaceholders(this.nodes.length),p=this.nodes.length>0?this.nodes[this.nodes.length-1]:a,s="$context.pipeline.userId$",u={action:e,input:t({nodes:this.nodes,prev:p.output,input:a,memory:r,userId:s}),output:this.createDynamicPlaceholders(this.nodes.length),memoryToSave:o?o({nodes:this.nodes,prev:p.output,output:i,input:a,memory:r,userId:s}):null};return this.nodes.push(u),this}createDynamicPlaceholders(e){let t={},o={get:function(a,i){return`$context.${e}.${i}$`}};return new Proxy(t,o)}output(e,t){return this.node(E,e,t)}getNodes(){return this.nodes}};var he=2,ge=350,Se=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??he,retryDelayInMs:t.retryDelayInMs??ge,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new O([]));return new T(o,r,e)}}}};var I=require("zod"),xe=I.z.object({image:I.z.string()}),pt=I.z.object({labels:I.z.array(I.z.string())});async function W(n,e){let t=xe.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(p=>p.description)}}var x=require("zod"),Ie=x.z.object({prompt:x.z.string(),response_format:x.z.literal("b64_json").default("b64_json"),size:x.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),ct=x.z.object({result:x.z.string()});async function F(n,e){let t=Ie.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 b=require("zod"),be=b.z.object({prompt:b.z.string(),size:b.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),mt=b.z.object({url:b.z.string().url()});async function J(n,e){let t=be.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 d=require("zod"),Pe=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"]),ve=d.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),we=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:Pe.default("stable-diffusion-v1-5"),clip_guidance_preset:ve.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")}),ft=d.z.object({result:d.z.instanceof(ArrayBuffer)});async function V(n,e){let t=we.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 A=require("zod"),Te=A.z.object({text:A.z.string()}),ht=A.z.object({text:A.z.string()});async function G(n){return{text:Te.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var P=require("zod"),Ae=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),St=P.z.object({text:P.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 Re(n){return Object.entries(Ne).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,n).join(", ")}

@@ -3,0 +3,0 @@ `).join(`

{
"name": "@aigur/client",
"version": "1.7.0",
"version": "1.8.0",
"description": "",

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

@@ -0,11 +1,16 @@

import { FlowBuilder } from './builder';
import { delay } from './delay';
import { placeholdersToConcreteValues } from './getConcreteNodeInput';
import { makeid } from './makeid';
import { createContext } from './PipelineContext';
import { retrieveConcreteMemoryData } from './retrieveMemoryData';
import {
APIKeys, ConcreteNode, EventType, PipelineConf, PipelineContext, PipelineProgressEvent,
PipelineStatusEvent
APIKeys,
ConcreteNode,
EventType,
PipelineConf,
PipelineContext,
PipelineProgressEvent,
PipelineStatusEvent,
} from './types';
import { retrieveConcreteMemoryData } from './retrieveMemoryData';
import { createContext } from './PipelineContext';
import { makeid } from './makeid';
import { placeholdersToConcreteValues } from './getConcreteNodeInput';
import { delay } from './delay';
import { FlowBuilder } from './builder';

@@ -252,5 +257,11 @@ const DEFAULT_RETRIES = 2;

}
context.output = context.values[nodes.length - 1].output;
console.log(`sending pipeline finish`, {
output: context.output instanceof ReadableStream ? 'Stream' : context.output,
});
const pipelineFinishPromise = this.notifyEvent({
type: 'pipeline:finish',
context,
data: { output: context.output instanceof ReadableStream ? 'Stream' : context.output },
});

@@ -260,4 +271,2 @@ if (!this.conf.stream) {

}
context.output = context.values[nodes.length - 1].output;
return context;

@@ -264,0 +273,0 @@ } catch (e) {

Sorry, the diff of this file is not supported yet

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