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.1.0 to 1.2.0

src/vercelEdgeFunction.ts

6

CHANGELOG.md
# @aigur/client
## 1.2.0
### Minor Changes
- 15d51cf1: Better Vercel helpers
## 1.1.0

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

14

dist/index.d.ts

@@ -149,7 +149,2 @@ import { z } from 'zod';

declare function vercelGenericEdge(pipelines: any, req: any): Promise<Response | {
output: any;
pipeline: any;
}>;
declare const inputSchema$b: z.ZodObject<{

@@ -499,2 +494,9 @@ image: z.ZodString;

export { Aigur, Pipeline, createClient, dalleBase64TextToImage, dalleUrlTextToImage, enhanceWithKeywords, googleImageLabeling, googleTextToSpeech, gpt3Prediction, gpt3PredictionStream, inputSchema$4 as inputSchema, output, outputSchema$4 as outputSchema, replaceMultipleStrings, replaceString, stabilityClipGuidancePreset, stabilityModel, stabilityTextToImage, stringToArrayBuffer, vercelGenericEdge, whisperApi };
declare function vercelEdgeFunction(pipelines: Record<string, Pipeline<any, any, any>>): (req: any) => Promise<Response>;
declare function vercelGenericEdge(pipelines: any, req: any): Promise<Response | {
output: any;
pipeline: any;
}>;
export { Aigur, Pipeline, createClient, dalleBase64TextToImage, dalleUrlTextToImage, enhanceWithKeywords, googleImageLabeling, googleTextToSpeech, gpt3Prediction, gpt3PredictionStream, inputSchema$4 as inputSchema, output, outputSchema$4 as outputSchema, replaceMultipleStrings, replaceString, stabilityClipGuidancePreset, stabilityModel, stabilityTextToImage, stringToArrayBuffer, vercelEdgeFunction, vercelGenericEdge, whisperApi };

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

var C=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var F=(n,e)=>{for(var t in e)C(n,t,{get:e[t],enumerable:!0})},J=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of B(e))!W.call(n,r)&&r!==t&&C(n,r,{get:()=>e[r],enumerable:!(o=$(e,r))||o.enumerable});return n};var V=n=>J(C({},"__esModule",{value:!0}),n);var Te={};F(Te,{Pipeline:()=>w,createClient:()=>Q,dalleBase64TextToImage:()=>oe,dalleUrlTextToImage:()=>ie,enhanceWithKeywords:()=>de,googleImageLabeling:()=>te,googleTextToSpeech:()=>we,gpt3Prediction:()=>ge,gpt3PredictionStream:()=>xe,inputSchema:()=>D,output:()=>O,outputSchema:()=>he,replaceMultipleStrings:()=>le,replaceString:()=>ye,stabilityClipGuidancePreset:()=>_,stabilityModel:()=>z,stabilityTextToImage:()=>se,stringToArrayBuffer:()=>ve,vercelGenericEdge:()=>Z,whisperApi:()=>Ae});module.exports=V(Te);function j(n){return new Promise(e=>setTimeout(e,n))}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=E(i);for(let s of p){let d=e[s.nodeId].output;if(d==null)continue;let c=d[s.property];if(c instanceof ArrayBuffer){a=c;continue}a=a?.replace(new RegExp(r(s.value)),c),a==="undefined"?a=void 0:a!==c&&a===c.toString()&&(a=c)}return a}function r(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function E(n){if(typeof n!="string")return[];let e=/\$context\.(\d+|input|memory)\.(\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 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 U(n){let e={input:{input:n.input,output:n.input},memory:{input:n.memory,output:n.memory}};return{pipelineInstanceId:n.pipelineInstanceId,input:n.input,output:{},values:e,memory:n.memory,userId:n.userId}}async function L(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=E(t[r]),[s,d]=a.tee();n.values[p[0].nodeId].output=s;let c=await G(d);o[i]=c}}return o}function G(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)})}var H=2,Y=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=U({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,d=!1;for(;!d;){let{value:c,done:y}=await p.read();d=y;let v=s.decode(c);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??H;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,d=!1;do{s++;try{let{action:y,input:v,memoryToSave:De}=r[a],R=e.values[a]={input:null,output:null};R.input=A(v,e.values),R.output=await y(R.input,this.apiKeys);let K=L(e,r[a]);this.saveMemory(e,K),d=!0}catch(y){if(s>t)throw y;await j((this.conf.retryDelayInMs??Y)*s)}}while(!d&&s<=t);let c=this.notifyEvent({type:"node:finish",context:e,data:{node:r[a].action.name,index:a}});this.conf.stream||await c}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 O(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={action:e,input:t({nodes:this.nodes,prev:p.output,input:i,memory:r}),output:this.createDynamicPlaceholders(this.nodes.length),memoryToSave:o?o({nodes:this.nodes,prev:p.output,output:a,input:i,memory:r}):null};return this.nodes.push(s),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(O,e,t)}getNodes(){return this.nodes}};var q=2,X=350,Q=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??q,retryDelayInMs:t.retryDelayInMs??X,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new T([]));return new w(o,r,e)}}}};async function Z(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}}var x=require("zod"),ee=x.z.object({image:x.z.string()}),qe=x.z.object({labels:x.z.array(x.z.string())});async function te(n,e){let t=ee.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"),ne=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")}),Qe=S.z.object({result:S.z.string()});async function oe(n,e){let t=ne.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"),re=I.z.object({prompt:I.z.string(),size:I.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),et=I.z.object({url:I.z.string().url()});async function ie(n,e){let t=re.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 u=require("zod"),z=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"]),_=u.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),ae=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:z.default("stable-diffusion-v1-5"),clip_guidance_preset:_.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")}),nt=u.z.object({result:u.z.instanceof(ArrayBuffer)});async function se(n,e){let t=ae.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 P=require("zod"),pe=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),rt=P.z.object({text:P.z.string()}),ue={"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 ce(n){return Object.entries(ue).map(([e,t])=>`Title: ${e}
var E=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var J=(n,e)=>{for(var t in e)E(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of F(e))!W.call(n,r)&&r!==t&&E(n,r,{get:()=>e[r],enumerable:!(o=B(e,r))||o.enumerable});return n};var G=n=>V(E({},"__esModule",{value:!0}),n);var Re={};J(Re,{Pipeline:()=>w,createClient:()=>Z,dalleBase64TextToImage:()=>oe,dalleUrlTextToImage:()=>ie,enhanceWithKeywords:()=>de,googleImageLabeling:()=>te,googleTextToSpeech:()=>we,gpt3Prediction:()=>ge,gpt3PredictionStream:()=>xe,inputSchema:()=>R,output:()=>O,outputSchema:()=>he,replaceMultipleStrings:()=>le,replaceString:()=>ye,stabilityClipGuidancePreset:()=>k,stabilityModel:()=>_,stabilityTextToImage:()=>se,stringToArrayBuffer:()=>ve,vercelEdgeFunction:()=>Ae,vercelGenericEdge:()=>j,whisperApi:()=>Te});module.exports=G(Re);function U(n){return new Promise(e=>setTimeout(e,n))}function T(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=C(i);for(let s of p){let d=e[s.nodeId].output;if(d==null)continue;let c=d[s.property];if(c instanceof ArrayBuffer){a=c;continue}a=a?.replace(new RegExp(r(s.value)),c),a==="undefined"?a=void 0:a!==c&&a===c.toString()&&(a=c)}return a}function r(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function C(n){if(typeof n!="string")return[];let e=/\$context\.(\d+|input|memory)\.(\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 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 L(n){let e={input:{input:n.input,output:n.input},memory:{input:n.memory,output:n.memory}};return{pipelineInstanceId:n.pipelineInstanceId,input:n.input,output:{},values:e,memory:n.memory,userId:n.userId}}async function z(n,e){let{memoryToSave:t}=e;if(!t)return;let o=T(t,n.values);for(let r in t)for(let i in o){let a=o[i];if(a instanceof ReadableStream){let p=C(t[r]),[s,d]=a.tee();n.values[p[0].nodeId].output=s;let c=await H(d);o[i]=c}}return o}function H(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)})}var Y=2,q=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,d=!1;for(;!d;){let{value:c,done:y}=await p.read();d=y;let v=s.decode(c);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??Y;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,d=!1;do{s++;try{let{action:y,input:v,memoryToSave:De}=r[a],D=e.values[a]={input:null,output:null};D.input=T(v,e.values),D.output=await y(D.input,this.apiKeys);let $=z(e,r[a]);this.saveMemory(e,$),d=!0}catch(y){if(s>t)throw y;await U((this.conf.retryDelayInMs??q)*s)}}while(!d&&s<=t);let c=this.notifyEvent({type:"node:finish",context:e,data:{node:r[a].action.name,index:a}});this.conf.stream||await c}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 O(n){return n}var A=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={action:e,input:t({nodes:this.nodes,prev:p.output,input:i,memory:r}),output:this.createDynamicPlaceholders(this.nodes.length),memoryToSave:o?o({nodes:this.nodes,prev:p.output,output:a,input:i,memory:r}):null};return this.nodes.push(s),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(O,e,t)}getNodes(){return this.nodes}};var X=2,Q=350,Z=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??X,retryDelayInMs:t.retryDelayInMs??Q,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new A([]));return new w(o,r,e)}}}};var x=require("zod"),ee=x.z.object({image:x.z.string()}),qe=x.z.object({labels:x.z.array(x.z.string())});async function te(n,e){let t=ee.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"),ne=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")}),Qe=S.z.object({result:S.z.string()});async function oe(n,e){let t=ne.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"),re=I.z.object({prompt:I.z.string(),size:I.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),et=I.z.object({url:I.z.string().url()});async function ie(n,e){let t=re.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 u=require("zod"),_=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"]),k=u.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),ae=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:_.default("stable-diffusion-v1-5"),clip_guidance_preset:k.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")}),nt=u.z.object({result:u.z.instanceof(ArrayBuffer)});async function se(n,e){let t=ae.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 P=require("zod"),pe=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),rt=P.z.object({text:P.z.string()}),ue={"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 ce(n){return Object.entries(ue).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,n).join(", ")}

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

Title: ${e.text}
Description:`}}var h=require("zod"),me=h.z.object({strings:h.z.record(h.z.string(),h.z.string()),modifier:h.z.string()}),at=h.z.object({text:h.z.string()});async function le(n){let e=me.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"),fe=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),pt=g.z.object({text:g.z.string()});async function ye(n){let e=fe.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)}),he=m.z.object({text:m.z.string()});async function ge(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"),N=require("zod");var Se=D.merge(N.z.object({stream:N.z.literal(!0).optional().default(!0)})),ft=N.z.object({stream:N.z.instanceof(globalThis.ReadableStream??Object)});async function xe(n,e){let t=Se.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 Ie(o)}}async function Ie(n){let e=new TextEncoder,t=new TextDecoder,o=0;return new ReadableStream({async start(i){function a(s){if(s.type==="event"){let d=s.data;if(d==="[DONE]"){i.close();return}try{let y=JSON.parse(d).choices[0].text;if(o<2&&(y.match(/\n/)||[]).length)return;let v=e.encode(y);i.enqueue(v),o++}catch(c){i.error(c)}}}let p=(0,k.createParser)(a);for await(let s of n.body)p.feed(t.decode(s))}})}var M=require("zod"),Pe=M.z.object({string:M.z.string()}),ht=M.z.object({arrayBuffer:M.z.instanceof(ArrayBuffer)});async function ve(n){let e=Pe.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var l=require("zod"),be=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"})}),St=l.z.object({audio:l.z.string()});async function we(n,e){let t=be.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"),Ne="https://transcribe.whisperapi.com",Me=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")}),It=f.z.object({text:f.z.string()});async function Ae(n,e){let t=Me.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(Ne,{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,replaceMultipleStrings,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelGenericEdge,whisperApi});
Description:`}}var h=require("zod"),me=h.z.object({strings:h.z.record(h.z.string(),h.z.string()),modifier:h.z.string()}),at=h.z.object({text:h.z.string()});async function le(n){let e=me.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"),fe=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),pt=g.z.object({text:g.z.string()});async function ye(n){let e=fe.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var m=require("zod"),R=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)}),he=m.z.object({text:m.z.string()});async function ge(n,e){let t=R.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"),N=require("zod");var Se=R.merge(N.z.object({stream:N.z.literal(!0).optional().default(!0)})),ft=N.z.object({stream:N.z.instanceof(globalThis.ReadableStream??Object)});async function xe(n,e){let t=Se.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 Ie(o)}}async function Ie(n){let e=new TextEncoder,t=new TextDecoder,o=0;return new ReadableStream({async start(i){function a(s){if(s.type==="event"){let d=s.data;if(d==="[DONE]"){i.close();return}try{let y=JSON.parse(d).choices[0].text;if(o<2&&(y.match(/\n/)||[]).length)return;let v=e.encode(y);i.enqueue(v),o++}catch(c){i.error(c)}}}let p=(0,K.createParser)(a);for await(let s of n.body)p.feed(t.decode(s))}})}var M=require("zod"),Pe=M.z.object({string:M.z.string()}),ht=M.z.object({arrayBuffer:M.z.instanceof(ArrayBuffer)});async function ve(n){let e=Pe.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var l=require("zod"),be=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"})}),St=l.z.object({audio:l.z.string()});async function we(n,e){let t=be.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"),Ne="https://transcribe.whisperapi.com",Me=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")}),It=f.z.object({text:f.z.string()});async function Te(n,e){let t=Me.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(Ne,{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 j(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 Ae(n){return async e=>{let t=await j(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,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.1.0",
"version": "1.2.0",
"description": "",

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

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

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