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 0.32.0 to 0.32.1

src/nodes/image/textToImage/dalleBase64.ts

60

dist/index.d.ts

@@ -39,4 +39,7 @@ import { z } from 'zod';

private createDynamicPlaceholders;
private setPlaceholderValues;
output: any;
output(getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any> ? Awaited<ReturnType<PrevNode['action']>> : Input;
input: z.output<Input>;
}) => z.output<Output>): FlowBuilder<Input, Output, [...NodeDefinitions, ConcreteNode<z.input<Output>, Awaited<z.output<Output>>>], ConcreteNode<z.input<Output>, Awaited<z.output<Output>>>>;
getNodes(): NodeDefinitions;

@@ -93,3 +96,3 @@ }

declare const inputSchema$8: z.ZodObject<{
declare const inputSchema$a: z.ZodObject<{
image: z.ZodString;

@@ -101,3 +104,3 @@ }, "strip", z.ZodTypeAny, {

}>;
declare const outputSchema$8: z.ZodObject<{
declare const outputSchema$a: z.ZodObject<{
labels: z.ZodArray<z.ZodString, "many">;

@@ -109,4 +112,45 @@ }, "strip", z.ZodTypeAny, {

}>;
declare function googleImageLabeling(input: z.input<typeof inputSchema$8>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$8>>;
declare function googleImageLabeling(input: z.input<typeof inputSchema$a>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$a>>;
declare const inputSchema$9: z.ZodObject<{
prompt: z.ZodString;
size: z.ZodDefault<z.ZodEnum<["256x256", "512x512", "1024x1024"]>>;
}, "strip", z.ZodTypeAny, {
prompt: string;
size: "256x256" | "512x512" | "1024x1024";
}, {
size?: "256x256" | "512x512" | "1024x1024" | undefined;
prompt: string;
}>;
declare const outputSchema$9: z.ZodObject<{
url: z.ZodString;
}, "strip", z.ZodTypeAny, {
url: string;
}, {
url: string;
}>;
declare function dalleUrlTextToImage(input: z.input<typeof inputSchema$9>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$9>>;
declare const inputSchema$8: z.ZodObject<{
prompt: z.ZodString;
response_format: z.ZodDefault<z.ZodLiteral<"b64_json">>;
size: z.ZodDefault<z.ZodEnum<["256x256", "512x512", "1024x1024"]>>;
}, "strip", z.ZodTypeAny, {
prompt: string;
size: "256x256" | "512x512" | "1024x1024";
response_format: "b64_json";
}, {
size?: "256x256" | "512x512" | "1024x1024" | undefined;
response_format?: "b64_json" | undefined;
prompt: string;
}>;
declare const outputSchema$8: z.ZodObject<{
result: z.ZodString;
}, "strip", z.ZodTypeAny, {
result: string;
}, {
result: string;
}>;
declare function dalleBase64TextToImage(input: z.input<typeof inputSchema$8>, apiKeys: APIKeys): Promise<z.infer<typeof outputSchema$8>>;
declare const stabilityModel: z.ZodEnum<["stable-diffusion-v1-5", "stable-diffusion-512-v2-0", "stable-diffusion-768-v2-0", "stable-diffusion-512-v2-1", "stable-diffusion-768-v2-1"]>;

@@ -225,4 +269,4 @@ declare const stabilityClipGuidancePreset: z.ZodEnum<["NONE", "FAST_BLUE", "FAST_GREEN", "SIMPLE", "SLOW", "SLOWER", "SLOWEST"]>;

}, "strip", z.ZodTypeAny, {
prompt: string;
model: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002";
prompt: string;
temperature: number;

@@ -265,4 +309,4 @@ top_p: number;

}>, "strip", z.ZodTypeAny, {
prompt: string;
model: "text-davinci-003" | "text-curie-001" | "text-babbage-001" | "text-ada-001" | "code-davinci-002" | "code-cushman-002";
prompt: string;
temperature: number;

@@ -382,2 +426,2 @@ top_p: number;

export { Aigur, Pipeline, createClient, enhanceWithKeywords, googleImageLabeling, googleTextToSpeech, gpt3Prediction, gpt3PredictionStream, inputSchema$4 as inputSchema, output, outputSchema$4 as outputSchema, replaceString, stabilityClipGuidancePreset, stabilityModel, stabilityTextToImage, stringToArrayBuffer, vercelGenericEdge, whisperApi };
export { Aigur, Pipeline, createClient, dalleBase64TextToImage, dalleUrlTextToImage, enhanceWithKeywords, googleImageLabeling, googleTextToSpeech, gpt3Prediction, gpt3PredictionStream, inputSchema$4 as inputSchema, output, outputSchema$4 as outputSchema, replaceString, stabilityClipGuidancePreset, stabilityModel, stabilityTextToImage, stringToArrayBuffer, vercelGenericEdge, whisperApi };

10

dist/index.js

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

var O=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var D=(r,e)=>{for(var t in e)O(r,t,{get:e[t],enumerable:!0})},_=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!L.call(r,o)&&o!==t&&O(r,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return r};var M=r=>_(O({},"__esModule",{value:!0}),r);var me={};D(me,{Pipeline:()=>P,createClient:()=>B,enhanceWithKeywords:()=>X,googleImageLabeling:()=>J,googleTextToSpeech:()=>ue,gpt3Prediction:()=>ne,gpt3PredictionStream:()=>re,inputSchema:()=>I,output:()=>T,outputSchema:()=>te,replaceString:()=>ee,stabilityClipGuidancePreset:()=>R,stabilityModel:()=>N,stabilityTextToImage:()=>H,stringToArrayBuffer:()=>se,vercelGenericEdge:()=>W,whisperApi:()=>le});module.exports=M(me);async function T(r){return r}var S=class{constructor(e,t){this.input=e;this.nodes=t;this.output=this.node.bind(this,T)}static create(e){return new S(e,[])}node(e,t){let n=this.createDynamicPlaceholders("input"),o=this.nodes.length>0?this.nodes[this.nodes.length-1]:n,s={action:e,input:t({nodes:this.nodes,prev:o.output,input:n}),output:this.createDynamicPlaceholders(this.nodes.length)};return this.nodes.push(s),this}createDynamicPlaceholders(e){let t={},n={get:function(s,p){return`$context.${e}.${p}$`}};return new Proxy(t,n)}setPlaceholderValues(e,t){let n={};for(let o of e)n[o]=`$context.${t}.${o}$`;return n}getNodes(){return this.nodes}};function E(r){return new Promise(e=>setTimeout(e,r))}function z(r,e){if(typeof r=="string")return o(r);let t={...r};return n(t);function n(a){for(let i in a)a[i]=o(a[i]);return a}function o(a){if(Array.isArray(a))return a.map(u=>n(u));if(typeof a=="object"&&a!==null)return n(a);let i=a,d=s(a);for(let u of d){let h=e[u.nodeId][u.property];if(h instanceof ArrayBuffer){i=h;continue}i=i?.replace(new RegExp(p(u.value)),h),i==="undefined"?i=void 0:i!==h&&i===h.toString()&&(i=h)}return i}function s(a){if(typeof a!="string")return[];let i=/\$context\.(\d+|input)\.(\w+)\$/g,d=a.matchAll(i),u=[];for(let f of d)u.push({value:f[0],nodeId:f[1],property:f[2]});return u}function p(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function A(r=16){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length;for(let o=0;o<r;o++)e+=t.charAt(Math.floor(Math.random()*n));return e}var K=2,k=350,P=class{constructor(e,t,n){this.conf=e;this.flow=t;this.apiKeys=n;this.onProgressListeners=new Map;this.onStartListeners=new Map;this.onFinishListeners=new Map;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){return this.processPipeline(this.conf,e)}invokeRemote(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(n=>n.json())}async invokeStream(e,t,n){let o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok)throw new Error(o.statusText);let s=o.body;if(!s)return;let p=s.getReader(),a=new TextDecoder,i=!1;for(;!i;){let{value:d,done:u}=await p.read();i=u;let f=a.decode(d);n(f)}}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)}}listenToEvents(){if(!this.conf.updateProgress||typeof window>"u"||!this.apiKeys?.ablySubscribe)return;let e=`https://realtime.ably.io/event-stream?channels=aigur-client&v=1.2&key=${this.apiKeys.ablySubscribe}&enveloped=false`,t=new EventSource(e);t.onmessage=n=>{let o=JSON.parse(n.data);o.pipelineId===this.conf.id&&(o.type==="pipeline:start"?this.triggerListeners(this.onStartListeners):o.type==="pipeline:finish"?this.triggerListeners(this.onFinishListeners):(o.type==="node:start"||o.type==="node:finish")&&this.triggerListeners(this.onProgressListeners,{...o.data,type:o.type}))}}triggerListeners(e,...t){for(let n of e.values())n(...t)}async processPipeline(e,t){let n=this.conf.retries??K;try{await this.notifyEvent("pipeline:start"),e.input.parse(t);let o={input:t},s={},p=this.flow.getNodes(),a;for(let i=0;i<p.length;i++){a=this.notifyEvent("node:start",{node:p[i],index:i});let d=0,u=!1;do{d++;try{s=await this.executeAction(p,i,o),o[i]=s,u=!0}catch(f){if(d>n)throw f;await E((this.conf.retryDelayInMs??k)*d)}}while(!u&&d<=n);await a,await this.notifyEvent("node:finish",{node:p[i],index:i})}return await this.notifyEvent("pipeline:finish"),s}catch(o){throw console.error(o),o}}async executeAction(e,t,n){let{action:o,schema:s,input:p}=e[t],a=z(p,n);return o(a,this.apiKeys)}notifyEvent(e,t){if(!(!this.conf.updateProgress||!this.apiKeys.ablyPublish))return fetch("https://rest.ably.io/channels/aigur-client/messages?enveloped=false ",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${btoa(this.apiKeys.ablyPublish)}`},body:JSON.stringify({type:e,data:t,pipelineId:this.conf.id})})}};var $=2,Z=350,B=r=>{let{apiKeys:e}=r;return{pipeline:{create:t=>{let n={...t,retries:t.retries??$,retryDelayInMs:t.retryDelayInMs??Z},o=t.flow(new S(t.input,[]));return new P(n,o,e)}}}};async function W(r,e){let t=await e.json(),{searchParams:n}=new URL(e.url);if(!n.has("id"))return new Response("Missing id",{status:400});let o=n.get("id"),s=r[o];return{output:await s.invoke(t),pipeline:s}}var b=require("zod"),F=b.z.object({image:b.z.string()}),ze=b.z.object({labels:b.z.array(b.z.string())});async function J(r,e){let t=F.parse(r),n=`https://vision.googleapis.com/v1/images:annotate?key=${e.googleapis}`,o={requests:[{image:{content:t.image},features:[{type:"LABEL_DETECTION"}]}]};return{labels:(await(await fetch(n,{method:"POST",body:JSON.stringify(o)})).json()).responses[0].labelAnnotations.map(a=>a.description)}}var c=require("zod"),N=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"]),R=c.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),G=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(r=>r.length>0,"Must have at least one text prompt"),model:N.default("stable-diffusion-v1-5"),clip_guidance_preset:R.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(r=>typeof r<"u"?r%64===0:!0,"Must be a multiple of 64"),width:c.z.number().min(128).optional().refine(r=>typeof r<"u"?r%64===0:!0,"Must be a multiple of 64")}),Re=c.z.object({result:c.z.instanceof(ArrayBuffer)});async function H(r,e){let t=G.parse(r),n=`https://api.stability.ai/v1beta/generation/${t.model}/text-to-image`;return{result:await(await fetch(n,{headers:{"Content-Type":"application/json",Accept:"image/png",Authorization:e.stability},method:"POST",body:JSON.stringify(t)})).arrayBuffer()}}var x=require("zod"),V=x.z.object({text:x.z.string(),amount:x.z.number().optional().default(8)}),Ue=x.z.object({text:x.z.string()}),Y={"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 q(r){return Object.entries(Y).map(([e,t])=>`Title: ${e}
Description: ${t.slice(0,r).join(", ")}
var T=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})},M=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _(e))!D.call(n,r)&&r!==t&&T(n,r,{get:()=>e[r],enumerable:!(o=L(e,r))||o.enumerable});return n};var k=n=>M(T({},"__esModule",{value:!0}),n);var be={};K(be,{Pipeline:()=>A,createClient:()=>F,dalleBase64TextToImage:()=>X,dalleUrlTextToImage:()=>Y,enhanceWithKeywords:()=>re,googleImageLabeling:()=>H,googleTextToSpeech:()=>ye,gpt3Prediction:()=>pe,gpt3PredictionStream:()=>ce,inputSchema:()=>O,output:()=>N,outputSchema:()=>se,replaceString:()=>ie,stabilityClipGuidancePreset:()=>C,stabilityModel:()=>R,stabilityTextToImage:()=>ee,stringToArrayBuffer:()=>le,vercelGenericEdge:()=>J,whisperApi:()=>Se});module.exports=k(be);async function N(n){return n}var b=class{constructor(e,t){this.input=e;this.nodes=t}static create(e){return new b(e,[])}node(e,t){let o=this.createDynamicPlaceholders("input"),r=this.nodes.length>0?this.nodes[this.nodes.length-1]:o,i={action:e,input:t({nodes:this.nodes,prev:r.output,input:o}),output:this.createDynamicPlaceholders(this.nodes.length)};return this.nodes.push(i),this}createDynamicPlaceholders(e){let t={},o={get:function(i,p){return`$context.${e}.${p}$`}};return new Proxy(t,o)}output(e){return this.node(N,e)}getNodes(){return this.nodes}};function j(n){return new Promise(e=>setTimeout(e,n))}function E(n,e){if(typeof n=="string")return r(n);let t={...n};return o(t);function o(s){for(let a in s)s[a]=r(s[a]);return s}function r(s){if(Array.isArray(s))return s.map(u=>o(u));if(typeof s=="object"&&s!==null)return o(s);let a=s,d=i(s);for(let u of d){let h=e[u.nodeId][u.property];if(h instanceof ArrayBuffer){a=h;continue}a=a?.replace(new RegExp(p(u.value)),h),a==="undefined"?a=void 0:a!==h&&a===h.toString()&&(a=h)}return a}function i(s){if(typeof s!="string")return[];let a=/\$context\.(\d+|input)\.(\w+)\$/g,d=s.matchAll(a),u=[];for(let f of d)u.push({value:f[0],nodeId:f[1],property:f[2]});return u}function p(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function z(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}var B=2,Z=350,A=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.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){return this.processPipeline(this.conf,e)}invokeRemote(e,t){return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(o=>o.json())}async invokeStream(e,t,o){let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(r.statusText);let i=r.body;if(!i)return;let p=i.getReader(),s=new TextDecoder,a=!1;for(;!a;){let{value:d,done:u}=await p.read();a=u;let f=s.decode(d);o(f)}}onProgress(e){let t=z();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=z();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=z();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}listenToEvents(){if(!this.conf.updateProgress||typeof window>"u"||!this.apiKeys?.ablySubscribe)return;let e=`https://realtime.ably.io/event-stream?channels=aigur-client&v=1.2&key=${this.apiKeys.ablySubscribe}&enveloped=false`,t=new EventSource(e);t.onmessage=o=>{let r=JSON.parse(o.data);r.pipelineId===this.conf.id&&(r.type==="pipeline:start"?this.triggerListeners(this.onStartListeners):r.type==="pipeline:finish"?this.triggerListeners(this.onFinishListeners):(r.type==="node:start"||r.type==="node:finish")&&this.triggerListeners(this.onProgressListeners,{...r.data,type:r.type}))}}triggerListeners(e,...t){for(let o of e.values())o(...t)}async processPipeline(e,t){let o=this.conf.retries??B;try{await this.notifyEvent("pipeline:start"),e.input.parse(t);let r={input:t},i={},p=this.flow.getNodes(),s;for(let a=0;a<p.length;a++){s=this.notifyEvent("node:start",{node:p[a],index:a});let d=0,u=!1;do{d++;try{i=await this.executeAction(p,a,r),r[a]=i,u=!0}catch(f){if(d>o)throw f;await j((this.conf.retryDelayInMs??Z)*d)}}while(!u&&d<=o);await s,await this.notifyEvent("node:finish",{node:p[a],index:a})}return await this.notifyEvent("pipeline:finish"),i}catch(r){throw console.error(r),r}}async executeAction(e,t,o){let{action:r,schema:i,input:p}=e[t],s=E(p,o);return r(s,this.apiKeys)}notifyEvent(e,t){if(!(!this.conf.updateProgress||!this.apiKeys.ablyPublish))return fetch("https://rest.ably.io/channels/aigur-client/messages?enveloped=false ",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${btoa(this.apiKeys.ablyPublish)}`},body:JSON.stringify({type:e,data:t,pipelineId:this.conf.id})})}};var $=2,W=350,F=n=>{let{apiKeys:e}=n;return{pipeline:{create:t=>{let o={...t,retries:t.retries??$,retryDelayInMs:t.retryDelayInMs??W},r=t.flow(new b(t.input,[]));return new A(o,r,e)}}}};async function J(n,e){let t=await e.json(),{searchParams:o}=new URL(e.url);if(!o.has("id"))return new Response("Missing id",{status:400});let r=o.get("id"),i=n[r];return{output:await i.invoke(t),pipeline:i}}var x=require("zod"),G=x.z.object({image:x.z.string()}),Le=x.z.object({labels:x.z.array(x.z.string())});async function H(n,e){let t=G.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(s=>s.description)}}var P=require("zod"),V=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 Y(n,e){let t=V.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 console.log("***url",i),{url:i[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")}),Me=S.z.object({result:S.z.string()});async function X(n,e){let t=q.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 c=require("zod"),R=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:R.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)}),$e=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}
Description: ${t.slice(0,n).join(", ")}
`).join(`
`)}async function X(r){let e=V.parse(r);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following
${q(e.amount)}
`)}async function re(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)}
Title: ${e.text}
Description:`}}var g=require("zod"),Q=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),Le=g.z.object({text:g.z.string()});async function ee(r){let e=Q.parse(r);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var l=require("zod"),I=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)}),te=l.z.object({text:l.z.string()});async function ne(r,e){let t=I.parse(r);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 j=require("eventsource-parser"),v=require("zod");var oe=I.merge(v.z.object({stream:v.z.literal(!0).optional().default(!0)})),$e=v.z.object({stream:v.z.instanceof(globalThis.ReadableStream??Object)});async function re(r,e){let t=oe.parse(r),n=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(n)}}async function ie(r){let e=new TextEncoder,t=new TextDecoder,n=0;return new ReadableStream({async start(s){function p(i){if(i.type==="event"){let d=i.data;if(d==="[DONE]"){s.close();return}try{let f=JSON.parse(d).choices[0].text;if(n<2&&(f.match(/\n/)||[]).length)return;let h=e.encode(f);s.enqueue(h),n++}catch(u){s.error(u)}}}let a=(0,j.createParser)(p);for await(let i of r.body)a.feed(t.decode(i))}})}var w=require("zod"),ae=w.z.object({string:w.z.string()}),Be=w.z.object({arrayBuffer:w.z.instanceof(ArrayBuffer)});async function se(r){let e=ae.parse(r);return{arrayBuffer:Uint8Array.from(atob(e.string),n=>n.charCodeAt(0)).buffer}}var m=require("zod"),pe=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"})}),Fe=m.z.object({audio:m.z.string()});async function ue(r,e){let t=pe.parse(r),n=`https://us-central1-texttospeech.googleapis.com/v1beta1/text:synthesize?key=${e.googleapis}`,o={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(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json()).audioContent}}var y=require("zod"),ce="https://transcribe.whisperapi.com",de=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")}),Ge=y.z.object({text:y.z.string()});async function le(r,e){let t=de.parse(r),n=new FormData;n.append("url",t.audioUrl),t.autoDetectLanguage||n.append("language",t.language),n.append("fileType",t.fileType),n.append("task",t.task);let o=await fetch(ce,{method:"POST",headers:{contentType:"application/json",Authorization:"Bearer "+e.whisperapi},body:n});if(!o.ok)throw new Error(o.statusText);return{text:(await o.json()).text.trim()}}0&&(module.exports={Pipeline,createClient,enhanceWithKeywords,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,inputSchema,output,outputSchema,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelGenericEdge,whisperApi});
Description:`}}var g=require("zod"),ae=g.z.object({text:g.z.string().or(g.z.array(g.z.string())),modifier:g.z.string()}),Fe=g.z.object({text:g.z.string()});async function ie(n){let e=ae.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var m=require("zod"),O=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)}),se=m.z.object({text:m.z.string()});async function pe(n,e){let t=O.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 U=require("eventsource-parser"),w=require("zod");var ue=O.merge(w.z.object({stream:w.z.literal(!0).optional().default(!0)})),qe=w.z.object({stream:w.z.instanceof(globalThis.ReadableStream??Object)});async function ce(n,e){let t=ue.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(i){function p(a){if(a.type==="event"){let d=a.data;if(d==="[DONE]"){i.close();return}try{let f=JSON.parse(d).choices[0].text;if(o<2&&(f.match(/\n/)||[]).length)return;let h=e.encode(f);i.enqueue(h),o++}catch(u){i.error(u)}}}let s=(0,U.createParser)(p);for await(let a of n.body)s.feed(t.decode(a))}})}var I=require("zod"),me=I.z.object({string:I.z.string()}),Qe=I.z.object({arrayBuffer:I.z.instanceof(ArrayBuffer)});async function le(n){let e=me.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var l=require("zod"),fe=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"})}),tt=l.z.object({audio:l.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}`,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 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 r=await fetch(he,{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,replaceString,stabilityClipGuidancePreset,stabilityModel,stabilityTextToImage,stringToArrayBuffer,vercelGenericEdge,whisperApi});
{
"name": "@aigur/client",
"version": "0.32.0",
"version": "0.32.1",
"description": "",

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

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

}),
// configure output to return a placeholder for any property accessed (e.g. $context.0.url$)
output: this.createDynamicPlaceholders(this.nodes.length),

@@ -73,22 +74,14 @@ } as NewNode;

private setPlaceholderValues<T extends ConcreteNode<any, any>>(
outputKeys: string[],
index: number | 'input'
): T['output'] {
const placeholderedOutput: T['output'] = {};
for (let key of outputKeys) {
placeholderedOutput[key] = `$context.${index}.${key}$`;
}
return placeholderedOutput;
output(
getUserInput: (data: {
nodes: NodeDefinitions;
prev: PrevNode extends ConcreteNode<any, any>
? Awaited<ReturnType<PrevNode['action']>>
: Input;
input: z.output<Input>;
}) => z.output<Output>
) {
return this.node(output<Output>, getUserInput);
}
// node2<
// I extends Record<string, any> | ReadableStream,
// O extends Record<string, any> | ReadableStream
// >(node: NodeAction<I, O>) {
// return this.nodeFactory(node);
// }
output = this.node.bind(this, output<Output>);
getNodes() {

@@ -95,0 +88,0 @@ return this.nodes;

export * from './image/labeling/googleImageLabeling';
export * from './image/textToImage/dalleUrl';
export * from './image/textToImage/dalleBase64';
export * from './image/textToImage/stability';

@@ -3,0 +5,0 @@ export * from './output/output';

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