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.0.1 to 1.0.2

README.md

6

CHANGELOG.md
# @aigur/client
## 1.0.2
### Patch Changes
- 6974e556: Wait for events for non-stream pipelines (temp)
## 1.0.1

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

8

dist/index.js

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

var N=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var k=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},M=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _(e))!D.call(n,i)&&i!==t&&N(n,i,{get:()=>e[i],enumerable:!(o=z(e,i))||o.enumerable});return n};var K=n=>M(N({},"__esModule",{value:!0}),n);var xe={};k(xe,{Pipeline:()=>w,createClient:()=>J,dalleBase64TextToImage:()=>Z,dalleUrlTextToImage:()=>q,enhanceWithKeywords:()=>ie,googleImageLabeling:()=>V,googleTextToSpeech:()=>ye,gpt3Prediction:()=>pe,gpt3PredictionStream:()=>ue,inputSchema:()=>T,output:()=>R,outputSchema:()=>se,replaceString:()=>ae,stabilityClipGuidancePreset:()=>C,stabilityModel:()=>U,stabilityTextToImage:()=>ee,stringToArrayBuffer:()=>me,vercelGenericEdge:()=>G,whisperApi:()=>Se});module.exports=K(xe);async function R(n){return n}var x=class{constructor(e){this.nodes=e}static create(){return new x([])}node(e,t){let o=this.createDynamicPlaceholders("input"),i=this.nodes.length>0?this.nodes[this.nodes.length-1]:o,a={action:e,input:t({nodes:this.nodes,prev:i.output,input:o}),output:this.createDynamicPlaceholders(this.nodes.length)};return this.nodes.push(a),this}createDynamicPlaceholders(e){let t={},o={get:function(a,p){return`$context.${e}.${p}$`}};return new Proxy(t,o)}output(e){return this.node(R,e)}getNodes(){return this.nodes}};function O(n){return new Promise(e=>setTimeout(e,n))}function j(n,e){if(typeof n=="string")return i(n);let t={...n};return o(t);function o(r){let s={};for(let d in r)s[d]=i(r[d]);return s}function i(r){if(Array.isArray(r))return r.map(u=>o(u));if(typeof r=="object"&&r!==null)return o(r);let s=r,d=a(r);for(let u of d){let h=e[u.nodeId][u.property];if(h instanceof ArrayBuffer){s=h;continue}s=s?.replace(new RegExp(p(u.value)),h),s==="undefined"?s=void 0:s!==h&&s===h.toString()&&(s=h)}return s}function a(r){if(typeof r!="string")return[];let s=/\$context\.(\d+|input)\.(\w+)\$/g,d=r.matchAll(s),u=[];for(let f of d)u.push({value:f[0],nodeId:f[1],property:f[2]});return u}function p(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function I(n=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=t.length;for(let i=0;i<n;i++)e+=t.charAt(Math.floor(Math.random()*o));return e}var B=2,$=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=I(16);this.eventIndex=0;this.vercel={invoke:e=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e),invokeStream:(e,t)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t)};this.listenToEvents()}invoke(e,t=this.pipelineInstanceId){return this.processPipeline(e,t)}invokeRemote(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId})}).then(o=>o.json())}async invokeStream(e,t,o){let i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId})});if(!i.ok)throw new Error(i.statusText);let a=i.body;if(!a)return;let p=a.getReader(),r=new TextDecoder,s=!1;for(;!s;){let{value:d,done:u}=await p.read();s=u;let f=r.decode(d);o(f)}}onProgress(e){let t=I();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=I();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=I();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e,t){let o=this.conf.retries??B;try{if(this.notifyEvent({type:"pipeline:start",pipelineInstanceId:t}),this.conf.validateInput){let r=this.conf.validateInput(e);if(!r.valid)throw new Error(r.message)}let i={input:e},a={},p=this.flow.getNodes();for(let r=0;r<p.length;r++){this.notifyEvent({type:"node:start",pipelineInstanceId:t,data:{node:p[r].name,index:r}});let s=0,d=!1;do{s++;try{a=await this.executeAction(p,r,i),i[r]=a,d=!0}catch(u){if(s>o)throw u;await O((this.conf.retryDelayInMs??$)*s)}}while(!d&&s<=o);this.notifyEvent({type:"node:finish",pipelineInstanceId:t,data:{node:p[r].name,index:r}})}return this.notifyEvent({type:"pipeline:finish",pipelineInstanceId:t}),a}catch(i){throw console.error(i),i}}async executeAction(e,t,o){let{action:i,input:a}=e[t],p=j(a,o);return i(p,this.apiKeys)}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.pipelineInstanceId,{pipelineId:this.conf.id,eventIndex:this.eventIndex++,...e})}};var W=2,F=350,J=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,retries:t.retries??W,retryDelayInMs:t.retryDelayInMs??F,eventListener:n.eventListener,eventPublisher:n.eventPublisher},i=t.flow(new x([]));return new w(o,i,e)}}}};async function G(n,e){let{pipelineInstanceId:t,input:o}=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(o,t),pipeline:p}}var b=require("zod"),H=b.z.object({image:b.z.string()}),ze=b.z.object({labels:b.z.array(b.z.string())});async function V(n,e){let t=H.parse(n),o=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,i={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(o,{method:"POST",body:JSON.stringify(i)})).json()).responses[0].labelAnnotations.map(r=>r.description)}}var P=require("zod"),Y=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 q(n,e){let t=Y.parse(n),i=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 i.json();return{url:a[0].url}}var S=require("zod"),X=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 Z(n,e){let t=X.parse(n),i=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 i.json();return{result:a[0].b64_json}}var c=require("zod"),U=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=c.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),Q=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:U.default("stable-diffusion-v1-5"),clip_guidance_preset:C.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")}),Be=c.z.object({result:c.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)}),We=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 N=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},B=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of k(e))!M.call(n,i)&&i!==t&&N(n,i,{get:()=>e[i],enumerable:!(o=D(e,i))||o.enumerable});return n};var $=n=>B(N({},"__esModule",{value:!0}),n);var Pe={};K(Pe,{Pipeline:()=>I,createClient:()=>H,dalleBase64TextToImage:()=>ee,dalleUrlTextToImage:()=>Z,enhanceWithKeywords:()=>ae,googleImageLabeling:()=>q,googleTextToSpeech:()=>ge,gpt3Prediction:()=>ue,gpt3PredictionStream:()=>me,inputSchema:()=>T,output:()=>R,outputSchema:()=>ce,replaceString:()=>pe,stabilityClipGuidancePreset:()=>C,stabilityModel:()=>U,stabilityTextToImage:()=>ne,stringToArrayBuffer:()=>ye,vercelGenericEdge:()=>V,whisperApi:()=>be});module.exports=$(Pe);async function R(n){return n}var x=class{constructor(e){this.nodes=e}static create(){return new x([])}node(e,t){let o=this.createDynamicPlaceholders("input"),i=this.nodes.length>0?this.nodes[this.nodes.length-1]:o,a={action:e,input:t({nodes:this.nodes,prev:i.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(R,e)}getNodes(){return this.nodes}};function O(n){return new Promise(e=>setTimeout(e,n))}function j(n,e){if(typeof n=="string")return i(n);let t={...n};return o(t);function o(r){let s={};for(let p in r)s[p]=i(r[p]);return s}function i(r){if(Array.isArray(r))return r.map(d=>o(d));if(typeof r=="object"&&r!==null)return o(r);let s=r,p=a(r);for(let d of p){let y=e[d.nodeId][d.property];if(y instanceof ArrayBuffer){s=y;continue}s=s?.replace(new RegExp(c(d.value)),y),s==="undefined"?s=void 0:s!==y&&s===y.toString()&&(s=y)}return s}function a(r){if(typeof r!="string")return[];let s=/\$context\.(\d+|input)\.(\w+)\$/g,p=r.matchAll(s),d=[];for(let m of p)d.push({value:m[0],nodeId:m[1],property:m[2]});return d}function c(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function w(n=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=t.length;for(let i=0;i<n;i++)e+=t.charAt(Math.floor(Math.random()*o));return e}var W=2,F=350,I=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=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e),invokeStream:(e,t)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t)};this.listenToEvents()}invoke(e,t=this.pipelineInstanceId){return this.processPipeline(e,t)}invokeRemote(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId})}).then(o=>o.json())}async invokeStream(e,t,o){let i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId})});if(!i.ok)throw new Error(i.statusText);let a=i.body;if(!a)return;let c=a.getReader(),r=new TextDecoder,s=!1;for(;!s;){let{value:p,done:d}=await c.read();s=d;let m=r.decode(p);o(m)}}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,t){let o=this.conf.retries??W;try{let i=this.notifyEvent({type:"pipeline:start",pipelineInstanceId:t});if(this.conf.stream||await i,this.conf.validateInput){let p=this.conf.validateInput(e);if(!p.valid)throw new Error(p.message)}let a={input:e},c={},r=this.flow.getNodes();for(let p=0;p<r.length;p++){let d=this.notifyEvent({type:"node:start",pipelineInstanceId:t,data:{node:r[p].name,index:p}});this.conf.stream||await d;let m=0,y=!1;do{m++;try{c=await this.executeAction(r,p,a),a[p]=c,y=!0}catch(_){if(m>o)throw _;await O((this.conf.retryDelayInMs??F)*m)}}while(!y&&m<=o);let z=this.notifyEvent({type:"node:finish",pipelineInstanceId:t,data:{node:r[p].name,index:p}});this.conf.stream||await z}let s=this.notifyEvent({type:"pipeline:finish",pipelineInstanceId:t});return this.conf.stream||await s,c}catch(i){throw console.error(i),i}}async executeAction(e,t,o){let{action:i,input:a}=e[t],c=j(a,o);return i(c,this.apiKeys)}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.pipelineInstanceId,{pipelineId:this.conf.id,eventIndex:this.eventIndex++,...e})}};var J=2,G=350,H=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,retries:t.retries??J,retryDelayInMs:t.retryDelayInMs??G,eventListener:n.eventListener,eventPublisher:n.eventPublisher},i=t.flow(new x([]));return new I(o,i,e)}}}};async function V(n,e){let{pipelineInstanceId:t,input:o}=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"),c=n[a];return{output:await c.invoke(o,t),pipeline:c}}var b=require("zod"),Y=b.z.object({image:b.z.string()}),De=b.z.object({labels:b.z.array(b.z.string())});async function q(n,e){let t=Y.parse(n),o=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,i={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(o,{method:"POST",body:JSON.stringify(i)})).json()).responses[0].labelAnnotations.map(r=>r.description)}}var P=require("zod"),X=P.z.object({prompt:P.z.string(),size:P.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),Me=P.z.object({url:P.z.string().url()});async function Z(n,e){let t=X.parse(n),i=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 i.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")}),Be=S.z.object({result:S.z.string()});async function ee(n,e){let t=Q.parse(n),i=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 i.json();return{result:a[0].b64_json}}var u=require("zod"),U=u.z.enum(["stable-diffusion-v1-5","stable-diffusion-512-v2-0","stable-diffusion-768-v2-0","stable-diffusion-512-v2-1","stable-diffusion-768-v2-1"]),C=u.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),te=u.z.object({text_prompts:u.z.array(u.z.object({text:u.z.string(),weight:u.z.number().min(-1).max(1).default(1)})).refine(n=>n.length>0,"Must have at least one text prompt"),model:U.default("stable-diffusion-v1-5"),clip_guidance_preset:C.optional(),steps:u.z.number().min(0).max(150).optional(),sampler:u.z.enum(["DDIM","DDPM","K_DPMPP_2M","K_DPMPP_2S_ANCESTRAL","K_DPM_2","K_DPM_2_ANCESTRAL","K_EULER","K_EULER_ANCESTRAL","K_HEUN","K_LMS"]).optional(),cfg_scale:u.z.number().min(0).max(35).optional(),seed:u.z.number().min(0).optional(),height:u.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:u.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),We=u.z.object({result:u.z.instanceof(ArrayBuffer)});async function ne(n,e){let t=te.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"),oe=v.z.object({text:v.z.string(),amount:v.z.number().optional().default(8)}),Je=v.z.object({text:v.z.string()}),ie={"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(ie).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,n).join(", ")}
`).join(`
`)}async function ie(n){let e=te.parse(n);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${oe(e.amount)}
`)}async function ae(n){let e=oe.parse(n);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${re(e.amount)}
Title: ${e.text}
Description:`}}var g=require("zod"),re=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),Je=g.z.object({text:g.z.string()});async function ae(n){let e=re.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),T=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=T.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 L=require("eventsource-parser"),A=require("zod");var ce=T.merge(A.z.object({stream:A.z.literal(!0).optional().default(!0)})),Xe=A.z.object({stream:A.z.instanceof(globalThis.ReadableStream??Object)});async function ue(n,e){let t=ce.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 p(s){if(s.type==="event"){let d=s.data;if(d==="[DONE]"){a.close();return}try{let f=JSON.parse(d).choices[0].text;if(o<2&&(f.match(/\n/)||[]).length)return;let h=e.encode(f);a.enqueue(h),o++}catch(u){a.error(u)}}}let r=(0,L.createParser)(p);for await(let s of n.body)r.feed(t.decode(s))}})}var E=require("zod"),le=E.z.object({string:E.z.string()}),Qe=E.z.object({arrayBuffer:E.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 m=require("zod"),fe=m.z.object({text:m.z.string(),speakingRate:m.z.number().min(.25).max(4).optional().default(1),pitch:m.z.number().min(-20).max(20).optional().default(0),encoding:m.z.enum(["MP3","FLAC","LINEAR16","MULAW","AMR","AMR_WB","OGG_OPUS","SPEEX_WITH_HEADER_BYTE","WEBM_OPUS"]).optional().default("MP3"),voice:m.z.object({language:m.z.string().optional().default("en-US"),name:m.z.enum(["en-US-Standard-A","en-US-Standard-C","en-US-Standard-D","en-US-Standard-E","en-US-Standard-F","en-US-Standard-G","en-US-Standard-H","en-US-Standard-I","en-US-Standard-J","en-US-Studio-M","en-US-Studio-O","en-US-Wavenet-A","en-US-Wavenet-B","en-US-Wavenet-C","en-US-Wavenet-D","en-US-Wavenet-E","en-US-Wavenet-F","en-US-Wavenet-G","en-US-Wavenet-H","en-US-Wavenet-I","en-US-Wavenet-J","en-US-News-K","en-US-News-L","en-US-News-M","en-US-News-N","en-US-Standard-A","en-US-Standard-B","en-US-Standard-C","en-US-Standard-D","en-US-Standard-E","en-US-Standard-F","en-US-Standard-G","en-US-Standard-H","en-US-Standard-I","en-US-Standard-J"]).or(m.z.string()).optional().default("en-US-Neural2-C")}).optional().default({language:"en-US",name:"en-US-Neural2-C"})}),tt=m.z.object({audio:m.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}`,i={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(i)})).json()).audioContent}}var y=require("zod"),he="https://transcribe.whisperapi.com",ge=y.z.object({audioUrl:y.z.string().url(),language:y.z.string().default("en"),autoDetectLanguage:y.z.boolean().default(!1),fileType:y.z.string().default("mp3"),task:y.z.enum(["transcribe","translate"]).default("transcribe")}),ot=y.z.object({text:y.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 i=await fetch(he,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:o});if(!i.ok)throw new Error(i.statusText);return{text:(await i.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"),se=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),He=g.z.object({text:g.z.string()});async function pe(n){let e=se.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),T=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)}),ce=l.z.object({text:l.z.string()});async function ue(n,e){let t=T.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 L=require("eventsource-parser"),A=require("zod");var de=T.merge(A.z.object({stream:A.z.literal(!0).optional().default(!0)})),Qe=A.z.object({stream:A.z.instanceof(globalThis.ReadableStream??Object)});async function me(n,e){let t=de.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 le(o)}}async function le(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(d){a.error(d)}}}let r=(0,L.createParser)(c);for await(let s of n.body)r.feed(t.decode(s))}})}var E=require("zod"),fe=E.z.object({string:E.z.string()}),tt=E.z.object({arrayBuffer:E.z.instanceof(ArrayBuffer)});async function ye(n){let e=fe.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var f=require("zod"),he=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"})}),ot=f.z.object({audio:f.z.string()});async function ge(n,e){let t=he.parse(n),o=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,i={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(i)})).json()).audioContent}}var h=require("zod"),Se="https://transcribe.whisperapi.com",xe=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")}),rt=h.z.object({text:h.z.string()});async function be(n,e){let t=xe.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 i=await fetch(Se,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:o});if(!i.ok)throw new Error(i.statusText);return{text:(await i.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": "1.0.1",
"version": "1.0.2",
"description": "",

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

@@ -131,3 +131,6 @@ import { FlowBuilder } from './builder';

try {
this.notifyEvent({ type: 'pipeline:start', pipelineInstanceId });
const pipelineStartPromise = this.notifyEvent({ type: 'pipeline:start', pipelineInstanceId });
if (!this.conf.stream) {
await pipelineStartPromise;
}
if (this.conf.validateInput) {

@@ -145,3 +148,3 @@ const result = this.conf.validateInput(input);

for (let i = 0; i < nodes.length; i++) {
this.notifyEvent({
const nodeStartPromise = this.notifyEvent({
type: 'node:start',

@@ -154,2 +157,5 @@ pipelineInstanceId,

});
if (!this.conf.stream) {
await nodeStartPromise;
}
let attemptCount = 0;

@@ -170,3 +176,3 @@ let isSuccess = false;

} while (!isSuccess && attemptCount <= retriesCount);
this.notifyEvent({
const nodeEndPromise = this.notifyEvent({
type: 'node:finish',

@@ -179,4 +185,13 @@ pipelineInstanceId,

});
if (!this.conf.stream) {
await nodeEndPromise;
}
}
this.notifyEvent({ type: 'pipeline:finish', pipelineInstanceId });
const pipelineFinishPromise = this.notifyEvent({
type: 'pipeline:finish',
pipelineInstanceId,
});
if (!this.conf.stream) {
await pipelineFinishPromise;
}
return output;

@@ -183,0 +198,0 @@ } catch (e) {

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