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.9.0 to 1.9.1

9

CHANGELOG.md
# @aigur/client
## 1.9.1
### Patch Changes
- f6274fb3: Export hf
- f6274fb3: configure hf package to be imported from source
- Updated dependencies [f6274fb3]
- @aigur/huggingface@0.0.12
## 1.9.0

@@ -4,0 +13,0 @@

1

dist/index.d.ts

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

export * from '@aigur/huggingface';
import { z } from 'zod';

@@ -2,0 +3,0 @@

8

dist/index.js

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

var j=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ce=(n,e)=>{for(var t in e)j(n,t,{get:e[t],enumerable:!0})},me=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pe(e))!ue.call(n,r)&&r!==t&&j(n,r,{get:()=>e[r],enumerable:!(o=se(e,r))||o.enumerable});return n};var de=n=>me(j({},"__esModule",{value:!0}),n);var Be={};ce(Be,{Pipeline:()=>T,cleanContextVars:()=>G,createClient:()=>xe,dalleBase64TextToImage:()=>F,dalleUrlTextToImage:()=>J,enhanceWithKeywords:()=>q,googleImageLabeling:()=>W,googleTextToSpeech:()=>re,gpt3Prediction:()=>X,gpt3PredictionStream:()=>ne,gpt3TurboPrediction:()=>Q,gpt3TurboPredictionStream:()=>ee,output:()=>C,replaceMultipleStrings:()=>H,replaceString:()=>Y,stabilityTextToImage:()=>V,stringToArrayBuffer:()=>oe,vercelEdgeFunction:()=>$e,vercelGenericEdge:()=>k,whisperApi:()=>ae});module.exports=de(Be);function K(n){return new Promise(e=>setTimeout(e,n))}function D(n,e){if(typeof n=="string")return o(n);return t({...n});function t(a){let i={};for(let p in a)i[p]=o(a[p]);return i}function o(a){if(Array.isArray(a))return a.map(s=>t(s));if(typeof a=="object"&&a!==null)return t(a);let i=a,p=z(a);for(let s of p){let u=e[s.nodeId].output;if(u==null)continue;let c=u[s.property];if(c instanceof ArrayBuffer){i=c;continue}i=i?.replace(new RegExp(r(s.value)),c),i==="undefined"?i=void 0:i!==c&&i===c.toString()&&(i=c)}return i}function r(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function z(n){if(typeof n!="string")return[];let e=/\$context\.(\d+|input|memory|pipeline)\.(\w+)\$/g,t=n.matchAll(e),o=[];for(let r of t)o.push({value:r[0],nodeId:r[1],property:r[2]});return o}function w(n=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=t.length;for(let r=0;r<n;r++)e+=t.charAt(Math.floor(Math.random()*o));return e}function $(n){let e={input:{input:n.input,output:n.input},memory:{input:n.memory,output:n.memory},pipeline:{input:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId},output:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId}}};return{pipelineInstanceId:n.pipelineInstanceId,input:n.input,output:{},values:e,memory:n.memory,userId:n.userId}}async function B(n,e){let{memoryToSave:t}=e;if(!t)return;let o=D(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let p=z(t[r]),[s,u]=i.tee();n.values[p[0].nodeId].output=s;let c=await le(u);o[a]=c}}return o}function le(n){return new Promise(async e=>{let t=n.getReader(),o=new TextDecoder,r=!1,a="";for(;!r;){let{value:i,done:p}=await t.read();r=p;let s=o.decode(i);a+=s}e(a)})}var fe=2,ye=350,T=class{constructor(e,t,o){this.conf=e;this.flow=t;this.apiKeys=o;this.onProgressListeners=new Map;this.onStartListeners=new Map;this.onFinishListeners=new Map;this.pipelineInstanceId=w(16);this.eventIndex=0;this.vercel={invoke:(e,t)=>this.invokeRemote(`/api/pipelines/${this.conf.id}`,e,{userId:t?.userId}),invokeStream:(e,t,o)=>this.invokeStream(`/api/pipelines/${this.conf.id}`,e,t,{userId:o?.userId})};this.listenToEvents()}async invoke(e,t){let o=await this.loadMemory(t?.userId),r=$({input:e,pipelineInstanceId:t?.pipelineInstanceId??this.pipelineInstanceId,userId:t?.userId??"",memory:o});return await this.processPipeline(r),r.output}async saveMemory(e,t){let o=await t;!this.conf.memoryManager||!o||this.conf.memoryManager.saveMemory(this.getMemoryId(e.userId),o)}getMemoryId(e){return`${this.conf.id}${e?`-${e}`:""}`}loadMemory(e){return this.conf.memoryManager?this.conf.memoryManager.loadMemory(this.getMemoryId(e)):Promise.resolve(null)}invokeRemote(e,t,o){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:o?.userId??""})}).then(r=>r.json())}async invokeStream(e,t,o,r){let a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:r?.userId??""})});if(!a.ok)throw new Error(a.statusText);let i=a.body;if(!i)return;let p=i.getReader(),s=new TextDecoder,u=!1;for(;!u;){let{value:c,done:y}=await p.read();u=y;let v=s.decode(c);o(v)}}onProgress(e){let t=w();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=w();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=w();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??fe;try{let o=this.notifyEvent({type:"pipeline:start",context:e});if(this.conf.stream||await o,this.conf.validateInput){let i=this.conf.validateInput(e.input);if(!i.valid)throw new Error(i.message)}let r=this.flow.getNodes();for(let i=0;i<r.length;i++){let p=this.notifyEvent({type:"node:start",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await p;let s=0,u=!1;do{s++;try{let{action:y,input:v}=r[i],O=e.values[i]={input:null,output:null};O.input=D(v,e.values),O.output=await y(O.input,this.apiKeys);let ie=B(e,r[i]);this.saveMemory(e,ie),u=!0}catch(y){if(s>t)throw y;await K((this.conf.retryDelayInMs??ye)*s)}}while(!u&&s<=t);let c=this.notifyEvent({type:"node:finish",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await c}e.output=e.values[r.length-1].output;let a=this.notifyEvent({type:"pipeline:finish",context:e,data:{output:e.output instanceof ReadableStream?"Stream":e.output}});return this.conf.stream||await a,e}catch(o){throw console.error(o),o}}listenToEvents(){!this.conf.updateProgress||typeof window>"u"||!this.conf.eventListener||this.conf.eventListener(this.pipelineInstanceId,e=>{e.pipelineId===this.conf.id&&(e.type==="node:start"||e.type==="node:finish"?this.triggerListeners(this.onProgressListeners,e):e.type==="pipeline:start"?this.triggerListeners(this.onStartListeners,e):e.type==="pipeline:finish"&&this.triggerListeners(this.onFinishListeners,e))})}triggerListeners(e,...t){for(let o of e.values())o(...t)}notifyEvent(e){if(!(!this.conf.updateProgress||!this.conf.eventPublisher))return this.conf.eventPublisher(e.context.pipelineInstanceId,{pipelineId:this.conf.id,eventIndex:this.eventIndex++,type:e.type,data:e.data})}};async function C(n){return n}var E=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(C,e,t)}getNodes(){return this.nodes}};var he=2,ge=350,xe=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??he,retryDelayInMs:t.retryDelayInMs??ge,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new E([]));return new T(o,r,e)}}}};var I=require("zod"),Se=I.z.object({image:I.z.string()}),pt=I.z.object({labels:I.z.array(I.z.string())});async function W(n,e){let t=Se.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"),Ie=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")}),ct=S.z.object({result:S.z.string()});async function F(n,e){let t=Ie.parse(n),r=await fetch("https://api.openai.com/v1/images/generations",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)}),{data:a}=await r.json();return{result:a[0].b64_json}}var b=require("zod"),be=b.z.object({prompt:b.z.string(),size:b.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),dt=b.z.object({url:b.z.string().url()});async function J(n,e){let t=be.parse(n),r=await fetch("https://api.openai.com/v1/images/generations",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)}),{data:a}=await r.json();return{url:a[0].url}}var m=require("zod"),Pe=m.z.enum(["stable-diffusion-v1-5","stable-diffusion-512-v2-0","stable-diffusion-768-v2-0","stable-diffusion-512-v2-1","stable-diffusion-768-v2-1"]),ve=m.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),we=m.z.object({text_prompts:m.z.array(m.z.object({text:m.z.string(),weight:m.z.number().min(-1).max(1).default(1)})).refine(n=>n.length>0,"Must have at least one text prompt"),model:Pe.default("stable-diffusion-v1-5"),clip_guidance_preset:ve.optional(),steps:m.z.number().min(0).max(150).optional(),sampler:m.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:m.z.number().min(0).max(35).optional(),seed:m.z.number().min(0).optional(),height:m.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:m.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),ft=m.z.object({result:m.z.instanceof(ArrayBuffer)});async function V(n,e){let t=we.parse(n),o=`https://api.stability.ai/v1beta/generation/${t.model}/text-to-image`;return{result:await(await fetch(o,{headers:{"Content-Type":"application/json",Accept:"image/png",Authorization:e.stability},method:"POST",body:JSON.stringify(t)})).arrayBuffer()}}var A=require("zod"),Te=A.z.object({text:A.z.string()}),ht=A.z.object({text:A.z.string()});async function G(n){return{text:Te.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var P=require("zod"),Ae=P.z.object({text:P.z.string(),amount:P.z.number().optional().default(8)}),xt=P.z.object({text:P.z.string()}),Ne={"Colonial-style home":"Colonial, traditional, classic, historical, timeless, elegant, regal, grand, spacious, architectural, wood-framed, brick-exterior, symmetrical, gabled roof, columns, portico, fireplace, formal, ornate, landscaped".split(", "),"High-end penthouse apartment":"Luxury, high-end, penthouse, apartment, upscale, contemporary, modern, stylish, designer, elite, high-rise, rooftop, panoramic, views, spacious, open-plan, top-floor, amenities, concierge, service, exclusive".split(", ")};function Re(n){return Object.entries(Ne).map(([e,t])=>`Title: ${e}
var L=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var le=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},U=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of me(e))!de.call(n,r)&&r!==t&&L(n,r,{get:()=>e[r],enumerable:!(o=ce(e,r))||o.enumerable});return n},x=(n,e,t)=>(U(n,e,"default"),t&&U(t,e,"default"));var fe=n=>U(L({},"__esModule",{value:!0}),n);var g={};le(g,{Pipeline:()=>N,cleanContextVars:()=>Y,createClient:()=>Ie,dalleBase64TextToImage:()=>G,dalleUrlTextToImage:()=>q,enhanceWithKeywords:()=>X,googleImageLabeling:()=>V,googleTextToSpeech:()=>se,gpt3Prediction:()=>ee,gpt3PredictionStream:()=>ae,gpt3TurboPrediction:()=>te,gpt3TurboPredictionStream:()=>oe,output:()=>O,replaceMultipleStrings:()=>Q,replaceString:()=>Z,stabilityTextToImage:()=>H,stringToArrayBuffer:()=>ie,vercelEdgeFunction:()=>We,vercelGenericEdge:()=>B,whisperApi:()=>pe});module.exports=fe(g);x(g,require("@aigur/huggingface"),module.exports);function W(n){return new Promise(e=>setTimeout(e,n))}function E(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=_(a);for(let s of p){let u=e[s.nodeId].output;if(u==null)continue;let c=u[s.property];if(c instanceof ArrayBuffer){i=c;continue}i=i?.replace(new RegExp(r(s.value)),c),i==="undefined"?i=void 0:i!==c&&i===c.toString()&&(i=c)}return i}function r(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function _(n){if(typeof n!="string")return[];let e=/\$context\.(\d+|input|memory|pipeline)\.(\w+)\$/g,t=n.matchAll(e),o=[];for(let r of t)o.push({value:r[0],nodeId:r[1],property:r[2]});return o}function A(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 F(n){let e={input:{input:n.input,output:n.input},memory:{input:n.memory,output:n.memory},pipeline:{input:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId},output:{pipelineInstanceId:n.pipelineInstanceId,userId:n.userId}}};return{pipelineInstanceId:n.pipelineInstanceId,input:n.input,output:{},values:e,memory:n.memory,userId:n.userId}}async function J(n,e){let{memoryToSave:t}=e;if(!t)return;let o=E(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let p=_(t[r]),[s,u]=i.tee();n.values[p[0].nodeId].output=s;let c=await ye(u);o[a]=c}}return o}function ye(n){return new Promise(async e=>{let t=n.getReader(),o=new TextDecoder,r=!1,a="";for(;!r;){let{value:i,done:p}=await t.read();r=p;let s=o.decode(i);a+=s}e(a)})}var he=2,ge=350,N=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=A(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=F({input:e,pipelineInstanceId:t?.pipelineInstanceId??this.pipelineInstanceId,userId:t?.userId??"",memory:o});return await this.processPipeline(r),r.output}async saveMemory(e,t){let o=await t;!this.conf.memoryManager||!o||this.conf.memoryManager.saveMemory(this.getMemoryId(e.userId),o)}getMemoryId(e){return`${this.conf.id}${e?`-${e}`:""}`}loadMemory(e){return this.conf.memoryManager?this.conf.memoryManager.loadMemory(this.getMemoryId(e)):Promise.resolve(null)}invokeRemote(e,t,o){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:o?.userId??""})}).then(r=>r.json())}async invokeStream(e,t,o,r){let a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,pipelineInstanceId:this.pipelineInstanceId,userId:r?.userId??""})});if(!a.ok)throw new Error(a.statusText);let i=a.body;if(!i)return;let p=i.getReader(),s=new TextDecoder,u=!1;for(;!u;){let{value:c,done:y}=await p.read();u=y;let T=s.decode(c);o(T)}}onProgress(e){let t=A();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=A();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=A();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??he;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:T}=r[i],z=e.values[i]={input:null,output:null};z.input=E(T,e.values),z.output=await y(z.input,this.apiKeys);let ue=J(e,r[i]);this.saveMemory(e,ue),u=!0}catch(y){if(s>t)throw y;await W((this.conf.retryDelayInMs??ge)*s)}}while(!u&&s<=t);let c=this.notifyEvent({type:"node:finish",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await c}e.output=e.values[r.length-1].output;let a=this.notifyEvent({type:"pipeline:finish",context:e,data:{output:e.output instanceof ReadableStream?"Stream":e.output}});return this.conf.stream||await a,e}catch(o){throw console.error(o),o}}listenToEvents(){!this.conf.updateProgress||typeof window>"u"||!this.conf.eventListener||this.conf.eventListener(this.pipelineInstanceId,e=>{e.pipelineId===this.conf.id&&(e.type==="node:start"||e.type==="node:finish"?this.triggerListeners(this.onProgressListeners,e):e.type==="pipeline:start"?this.triggerListeners(this.onStartListeners,e):e.type==="pipeline:finish"&&this.triggerListeners(this.onFinishListeners,e))})}triggerListeners(e,...t){for(let o of e.values())o(...t)}notifyEvent(e){if(!(!this.conf.updateProgress||!this.conf.eventPublisher))return this.conf.eventPublisher(e.context.pipelineInstanceId,{pipelineId:this.conf.id,eventIndex:this.eventIndex++,type:e.type,data:e.data})}};async function O(n){return n}var j=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(O,e,t)}getNodes(){return this.nodes}};var xe=2,Se=350,Ie=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??xe,retryDelayInMs:t.retryDelayInMs??Se,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new j([]));return new N(o,r,e)}}}};var P=require("zod"),be=P.z.object({image:P.z.string()}),ut=P.z.object({labels:P.z.array(P.z.string())});async function V(n,e){let t=be.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 b=require("zod"),Pe=b.z.object({prompt:b.z.string(),response_format:b.z.literal("b64_json").default("b64_json"),size:b.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),mt=b.z.object({result:b.z.string()});async function G(n,e){let t=Pe.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 v=require("zod"),ve=v.z.object({prompt:v.z.string(),size:v.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),lt=v.z.object({url:v.z.string().url()});async function q(n,e){let t=ve.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 m=require("zod"),we=m.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"]),Te=m.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),Ae=m.z.object({text_prompts:m.z.array(m.z.object({text:m.z.string(),weight:m.z.number().min(-1).max(1).default(1)})).refine(n=>n.length>0,"Must have at least one text prompt"),model:we.default("stable-diffusion-v1-5"),clip_guidance_preset:Te.optional(),steps:m.z.number().min(0).max(150).optional(),sampler:m.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:m.z.number().min(0).max(35).optional(),seed:m.z.number().min(0).optional(),height:m.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:m.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),yt=m.z.object({result:m.z.instanceof(ArrayBuffer)});async function H(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 R=require("zod"),Ne=R.z.object({text:R.z.string()}),gt=R.z.object({text:R.z.string()});async function Y(n){return{text:Ne.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var w=require("zod"),Re=w.z.object({text:w.z.string(),amount:w.z.number().optional().default(8)}),St=w.z.object({text:w.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 De(n){return Object.entries(Me).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,n).join(", ")}
`).join(`
`)}async function q(n){let e=Ae.parse(n);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${Re(e.amount)}
`)}async function X(n){let e=Re.parse(n);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${De(e.amount)}
Title: ${e.text}
Description:`}}var g=require("zod"),Me=g.z.object({strings:g.z.record(g.z.string(),g.z.string()),modifier:g.z.string()}),It=g.z.object({text:g.z.string()});async function H(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 x=require("zod"),De=x.z.object({text:x.z.string().or(x.z.array(x.z.string())),modifier:x.z.string()}),Pt=x.z.object({text:x.z.string()});async function Y(n){let e=De.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),U=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","gpt-3.5-turbo"]).default("gpt-3.5-turbo"),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)}).strict(),L=n=>{if(n.model==="gpt-3.5-turbo"){let{prompt:e,...t}=n;return{...t,messages:[{role:"user",content:n.prompt}]}}return n},Ce=U.transform(n=>L(n)),wt=l.z.object({text:l.z.string()});async function X(n,e){let t=Ce.parse(n),o=t.model==="gpt-3.5-turbo"?"https://api.openai.com/v1/chat/completions":"https://api.openai.com/v1/completions",a=await(await fetch(o,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)})).json();return{text:(t.model==="gpt-3.5-turbo"?a.choices[0]?.message.content:a.choices[0].text).replace(/^(?:\n)+/gm,"")}}var d=require("zod"),_=d.z.object({messages:d.z.array(d.z.object({role:d.z.enum(["user","system","assistant"]),content:d.z.string()})).nonempty(),model:d.z.enum(["gpt-3.5-turbo"]).default("gpt-3.5-turbo"),temperature:d.z.number().min(0).max(2).default(.7),top_p:d.z.number().min(0).max(1).default(1),frequency_penalty:d.z.number().min(-2).max(2).default(0),presence_penalty:d.z.number().min(-2).max(2).default(0),max_tokens:d.z.number().default(200),n:d.z.number().default(1)}),At=d.z.object({text:d.z.string()});async function Q(n,e){let t=_.parse(n);return{text:(await(await fetch("https://api.openai.com/v1/chat/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)})).json()).choices[0]?.message.content.replace(/^(?:\n)+/gm,"")}}var Z=require("eventsource-parser"),N=require("zod");var Ee=_.merge(N.z.object({stream:N.z.literal(!0).optional().default(!0)})),Ct=N.z.object({stream:N.z.instanceof(globalThis.ReadableStream??Object)});async function ee(n,e){let t=Ee.parse(n),o=await fetch("https://api.openai.com/v1/chat/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)});return{stream:await Oe(o)}}async function Oe(n){let e=new TextEncoder,t=new TextDecoder;return new ReadableStream({async start(r){function a(p){if(p.type==="event"){let s=p.data;if(s==="[DONE]"){r.close();return}try{let c=JSON.parse(s).choices[0]?.delta.content,y=e.encode(c);r.enqueue(y)}catch(u){r.error(u)}}}let i=(0,Z.createParser)(a);for await(let p of n.body)i.feed(t.decode(p))}})}var te=require("eventsource-parser"),R=require("zod");var je=U.merge(R.z.object({stream:R.z.literal(!0).optional().default(!0)})).strict(),ze=je.transform(n=>L(n)),Ut=R.z.object({stream:R.z.instanceof(globalThis.ReadableStream??Object)});async function ne(n,e){let t=ze.parse(n),o=t.model==="gpt-3.5-turbo"?"https://api.openai.com/v1/chat/completions":"https://api.openai.com/v1/completions",r=await fetch(o,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)});return{stream:await Ue(t,r)}}async function Ue(n,e){let t=new TextEncoder,o=new TextDecoder;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 c=JSON.parse(u),y=n.model==="gpt-3.5-turbo"?c.choices[0]?.delta.content:c.choices[0].text,v=t.encode(y);a.enqueue(v)}catch(c){a.error(c)}}}let p=(0,te.createParser)(i);for await(let s of e.body)p.feed(o.decode(s))}})}var M=require("zod"),Le=M.z.object({string:M.z.string()}),_t=M.z.object({arrayBuffer:M.z.instanceof(ArrayBuffer)});async function oe(n){let e=Le.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var f=require("zod"),_e=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"})}),Kt=f.z.object({audio:f.z.string()});async function re(n,e){let t=_e.parse(n),o=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,r={input:{text:t.text},voice:{languageCode:t.voice.language,name:t.voice.name},audioConfig:{audioEncoding:t.encoding,speakingRate:t.speakingRate,pitch:t.pitch}};return{audio:(await(await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()).audioContent}}var h=require("zod"),ke="https://transcribe.whisperapi.com",Ke=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")}),Bt=h.z.object({text:h.z.string()});async function ae(n,e){let t=Ke.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(ke,{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 k(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 $e(n){return async e=>{let t=await k(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,gpt3TurboPrediction,gpt3TurboPredictionStream,output,replaceMultipleStrings,replaceString,stabilityTextToImage,stringToArrayBuffer,vercelEdgeFunction,vercelGenericEdge,whisperApi});
Description:`}}var S=require("zod"),Ce=S.z.object({strings:S.z.record(S.z.string(),S.z.string()),modifier:S.z.string()}),bt=S.z.object({text:S.z.string()});async function Q(n){let e=Ce.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 I=require("zod"),Ee=I.z.object({text:I.z.string().or(I.z.array(I.z.string())),modifier:I.z.string()}),vt=I.z.object({text:I.z.string()});async function Z(n){let e=Ee.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),k=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","gpt-3.5-turbo"]).default("gpt-3.5-turbo"),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)}).strict(),K=n=>{if(n.model==="gpt-3.5-turbo"){let{prompt:e,...t}=n;return{...t,messages:[{role:"user",content:n.prompt}]}}return n},Oe=k.transform(n=>K(n)),Tt=l.z.object({text:l.z.string()});async function ee(n,e){let t=Oe.parse(n),o=t.model==="gpt-3.5-turbo"?"https://api.openai.com/v1/chat/completions":"https://api.openai.com/v1/completions",a=await(await fetch(o,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)})).json();return{text:(t.model==="gpt-3.5-turbo"?a.choices[0]?.message.content:a.choices[0].text).replace(/^(?:\n)+/gm,"")}}var d=require("zod"),$=d.z.object({messages:d.z.array(d.z.object({role:d.z.enum(["user","system","assistant"]),content:d.z.string()})).nonempty(),model:d.z.enum(["gpt-3.5-turbo"]).default("gpt-3.5-turbo"),temperature:d.z.number().min(0).max(2).default(.7),top_p:d.z.number().min(0).max(1).default(1),frequency_penalty:d.z.number().min(-2).max(2).default(0),presence_penalty:d.z.number().min(-2).max(2).default(0),max_tokens:d.z.number().default(200),n:d.z.number().default(1)}),Nt=d.z.object({text:d.z.string()});async function te(n,e){let t=$.parse(n);return{text:(await(await fetch("https://api.openai.com/v1/chat/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)})).json()).choices[0]?.message.content.replace(/^(?:\n)+/gm,"")}}var ne=require("eventsource-parser"),M=require("zod");var je=$.merge(M.z.object({stream:M.z.literal(!0).optional().default(!0)})),Et=M.z.object({stream:M.z.instanceof(globalThis.ReadableStream??Object)});async function oe(n,e){let t=je.parse(n),o=await fetch("https://api.openai.com/v1/chat/completions",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)});return{stream:await ze(o)}}async function ze(n){let e=new TextEncoder,t=new TextDecoder;return new ReadableStream({async start(r){function a(p){if(p.type==="event"){let s=p.data;if(s==="[DONE]"){r.close();return}try{let c=JSON.parse(s).choices[0]?.delta.content,y=e.encode(c);r.enqueue(y)}catch(u){r.error(u)}}}let i=(0,ne.createParser)(a);for await(let p of n.body)i.feed(t.decode(p))}})}var re=require("eventsource-parser"),D=require("zod");var Ue=k.merge(D.z.object({stream:D.z.literal(!0).optional().default(!0)})).strict(),Le=Ue.transform(n=>K(n)),Lt=D.z.object({stream:D.z.instanceof(globalThis.ReadableStream??Object)});async function ae(n,e){let t=Le.parse(n),o=t.model==="gpt-3.5-turbo"?"https://api.openai.com/v1/chat/completions":"https://api.openai.com/v1/completions",r=await fetch(o,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.openai}`},method:"POST",body:JSON.stringify(t)});return{stream:await _e(t,r)}}async function _e(n,e){let t=new TextEncoder,o=new TextDecoder;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 c=JSON.parse(u),y=n.model==="gpt-3.5-turbo"?c.choices[0]?.delta.content:c.choices[0].text,T=t.encode(y);a.enqueue(T)}catch(c){a.error(c)}}}let p=(0,re.createParser)(i);for await(let s of e.body)p.feed(o.decode(s))}})}var C=require("zod"),ke=C.z.object({string:C.z.string()}),kt=C.z.object({arrayBuffer:C.z.instanceof(ArrayBuffer)});async function ie(n){let e=ke.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var f=require("zod"),Ke=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"})}),$t=f.z.object({audio:f.z.string()});async function se(n,e){let t=Ke.parse(n),o=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,r={input:{text:t.text},voice:{languageCode:t.voice.language,name:t.voice.name},audioConfig:{audioEncoding:t.encoding,speakingRate:t.speakingRate,pitch:t.pitch}};return{audio:(await(await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()).audioContent}}var h=require("zod"),$e="https://transcribe.whisperapi.com",Be=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")}),Wt=h.z.object({text:h.z.string()});async function pe(n,e){let t=Be.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($e,{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 B(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 We(n){return async e=>{let t=await B(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,gpt3TurboPrediction,gpt3TurboPredictionStream,output,replaceMultipleStrings,replaceString,stabilityTextToImage,stringToArrayBuffer,vercelEdgeFunction,vercelGenericEdge,whisperApi});
{
"name": "@aigur/client",
"version": "1.9.0",
"version": "1.9.1",
"description": "",

@@ -17,3 +17,3 @@ "main": "./dist/index.js",

"zod": "^3.20.2",
"@aigur/huggingface": "0.0.11"
"@aigur/huggingface": "0.0.12"
},

@@ -20,0 +20,0 @@ "devDependencies": {

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

export * from '@aigur/huggingface';
export * from './Aigur';

@@ -2,0 +3,0 @@ 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