@aigur/client
Advanced tools
Comparing version 1.10.0 to 1.11.0
# @aigur/client | ||
## 1.11.0 | ||
### Minor Changes | ||
- ce92010e: Export and fix hf nodes | ||
## 1.10.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,7 +0,7 @@ | ||
var z=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var le=(n,e)=>{for(var t in e)z(n,t,{get:e[t],enumerable:!0})},fe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of me(e))!de.call(n,r)&&r!==t&&z(n,r,{get:()=>e[r],enumerable:!(o=ce(e,r))||o.enumerable});return n};var ye=n=>fe(z({},"__esModule",{value:!0}),n);var Je={};le(Je,{Pipeline:()=>A,cleanContextVars:()=>Y,createClient:()=>be,dalleBase64TextToImage:()=>H,dalleUrlTextToImage:()=>G,enhanceWithKeywords:()=>X,googleImageLabeling:()=>V,googleTextToSpeech:()=>se,gpt3Prediction:()=>ee,gpt3PredictionStream:()=>ae,gpt3TurboPrediction:()=>te,gpt3TurboPredictionStream:()=>oe,hf:()=>J,output:()=>C,replaceMultipleStrings:()=>Q,replaceString:()=>Z,stabilityTextToImage:()=>q,stringToArrayBuffer:()=>ie,vercelEdgeFunction:()=>We,vercelGenericEdge:()=>K,whisperApi:()=>pe});module.exports=ye(Je);function $(n){return new Promise(e=>setTimeout(e,n))}function O(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=U(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 U(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 T(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 B(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 F(n,e){let{memoryToSave:t}=e;if(!t)return;let o=O(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let p=U(t[r]),[s,u]=i.tee();n.values[p[0].nodeId].output=s;let c=await he(u);o[a]=c}}return o}function he(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 ge=2,xe=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.pipelineInstanceId=T(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=B({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 w=s.decode(c);o(w)}}onProgress(e){let t=T();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=T();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=T();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??ge;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:w}=r[i],j=e.values[i]={input:null,output:null};j.input=O(w,e.values),j.output=await y(j.input,this.apiKeys);let ue=F(e,r[i]);this.saveMemory(e,ue),u=!0}catch(y){if(s>t)throw y;await $((this.conf.retryDelayInMs??xe)*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 Se=2,Ie=350,be=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??Se,retryDelayInMs:t.retryDelayInMs??Ie,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new E([]));return new A(o,r,e)}}}};var I=require("zod"),W=require("@huggingface/inference");function J(n,e){return(t,o)=>{let r=new W.HfInference(o.huggingface);return n(r).call(r,t,e)}}var dt=I.z.object({retry_on_error:I.z.boolean().optional().default(!0),use_cache:I.z.boolean().optional().default(!0),use_gpu:I.z.boolean().optional(),wait_for_model:I.z.boolean().optional()}).optional();var b=require("zod"),Pe=b.z.object({image:b.z.string()}),ft=b.z.object({labels:b.z.array(b.z.string())});async function V(n,e){let t=Pe.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"),ve=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")}),ht=S.z.object({result:S.z.string()});async function H(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{result:a[0].b64_json}}var P=require("zod"),we=P.z.object({prompt:P.z.string(),size:P.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),xt=P.z.object({url:P.z.string().url()});async function G(n,e){let t=we.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"),Te=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"]),Ae=m.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),Re=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:Te.default("stable-diffusion-v1-5"),clip_guidance_preset:Ae.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")}),It=m.z.object({result:m.z.instanceof(ArrayBuffer)});async function q(n,e){let t=Re.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()}),Pt=R.z.object({text:R.z.string()});async function Y(n){return{text:Ne.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var v=require("zod"),Me=v.z.object({text:v.z.string(),amount:v.z.number().optional().default(8)}),wt=v.z.object({text:v.z.string()}),De={"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(De).map(([e,t])=>`Title: ${e} | ||
var Z=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var mt=(n,e)=>{for(var t in e)Z(n,t,{get:e[t],enumerable:!0})},ft=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ct(e))!ut.call(n,r)&&r!==t&&Z(n,r,{get:()=>e[r],enumerable:!(o=pt(e,r))||o.enumerable});return n};var lt=n=>ft(Z({},"__esModule",{value:!0}),n);var sn={};mt(sn,{Pipeline:()=>F,audioClassification:()=>me,automaticSpeechRecognition:()=>le,cleanContextVars:()=>Ve,conversational:()=>ye,createClient:()=>St,dalleBase64TextToImage:()=>We,dalleUrlTextToImage:()=>Je,enhanceWithKeywords:()=>Ge,featureExtraction:()=>he,fillMask:()=>Se,googleImageLabeling:()=>Fe,googleTextToSpeech:()=>at,gpt3Prediction:()=>Xe,gpt3PredictionStream:()=>ot,gpt3TurboPrediction:()=>Ze,gpt3TurboPredictionStream:()=>tt,hf:()=>ce,imageClassification:()=>Ie,imageSegmentation:()=>we,objectDetection:()=>Ae,output:()=>Y,questionAnswer:()=>Te,replaceMultipleStrings:()=>Ye,replaceString:()=>Qe,stabilityTextToImage:()=>qe,stringToArrayBuffer:()=>rt,summarization:()=>Ce,tableQuestionAnswer:()=>Re,textClassification:()=>Me,textGeneration:()=>Ee,textToImage:()=>Ke,tokenClassification:()=>Ue,translation:()=>Be,vercelEdgeFunction:()=>an,vercelGenericEdge:()=>re,whisperApi:()=>it,zeroShotClassification:()=>He});module.exports=lt(sn);function ae(n){return new Promise(e=>setTimeout(e,n))}function G(n,e){if(typeof n=="string")return o(n);return t({...n});function t(a){let i={};for(let c in a)i[c]=o(a[c]);return i}function o(a){if(Array.isArray(a))return a.map(p=>t(p));if(typeof a=="object"&&a!==null)return t(a);let i=a,c=ee(a);for(let p of c){let m=e[p.nodeId].output;if(m==null)continue;let f=m[p.property];if(f instanceof ArrayBuffer){i=f;continue}i=i?.replace(new RegExp(r(p.value)),f),i==="undefined"?i=void 0:i!==f&&i===f.toString()&&(i=f)}return i}function r(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}function ee(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 H(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 ie(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 se(n,e){let{memoryToSave:t}=e;if(!t)return;let o=G(t,n.values);for(let r in t)for(let a in o){let i=o[a];if(i instanceof ReadableStream){let c=ee(t[r]),[p,m]=i.tee();n.values[c[0].nodeId].output=p;let f=await dt(m);o[a]=f}}return o}function dt(n){return new Promise(async e=>{let t=n.getReader(),o=new TextDecoder,r=!1,a="";for(;!r;){let{value:i,done:c}=await t.read();r=c;let p=o.decode(i);a+=p}e(a)})}var yt=2,gt=350,F=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=H(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=ie({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 c=i.getReader(),p=new TextDecoder,m=!1;for(;!m;){let{value:f,done:T}=await c.read();m=T;let $=p.decode(f);o($)}}onProgress(e){let t=H();return this.onProgressListeners.set(t,e),()=>{this.onProgressListeners.delete(t)}}onStart(e){let t=H();return this.onStartListeners.set(t,e),()=>{this.onStartListeners.delete(t)}}onFinish(e){let t=H();return this.onFinishListeners.set(t,e),()=>{this.onFinishListeners.delete(t)}}async processPipeline(e){let t=this.conf.retries??yt;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 c=this.notifyEvent({type:"node:start",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await c;let p=0,m=!1;do{p++;try{let{action:T,input:$}=r[i],X=e.values[i]={input:null,output:null};X.input=G($,e.values),X.output=await T(X.input,this.apiKeys);let st=se(e,r[i]);this.saveMemory(e,st),m=!0}catch(T){if(p>t)throw T;await ae((this.conf.retryDelayInMs??gt)*p)}}while(!m&&p<=t);let f=this.notifyEvent({type:"node:finish",context:e,data:{node:r[i].action.name,tag:r[i].tag??"",index:i}});this.conf.stream||await f}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 Y(n){return n}var Q=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),c=this.nodes.length>0?this.nodes[this.nodes.length-1]:a,p="$context.pipeline.userId$",m={action:e,input:t({nodes:this.nodes,prev:c.output,input:a,memory:r,userId:p}),output:this.createDynamicPlaceholders(this.nodes.length),memoryToSave:o?o({nodes:this.nodes,prev:c.output,output:i,input:a,memory:r,userId:p}):null};return this.nodes.push(m),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(Y,e,t)}getNodes(){return this.nodes}};var ht=2,xt=350,St=n=>{let{apiKeys:e}=n;return{apiKeys:e,pipeline:{create:t=>{let o={...t,memoryManager:n.memoryManager,retries:t.retries??ht,retryDelayInMs:t.retryDelayInMs??xt,eventListener:n.eventListener,eventPublisher:n.eventPublisher},r=t.flow(new Q([]));return new F(o,r,e)}}}};var z=require("zod"),ue=require("@huggingface/inference");var O=require("zod"),pe=require("@huggingface/inference");function ce(n,e){return(t,o)=>{let r=new pe.HfInference(o.huggingface);return n(r).call(r,t,e)}}var s=O.z.object({retry_on_error:O.z.boolean().optional().default(!0),use_cache:O.z.boolean().optional().default(!0),use_gpu:O.z.boolean().optional(),wait_for_model:O.z.boolean().optional()}).optional();var bt=z.z.object({model:z.z.string(),data:z.z.instanceof(ArrayBuffer),options:s}),_n=z.z.object({result:z.z.array(z.z.object({label:z.z.string(),score:z.z.number()}))});async function me(n,e){let{options:t,...o}=bt.parse(n);return{result:await new ue.HfInference(e.huggingface).audioClassification(o,t)}}var K=require("zod"),fe=require("@huggingface/inference");var It=K.z.object({model:K.z.string(),data:K.z.instanceof(ArrayBuffer),options:s}),Mn=K.z.object({text:K.z.string()});async function le(n,e){let{options:t,...o}=It.parse(n),r=new fe.HfInference(e.huggingface),{text:a}=await r.automaticSpeechRecognition(o,t);return{text:a}}var u=require("zod"),de=require("@huggingface/inference");var Pt=u.z.object({model:u.z.string(),inputs:u.z.object({generated_responses:u.z.string().array().optional(),past_user_inputs:u.z.string().array().optional(),text:u.z.string()}),parameters:u.z.object({max_length:u.z.number().int().optional(),max_time:u.z.number().min(0).max(120).optional(),min_length:u.z.number().int().optional(),repetition_penalty:u.z.number().min(0).max(100).optional(),temperature:u.z.number().min(0).max(100).optional().default(1),top_k:u.z.number().int().optional(),top_p:u.z.number().optional()}).optional(),options:s}),On=u.z.object({conversation:u.z.object({generated_responses:u.z.string().array(),past_user_inputs:u.z.string().array()}),generated_text:u.z.string(),warnings:u.z.string().array()});async function ye(n,e){let{options:t,...o}=Pt.parse(n);return await new de.HfInference(e.huggingface).conversational(o,t)}var b=require("zod"),ge=require("@huggingface/inference");var wt=b.z.object({model:b.z.string(),inputs:b.z.record(b.z.string(),b.z.any()).or(b.z.record(b.z.string(),b.z.any()).array()),options:s}),Un=b.z.object({result:b.z.array(b.z.number().or(b.z.number().array()))});async function he(n,e){let{options:t,...o}=wt.parse(n);return{result:await new ge.HfInference(e.huggingface).featureExtraction(o,t)}}var v=require("zod"),xe=require("@huggingface/inference");var vt=v.z.object({model:v.z.string(),inputs:v.z.string(),options:s}),$n=v.z.object({result:v.z.array(v.z.object({score:v.z.number(),sequence:v.z.string(),token:v.z.number(),token_str:v.z.string()}))});async function Se(n,e){let{options:t,...o}=vt.parse(n);return{result:await new xe.HfInference(e.huggingface).fillMask(o,t)}}var C=require("zod"),be=require("@huggingface/inference");var At=C.z.object({model:C.z.string(),data:C.z.instanceof(ArrayBuffer),options:s}),Wn=C.z.object({result:C.z.array(C.z.object({label:C.z.string(),score:C.z.number()}))});async function Ie(n,e){let{options:t,...o}=At.parse(n);return{result:await new be.HfInference(e.huggingface).imageClassification(o,t)}}var j=require("zod"),Pe=require("@huggingface/inference");var jt=j.z.object({model:j.z.string(),data:j.z.instanceof(ArrayBuffer),options:s}),Vn=j.z.object({result:j.z.array(j.z.object({label:j.z.string(),mask:j.z.string(),score:j.z.number()}))});async function we(n,e){let{options:t,...o}=jt.parse(n);return{result:await new Pe.HfInference(e.huggingface).imageSegmentation(o,t)}}var g=require("zod"),ve=require("@huggingface/inference");var Tt=g.z.object({model:g.z.string(),data:g.z.instanceof(ArrayBuffer),options:s}),Qn=g.z.object({result:g.z.array(g.z.object({box:g.z.object({xmax:g.z.number(),xmin:g.z.number(),ymax:g.z.number(),ymin:g.z.number()}),label:g.z.string(),score:g.z.number()}))});async function Ae(n,e){let{options:t,...o}=Tt.parse(n);return{result:await new ve.HfInference(e.huggingface).objectDetection(o,t)}}var A=require("zod"),je=require("@huggingface/inference");var zt=A.z.object({model:A.z.string(),inputs:A.z.object({context:A.z.string(),question:A.z.string()}),options:s}),eo=A.z.object({answer:A.z.string(),end:A.z.number(),score:A.z.number(),start:A.z.number()});async function Te(n,e){let{options:t,...o}=zt.parse(n);return await new je.HfInference(e.huggingface).questionAnswer(o,t)}var h=require("zod"),ze=require("@huggingface/inference");var Ct=h.z.object({model:h.z.string(),inputs:h.z.string(),parameters:h.z.object({max_length:h.z.number().int().optional(),max_time:h.z.number().min(0).max(120).optional(),min_length:h.z.number().int().optional(),repetition_penalty:h.z.number().min(0).max(100).optional(),temperature:h.z.number().min(0).max(100).optional().default(1),top_k:h.z.number().int().optional(),top_p:h.z.number().optional()}).optional(),options:s}),oo=h.z.object({summary_text:h.z.string()});async function Ce(n,e){let{options:t,...o}=Ct.parse(n),r=new ze.HfInference(e.huggingface),{summary_text:a}=await r.summarization(o,t);return{summary_text:a}}var I=require("zod"),_e=require("@huggingface/inference");var _t=I.z.object({model:I.z.string(),inputs:I.z.object({query:I.z.string(),table:I.z.record(I.z.string().array())}),options:s}),io=I.z.object({aggregator:I.z.string(),answer:I.z.string(),cells:I.z.string().array(),coordinates:I.z.number().array().array()});async function Re(n,e){let{options:t,...o}=_t.parse(n);return await new _e.HfInference(e.huggingface).tableQuestionAnswer(o,t)}var _=require("zod"),Ne=require("@huggingface/inference");var Rt=_.z.object({model:_.z.string(),inputs:_.z.string(),options:s}),co=_.z.object({result:_.z.array(_.z.object({label:_.z.string(),score:_.z.number()}))});async function Me(n,e){let{options:t,...o}=Rt.parse(n);return{result:await new Ne.HfInference(e.huggingface).textClassification(o,t)}}var l=require("zod"),De=require("@huggingface/inference");var Nt=l.z.object({model:l.z.string(),inputs:l.z.string(),parameters:l.z.object({do_sample:l.z.boolean().optional().default(!0),max_new_tokens:l.z.number().int().min(0).max(250).optional(),max_time:l.z.number().min(0).max(120).optional(),num_return_sequences:l.z.number().int().min(0).optional().default(1),repetition_penalty:l.z.number().min(0).max(100).optional(),return_full_text:l.z.boolean().optional().default(!0),temperature:l.z.number().min(0).max(100).optional().default(1),top_k:l.z.number().int().optional(),top_p:l.z.number().optional()}).optional(),options:s}),fo=l.z.object({generated_text:l.z.string()});async function Ee(n,e){let{options:t,...o}=Nt.parse(n),r=new De.HfInference(e.huggingface),{generated_text:a}=await r.textGeneration(o,t);return{generated_text:a}}var D=require("zod"),Oe=require("@huggingface/inference");var Mt=D.z.object({model:D.z.string(),inputs:D.z.string(),negative_prompt:D.z.string().optional(),options:s}),go=D.z.object({result:D.z.instanceof(ArrayBuffer)});async function Ke(n,e){let{options:t,...o}=Mt.parse(n);return{result:await new Oe.HfInference(e.huggingface).textToImage(o,t)}}var x=require("zod"),ke=require("@huggingface/inference");var Dt=x.z.object({model:x.z.string(),inputs:x.z.string(),parameters:x.z.object({aggregation_strategy:x.z.enum(["none","simple","first","average","max"]).optional().default("simple")}).optional(),options:s}),So=x.z.object({result:x.z.array(x.z.object({end:x.z.number(),entity_group:x.z.string(),score:x.z.number(),start:x.z.number(),word:x.z.string()}))});async function Ue(n,e){let{options:t,...o}=Dt.parse(n);return{result:await new ke.HfInference(e.huggingface).tokenClassification(o,t)}}var k=require("zod"),Le=require("@huggingface/inference");var Et=k.z.object({model:k.z.string(),inputs:k.z.string(),options:s}),Po=k.z.object({translation_text:k.z.string()});async function Be(n,e){let{options:t,...o}=Et.parse(n),r=new Le.HfInference(e.huggingface),{translation_text:a}=await r.translation(o,t);return{translation_text:a}}var S=require("zod"),$e=require("@huggingface/inference");var Ot=S.z.object({model:S.z.string(),inputs:S.z.string().or(S.z.string().array()),parameters:S.z.object({candidate_labels:S.z.string().array(),multi_label:S.z.boolean().optional()}),options:s}),Ao=S.z.object({result:S.z.array(S.z.object({labels:S.z.string().array(),scores:S.z.number().array(),sequence:S.z.string()}))});async function He(n,e){let{options:t,...o}=Ot.parse(n);return{result:await new $e.HfInference(e.huggingface).zeroShotClassification(o,t)}}var U=require("zod"),Kt=U.z.object({image:U.z.string()}),Jo=U.z.object({labels:U.z.array(U.z.string())});async function Fe(n,e){let t=Kt.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(c=>c.description)}}var E=require("zod"),kt=E.z.object({prompt:E.z.string(),response_format:E.z.literal("b64_json").default("b64_json"),size:E.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),Vo=E.z.object({result:E.z.string()});async function We(n,e){let t=kt.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 L=require("zod"),Ut=L.z.object({prompt:L.z.string(),size:L.z.enum(["256x256","512x512","1024x1024"]).default("512x512")}),Yo=L.z.object({url:L.z.string().url()});async function Je(n,e){let t=Ut.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 d=require("zod"),Lt=d.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"]),Bt=d.z.enum(["NONE","FAST_BLUE","FAST_GREEN","SIMPLE","SLOW","SLOWER","SLOWEST"]),$t=d.z.object({text_prompts:d.z.array(d.z.object({text:d.z.string(),weight:d.z.number().min(-1).max(1).default(1)})).refine(n=>n.length>0,"Must have at least one text prompt"),model:Lt.default("stable-diffusion-v1-5"),clip_guidance_preset:Bt.optional(),steps:d.z.number().min(0).max(150).optional(),sampler:d.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:d.z.number().min(0).max(35).optional(),seed:d.z.number().min(0).optional(),height:d.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64"),width:d.z.number().min(128).optional().refine(n=>typeof n<"u"?n%64===0:!0,"Must be a multiple of 64")}),Xo=d.z.object({result:d.z.instanceof(ArrayBuffer)});async function qe(n,e){let t=$t.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 W=require("zod"),Ht=W.z.object({text:W.z.string()}),er=W.z.object({text:W.z.string()});async function Ve(n){return{text:Ht.parse(n).text.replace(/\$context\..*?\..*?\$/gm,"").trim()}}var B=require("zod"),Ft=B.z.object({text:B.z.string(),amount:B.z.number().optional().default(8)}),nr=B.z.object({text:B.z.string()}),Wt={"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 Jt(n){return Object.entries(Wt).map(([e,t])=>`Title: ${e} | ||
Description: ${t.slice(0,n).join(", ")} | ||
`).join(` | ||
`)}async function X(n){let e=Me.parse(n);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following | ||
${Oe(e.amount)} | ||
`)}async function Ge(n){let e=Ft.parse(n);return{text:`Write a maximum of ${e.amount} keywords in a csv list that describes the following | ||
${Jt(e.amount)} | ||
Title: ${e.text} | ||
Description:`}}var g=require("zod"),Ce=g.z.object({strings:g.z.record(g.z.string(),g.z.string()),modifier:g.z.string()}),At=g.z.object({text:g.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 x=require("zod"),Ee=x.z.object({text:x.z.string().or(x.z.array(x.z.string())),modifier:x.z.string()}),Nt=x.z.object({text:x.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"),_=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},je=_.transform(n=>L(n)),Dt=l.z.object({text:l.z.string()});async function ee(n,e){let t=je.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"),k=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)}),Ct=d.z.object({text:d.z.string()});async function te(n,e){let t=k.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"),N=require("zod");var ze=k.merge(N.z.object({stream:N.z.literal(!0).optional().default(!0)})),_t=N.z.object({stream:N.z.instanceof(globalThis.ReadableStream??Object)});async function oe(n,e){let t=ze.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 Ue(o)}}async function Ue(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"),M=require("zod");var _e=_.merge(M.z.object({stream:M.z.literal(!0).optional().default(!0)})).strict(),Le=_e.transform(n=>L(n)),Bt=M.z.object({stream:M.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 ke(t,r)}}async function ke(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,w=t.encode(y);a.enqueue(w)}catch(c){a.error(c)}}}let p=(0,re.createParser)(i);for await(let s of e.body)p.feed(o.decode(s))}})}var D=require("zod"),Ke=D.z.object({string:D.z.string()}),Wt=D.z.object({arrayBuffer:D.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"),$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"})}),Vt=f.z.object({audio:f.z.string()});async function se(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"),Be="https://transcribe.whisperapi.com",Fe=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")}),Gt=h.z.object({text:h.z.string()});async function pe(n,e){let t=Fe.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(Be,{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 We(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,hf,output,replaceMultipleStrings,replaceString,stabilityTextToImage,stringToArrayBuffer,vercelEdgeFunction,vercelGenericEdge,whisperApi}); | ||
Description:`}}var N=require("zod"),qt=N.z.object({strings:N.z.record(N.z.string(),N.z.string()),modifier:N.z.string()}),rr=N.z.object({text:N.z.string()});async function Ye(n){let e=qt.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 M=require("zod"),Vt=M.z.object({text:M.z.string().or(M.z.array(M.z.string())),modifier:M.z.string()}),ir=M.z.object({text:M.z.string()});async function Qe(n){let e=Vt.parse(n);return{text:e.modifier.replace(/\$\(text\)\$/gm,Array.isArray(e.text)?e.text.join(", "):e.text)}}var P=require("zod"),te=P.z.object({prompt:P.z.string(),model:P.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:P.z.number().min(0).max(2).default(.7),top_p:P.z.number().min(0).max(1).default(1),frequency_penalty:P.z.number().min(-2).max(2).default(0),presence_penalty:P.z.number().min(-2).max(2).default(0),max_tokens:P.z.number().default(200),n:P.z.number().default(1)}).strict(),ne=n=>{if(n.model==="gpt-3.5-turbo"){let{prompt:e,...t}=n;return{...t,messages:[{role:"user",content:n.prompt}]}}return n},Gt=te.transform(n=>ne(n)),pr=P.z.object({text:P.z.string()});async function Xe(n,e){let t=Gt.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 y=require("zod"),oe=y.z.object({messages:y.z.array(y.z.object({role:y.z.enum(["user","system","assistant"]),content:y.z.string()})).nonempty(),model:y.z.enum(["gpt-3.5-turbo"]).default("gpt-3.5-turbo"),temperature:y.z.number().min(0).max(2).default(.7),top_p:y.z.number().min(0).max(1).default(1),frequency_penalty:y.z.number().min(-2).max(2).default(0),presence_penalty:y.z.number().min(-2).max(2).default(0),max_tokens:y.z.number().default(200),n:y.z.number().default(1)}),ur=y.z.object({text:y.z.string()});async function Ze(n,e){let t=oe.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 et=require("eventsource-parser"),J=require("zod");var Yt=oe.merge(J.z.object({stream:J.z.literal(!0).optional().default(!0)})),yr=J.z.object({stream:J.z.instanceof(globalThis.ReadableStream??Object)});async function tt(n,e){let t=Yt.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 Qt(o)}}async function Qt(n){let e=new TextEncoder,t=new TextDecoder;return new ReadableStream({async start(r){function a(c){if(c.type==="event"){let p=c.data;if(p==="[DONE]"){r.close();return}try{let f=JSON.parse(p).choices[0]?.delta.content,T=e.encode(f);r.enqueue(T)}catch(m){r.error(m)}}}let i=(0,et.createParser)(a);for await(let c of n.body)i.feed(t.decode(c))}})}var nt=require("eventsource-parser"),q=require("zod");var Xt=te.merge(q.z.object({stream:q.z.literal(!0).optional().default(!0)})).strict(),Zt=Xt.transform(n=>ne(n)),br=q.z.object({stream:q.z.instanceof(globalThis.ReadableStream??Object)});async function ot(n,e){let t=Zt.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 en(t,r)}}async function en(n,e){let t=new TextEncoder,o=new TextDecoder;return new ReadableStream({async start(a){function i(p){if(p.type==="event"){let m=p.data;if(m==="[DONE]"){a.close();return}try{let f=JSON.parse(m),T=n.model==="gpt-3.5-turbo"?f.choices[0]?.delta.content:f.choices[0].text,$=t.encode(T);a.enqueue($)}catch(f){a.error(f)}}}let c=(0,nt.createParser)(i);for await(let p of e.body)c.feed(o.decode(p))}})}var V=require("zod"),tn=V.z.object({string:V.z.string()}),Pr=V.z.object({arrayBuffer:V.z.instanceof(ArrayBuffer)});async function rt(n){let e=tn.parse(n);return{arrayBuffer:Uint8Array.from(atob(e.string),o=>o.charCodeAt(0)).buffer}}var w=require("zod"),nn=w.z.object({text:w.z.string(),speakingRate:w.z.number().min(.25).max(4).optional().default(1),pitch:w.z.number().min(-20).max(20).optional().default(0),encoding:w.z.enum(["MP3","FLAC","LINEAR16","MULAW","AMR","AMR_WB","OGG_OPUS","SPEEX_WITH_HEADER_BYTE","WEBM_OPUS"]).optional().default("MP3"),voice:w.z.object({language:w.z.string().optional().default("en-US"),name:w.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(w.z.string()).optional().default("en-US-Neural2-C")}).optional().default({language:"en-US",name:"en-US-Neural2-C"})}),vr=w.z.object({audio:w.z.string()});async function at(n,e){let t=nn.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 R=require("zod"),on="https://transcribe.whisperapi.com",rn=R.z.object({audioUrl:R.z.string().url(),language:R.z.string().default("en"),autoDetectLanguage:R.z.boolean().default(!1),fileType:R.z.string().default("mp3"),task:R.z.enum(["transcribe","translate"]).default("transcribe")}),jr=R.z.object({text:R.z.string()});async function it(n,e){let t=rn.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(on,{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 re(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"),c=n[i];return{output:await c.invoke(r,{pipelineInstanceId:t,userId:o}),pipeline:c}}function an(n){return async e=>{let t=await re(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,audioClassification,automaticSpeechRecognition,cleanContextVars,conversational,createClient,dalleBase64TextToImage,dalleUrlTextToImage,enhanceWithKeywords,featureExtraction,fillMask,googleImageLabeling,googleTextToSpeech,gpt3Prediction,gpt3PredictionStream,gpt3TurboPrediction,gpt3TurboPredictionStream,hf,imageClassification,imageSegmentation,objectDetection,output,questionAnswer,replaceMultipleStrings,replaceString,stabilityTextToImage,stringToArrayBuffer,summarization,tableQuestionAnswer,textClassification,textGeneration,textToImage,tokenClassification,translation,vercelEdgeFunction,vercelGenericEdge,whisperApi,zeroShotClassification}); |
{ | ||
"name": "@aigur/client", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -14,3 +14,3 @@ export const inputSchema = z.object({ | ||
*/ | ||
data: z.instanceof(global.ArrayBuffer ?? Object), | ||
data: z.instanceof(ArrayBuffer), | ||
options: optionsSchema, | ||
@@ -17,0 +17,0 @@ }); |
@@ -6,3 +6,3 @@ import { z } from 'zod'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -15,3 +15,3 @@ // TODO: check if array buffer works instead of regular buffer | ||
*/ | ||
data: z.instanceof(global.ArrayBuffer ?? Object), | ||
data: z.instanceof(ArrayBuffer), | ||
options: optionsSchema, | ||
@@ -18,0 +18,0 @@ }); |
@@ -6,3 +6,3 @@ import { z } from 'zod'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -14,3 +14,3 @@ export const inputSchema = z.object({ | ||
*/ | ||
data: z.instanceof(global.ArrayBuffer ?? Object), | ||
data: z.instanceof(ArrayBuffer), | ||
options: optionsSchema, | ||
@@ -17,0 +17,0 @@ }); |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -14,3 +14,3 @@ export const inputSchema = z.object({ | ||
*/ | ||
data: z.instanceof(global.ArrayBuffer ?? Object), | ||
data: z.instanceof(ArrayBuffer), | ||
options: optionsSchema, | ||
@@ -17,0 +17,0 @@ }); |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -14,3 +14,3 @@ export const inputSchema = z.object({ | ||
*/ | ||
data: z.instanceof(global.ArrayBuffer ?? Object), | ||
data: z.instanceof(ArrayBuffer), | ||
options: optionsSchema, | ||
@@ -17,0 +17,0 @@ }); |
@@ -6,3 +6,3 @@ import { z } from 'zod'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -6,3 +6,3 @@ import { z } from 'zod'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -6,3 +6,3 @@ import { z } from 'zod'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -23,3 +23,3 @@ export const inputSchema = z.object({ | ||
export const outputSchema = z.object({ | ||
result: z.instanceof(global.ArrayBuffer ?? Object), | ||
result: z.instanceof(ArrayBuffer), | ||
}); | ||
@@ -26,0 +26,0 @@ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -6,3 +6,3 @@ import { z } from 'zod'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -5,4 +5,4 @@ import { z } from 'zod'; | ||
import { optionsSchema } from '../huggingface'; | ||
import { APIKeys } from '../../types'; | ||
import { optionsSchema } from './huggingface'; | ||
@@ -9,0 +9,0 @@ export const inputSchema = z.object({ |
@@ -1,2 +0,2 @@ | ||
export { hf } from './huggingface'; | ||
export * from './huggingface'; | ||
export { googleImageLabeling } from './image/labeling/googleImageLabeling'; | ||
@@ -3,0 +3,0 @@ export { dalleBase64TextToImage } from './image/textToImage/dalleBase64'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186886
59
4624