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.3.0 to 1.4.0

6

CHANGELOG.md
# @aigur/client
## 1.4.0
### Minor Changes
- 8fcb638d: Add node tag property to help with cross-server notifications
## 1.3.0

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

1

dist/index.d.ts

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

type ConcreteNode<Input extends Record<string, unknown> | ReadableStream, Output extends Record<string, unknown> | ReadableStream, MemoryData extends Record<string, unknown>> = {
tag?: string;
action: NodeAction<Input, Output>;

@@ -72,0 +73,0 @@ input: Input;

4

dist/index.js

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

var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var V=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},G=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of W(e))!J.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(o=F(e,r))||o.enumerable});return n};var H=n=>G(E({},"__esModule",{value:!0}),n);var Ee={};V(Ee,{Pipeline:()=>w,cleanContextVars:()=>ce,createClient:()=>ee,dalleBase64TextToImage:()=>re,dalleUrlTextToImage:()=>ae,enhanceWithKeywords:()=>fe,googleImageLabeling:()=>ne,googleTextToSpeech:()=>Re,gpt3Prediction:()=>Ie,gpt3PredictionStream:()=>ve,inputSchema:()=>D,output:()=>j,outputSchema:()=>xe,replaceMultipleStrings:()=>he,replaceString:()=>Se,stabilityClipGuidancePreset:()=>$,stabilityModel:()=>k,stabilityTextToImage:()=>pe,stringToArrayBuffer:()=>Ne,vercelEdgeFunction:()=>Ce,vercelGenericEdge:()=>U,whisperApi:()=>De});module.exports=H(Ee);function A(n,e){if(typeof n=="string")return o(n);return t({...n});function t(i){let a={};for(let p in i)a[p]=o(i[p]);return a}function o(i){if(Array.isArray(i))return i.map(s=>t(s));if(typeof i=="object"&&i!==null)return t(i);let a=i,p=O(i);for(let s of p){let u=e[s.nodeId].output;if(u==null)continue;let d=u[s.property];if(d instanceof ArrayBuffer){a=d;continue}a=a?.replace(new RegExp(r(s.value)),d),a==="undefined"?a=void 0:a!==d&&a===d.toString()&&(a=d)}return a}function r(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function O(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 z(n,e){let{memoryToSave:t}=e;if(!t)return;let o=A(t,n.values);for(let r in t)for(let i in o){let a=o[i];if(a instanceof ReadableStream){let p=O(t[r]),[s,u]=a.tee();n.values[p[0].nodeId].output=s;let d=await Y(u);o[i]=d}}return o}function Y(n){return new Promise(async e=>{let t=n.getReader(),o=new TextDecoder,r=!1,i="";for(;!r;){let{value:a,done:p}=await t.read();r=p;let s=o.decode(a);i+=s}e(i)})}function L(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 b(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){return new Promise(e=>setTimeout(e,n))}var q=2,X=350,w=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=b(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=L({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 i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:r?.userId??""})});if(!i.ok)throw new Error(i.statusText);let a=i.body;if(!a)return;let p=a.getReader(),s=new TextDecoder,u=!1;for(;!u;){let{value:d,done:y}=await p.read();u=y;let v=s.decode(d);o(v)}}onProgress(e){let t=b();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=b();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=b();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??q;try{let o=this.notifyEvent({type:"pipeline:start",context:e});if(this.conf.stream||await o,this.conf.validateInput){let a=this.conf.validateInput(e.input);if(!a.valid)throw new Error(a.message)}let r=this.flow.getNodes();for(let a=0;a<r.length;a++){let p=this.notifyEvent({type:"node:start",context:e,data:{node:r[a].action.name,index:a}});this.conf.stream||await p;let s=0,u=!1;do{s++;try{let{action:y,input:v}=r[a],C=e.values[a]={input:null,output:null};C.input=A(v,e.values),C.output=await y(C.input,this.apiKeys);let B=z(e,r[a]);this.saveMemory(e,B),u=!0}catch(y){if(s>t)throw y;await _((this.conf.retryDelayInMs??X)*s)}}while(!u&&s<=t);let d=this.notifyEvent({type:"node:finish",context:e,data:{node:r[a].action.name,index:a}});this.conf.stream||await d}let i=this.notifyEvent({type:"pipeline:finish",context:e});return this.conf.stream||await i,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 j(n){return n}var T=class{constructor(e){this.nodes=e}node(e,t,o){let r=this.createDynamicPlaceholders("memory"),i=this.createDynamicPlaceholders("input"),a=this.createDynamicPlaceholders(this.nodes.length),p=this.nodes.length>0?this.nodes[this.nodes.length-1]:i,s="$context.pipeline.userId$",u={action:e,input:t({nodes:this.nodes,prev:p.output,input:i,memory:r,userId:s}),output:this.createDynamicPlaceholders(this.nodes.length),memoryToSave:o?o({nodes:this.nodes,prev:p.output,output:a,input:i,memory:r,userId:s}):null};return this.nodes.push(u),this}createDynamicPlaceholders(e){let t={},o={get:function(i,a){return`$context.${e}.${a}$`}};return new Proxy(t,o)}output(e,t){return this.node(j,e,t)}getNodes(){return this.nodes}};var Q=2,Z=350,ee=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??Q,retryDelayInMs:t.retryDelayInMs??Z,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new T([]));return new w(o,r,e)}}}};var x=require("zod"),te=x.z.object({image:x.z.string()}),Qe=x.z.object({labels:x.z.array(x.z.string())});async function ne(n,e){let t=te.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 S=require("zod"),oe=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")}),et=S.z.object({result:S.z.string()});async function re(n,e){let t=oe.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 I=require("zod"),ie=I.z.object({prompt:I.z.string(),size:I.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),nt=I.z.object({url:I.z.string().url()});async function ae(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:i}=await r.json();return{url:i[0].url}}var c=require("zod"),k=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"]),$=c.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),se=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(n=>n.length>0,"Must have at least one text prompt"),model:k.default("stable-diffusion-v1-5"),clip_guidance_preset:$.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(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:c.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),rt=c.z.object({result:c.z.instanceof(ArrayBuffer)});async function pe(n,e){let t=se.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 N=require("zod"),ue=N.z.object({text:N.z.string()}),at=N.z.object({text:N.z.string()});async function ce(n){return{text:ue.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var P=require("zod"),de=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),pt=P.z.object({text:P.z.string()}),me={"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 le(n){return Object.entries(me).map(([e,t])=>`Title: ${e}
var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var V=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},G=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of W(e))!J.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(o=F(e,r))||o.enumerable});return n};var H=n=>G(E({},"__esModule",{value:!0}),n);var Ee={};V(Ee,{Pipeline:()=>w,cleanContextVars:()=>ce,createClient:()=>ee,dalleBase64TextToImage:()=>re,dalleUrlTextToImage:()=>ae,enhanceWithKeywords:()=>fe,googleImageLabeling:()=>ne,googleTextToSpeech:()=>Re,gpt3Prediction:()=>Ie,gpt3PredictionStream:()=>ve,inputSchema:()=>D,output:()=>j,outputSchema:()=>xe,replaceMultipleStrings:()=>he,replaceString:()=>Se,stabilityClipGuidancePreset:()=>$,stabilityModel:()=>k,stabilityTextToImage:()=>pe,stringToArrayBuffer:()=>Ne,vercelEdgeFunction:()=>Ce,vercelGenericEdge:()=>U,whisperApi:()=>De});module.exports=H(Ee);function A(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=O(a);for(let s of p){let u=e[s.nodeId].output;if(u==null)continue;let d=u[s.property];if(d instanceof ArrayBuffer){i=d;continue}i=i?.replace(new RegExp(r(s.value)),d),i==="undefined"?i=void 0:i!==d&&i===d.toString()&&(i=d)}return i}function r(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function O(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 z(n,e){let{memoryToSave:t}=e;if(!t)return;let o=A(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let p=O(t[r]),[s,u]=i.tee();n.values[p[0].nodeId].output=s;let d=await Y(u);o[a]=d}}return o}function Y(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 L(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 b(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){return new Promise(e=>setTimeout(e,n))}var q=2,X=350,w=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=b(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=L({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:d,done:y}=await p.read();u=y;let v=s.decode(d);o(v)}}onProgress(e){let t=b();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=b();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=b();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??q;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=A(v,e.values),C.output=await y(C.input,this.apiKeys);let B=z(e,r[i]);this.saveMemory(e,B),u=!0}catch(y){if(s>t)throw y;await _((this.conf.retryDelayInMs??X)*s)}}while(!u&&s<=t);let d=this.notifyEvent({type:"node:finish",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await d}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 j(n){return n}var T=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(j,e,t)}getNodes(){return this.nodes}};var Q=2,Z=350,ee=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??Q,retryDelayInMs:t.retryDelayInMs??Z,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new T([]));return new w(o,r,e)}}}};var x=require("zod"),te=x.z.object({image:x.z.string()}),Qe=x.z.object({labels:x.z.array(x.z.string())});async function ne(n,e){let t=te.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 S=require("zod"),oe=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")}),et=S.z.object({result:S.z.string()});async function re(n,e){let t=oe.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 I=require("zod"),ie=I.z.object({prompt:I.z.string(),size:I.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),nt=I.z.object({url:I.z.string().url()});async function ae(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{url:a[0].url}}var c=require("zod"),k=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"]),$=c.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),se=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(n=>n.length>0,"Must have at least one text prompt"),model:k.default("stable-diffusion-v1-5"),clip_guidance_preset:$.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(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:c.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),rt=c.z.object({result:c.z.instanceof(ArrayBuffer)});async function pe(n,e){let t=se.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 N=require("zod"),ue=N.z.object({text:N.z.string()}),at=N.z.object({text:N.z.string()});async function ce(n){return{text:ue.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var P=require("zod"),de=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),pt=P.z.object({text:P.z.string()}),me={"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 le(n){return Object.entries(me).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,n).join(", ")}

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

Title: ${e.text}
Description:`}}var h=require("zod"),ye=h.z.object({strings:h.z.record(h.z.string(),h.z.string()),modifier:h.z.string()}),ct=h.z.object({text:h.z.string()});async function he(n){let e=ye.parse(n);for(let t in e.strings)e.modifier=e.modifier.replace(new RegExp(`\\$\\(${t}\\)\\$`,"gm"),e.strings[t]);return{text:e.modifier}}var g=require("zod"),ge=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),mt=g.z.object({text:g.z.string()});async function Se(n){let e=ge.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var m=require("zod"),D=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)}),xe=m.z.object({text:m.z.string()});async function Ie(n,e){let t=D.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 K=require("eventsource-parser"),M=require("zod");var Pe=D.merge(M.z.object({stream:M.z.literal(!0).optional().default(!0)})),St=M.z.object({stream:M.z.instanceof(globalThis.ReadableStream??Object)});async function ve(n,e){let t=Pe.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 be(o)}}async function be(n){let e=new TextEncoder,t=new TextDecoder,o=0;return new ReadableStream({async start(i){function a(s){if(s.type==="event"){let u=s.data;if(u==="[DONE]"){i.close();return}try{let y=JSON.parse(u).choices[0].text;if(o<2&&(y.match(/\n/)||[]).length)return;let v=e.encode(y);i.enqueue(v),o++}catch(d){i.error(d)}}}let p=(0,K.createParser)(a);for await(let s of n.body)p.feed(t.decode(s))}})}var R=require("zod"),we=R.z.object({string:R.z.string()}),It=R.z.object({arrayBuffer:R.z.instanceof(ArrayBuffer)});async function Ne(n){let e=we.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var l=require("zod"),Me=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"})}),vt=l.z.object({audio:l.z.string()});async function Re(n,e){let t=Me.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 f=require("zod"),Ae="https://transcribe.whisperapi.com",Te=f.z.object({audioUrl:f.z.string().url(),language:f.z.string().default("en"),autoDetectLanguage:f.z.boolean().default(!1),fileType:f.z.string().default("mp3"),task:f.z.enum(["transcribe","translate"]).default("transcribe")}),wt=f.z.object({text:f.z.string()});async function De(n,e){let t=Te.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(Ae,{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()}}async function U(n,e){let{pipelineInstanceId:t,userId:o,input:r}=await e.json(),{searchParams:i}=new URL(e.url);if(!i.has("id"))return new Response("Missing id",{status:400});let a=i.get("id"),p=n[a];return{output:await p.invoke(r,{pipelineInstanceId:t,userId:o}),pipeline:p}}function Ce(n){return async e=>{let t=await U(n,e);return t instanceof Response?t:t.pipeline.conf.stream&&t.output instanceof ReadableStream?new Response(t.output):new Response(JSON.stringify(t.output,null,2),{headers:{"content-type":"application/json;charset=UTF-8"}})}}0&&(module.exports={Pipeline,cleanContextVars,createClient,dalleBase64TextToImage,dalleUrlTextToImage,enhanceWithKeywords,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,inputSchema,output,outputSchema,replaceMultipleStrings,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelEdgeFunction,vercelGenericEdge,whisperApi});
Description:`}}var h=require("zod"),ye=h.z.object({strings:h.z.record(h.z.string(),h.z.string()),modifier:h.z.string()}),ct=h.z.object({text:h.z.string()});async function he(n){let e=ye.parse(n);for(let t in e.strings)e.modifier=e.modifier.replace(new RegExp(`\\$\\(${t}\\)\\$`,"gm"),e.strings[t]);return{text:e.modifier}}var g=require("zod"),ge=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),mt=g.z.object({text:g.z.string()});async function Se(n){let e=ge.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var m=require("zod"),D=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)}),xe=m.z.object({text:m.z.string()});async function Ie(n,e){let t=D.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 K=require("eventsource-parser"),M=require("zod");var Pe=D.merge(M.z.object({stream:M.z.literal(!0).optional().default(!0)})),St=M.z.object({stream:M.z.instanceof(globalThis.ReadableStream??Object)});async function ve(n,e){let t=Pe.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 be(o)}}async function be(n){let e=new TextEncoder,t=new TextDecoder,o=0;return new ReadableStream({async start(a){function i(s){if(s.type==="event"){let u=s.data;if(u==="[DONE]"){a.close();return}try{let y=JSON.parse(u).choices[0].text;if(o<2&&(y.match(/\n/)||[]).length)return;let v=e.encode(y);a.enqueue(v),o++}catch(d){a.error(d)}}}let p=(0,K.createParser)(i);for await(let s of n.body)p.feed(t.decode(s))}})}var R=require("zod"),we=R.z.object({string:R.z.string()}),It=R.z.object({arrayBuffer:R.z.instanceof(ArrayBuffer)});async function Ne(n){let e=we.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var l=require("zod"),Me=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"})}),vt=l.z.object({audio:l.z.string()});async function Re(n,e){let t=Me.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 f=require("zod"),Ae="https://transcribe.whisperapi.com",Te=f.z.object({audioUrl:f.z.string().url(),language:f.z.string().default("en"),autoDetectLanguage:f.z.boolean().default(!1),fileType:f.z.string().default("mp3"),task:f.z.enum(["transcribe","translate"]).default("transcribe")}),wt=f.z.object({text:f.z.string()});async function De(n,e){let t=Te.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(Ae,{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()}}async function U(n,e){let{pipelineInstanceId:t,userId:o,input:r}=await e.json(),{searchParams:a}=new URL(e.url);if(!a.has("id"))return new Response("Missing id",{status:400});let i=a.get("id"),p=n[i];return{output:await p.invoke(r,{pipelineInstanceId:t,userId:o}),pipeline:p}}function Ce(n){return async e=>{let t=await U(n,e);return t instanceof Response?t:t.pipeline.conf.stream&&t.output instanceof ReadableStream?new Response(t.output):new Response(JSON.stringify(t.output,null,2),{headers:{"content-type":"application/json;charset=UTF-8"}})}}0&&(module.exports={Pipeline,cleanContextVars,createClient,dalleBase64TextToImage,dalleUrlTextToImage,enhanceWithKeywords,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,inputSchema,output,outputSchema,replaceMultipleStrings,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelEdgeFunction,vercelGenericEdge,whisperApi});
{
"name": "@aigur/client",
"version": "1.3.0",
"version": "1.4.0",
"description": "",

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

@@ -213,2 +213,3 @@ import {

node: nodes[nodeIndex].action.name,
tag: nodes[nodeIndex].tag ?? '',
index: nodeIndex,

@@ -244,2 +245,3 @@ },

node: nodes[nodeIndex].action.name,
tag: nodes[nodeIndex].tag ?? '',
index: nodeIndex,

@@ -246,0 +248,0 @@ },

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

> = {
tag?: string;
action: NodeAction<Input, Output>;

@@ -53,0 +54,0 @@ input: Input;

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