promptlayer 1.0.39 → 1.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var De=Object.defineProperty,Ye=Object.defineProperties;var Fe=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ne=(n,e)=>{if(e=Symbol[n])return e;throw Error("Symbol."+n+" is not defined")};var oe=(n,e,t)=>e in n?De(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e)=>{for(var t in e||(e={}))re.call(e,t)&&oe(n,t,e[t]);if(L)for(var t of L(e))se.call(e,t)&&oe(n,t,e[t]);return n},T=(n,e)=>Ye(n,Fe(e));var C=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var ae=(n,e)=>{var t={};for(var o in n)re.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&L)for(var o of L(n))e.indexOf(o)<0&&se.call(n,o)&&(t[o]=n[o]);return t};var u=(n,e,t)=>new Promise((o,r)=>{var s=i=>{try{p(t.next(i))}catch(c){r(c)}},a=i=>{try{p(t.throw(i))}catch(c){r(c)}},p=i=>i.done?o(i.value):Promise.resolve(i.value).then(s,a);p((t=t.apply(n,e)).next())}),A=function(n,e){this[0]=n,this[1]=e},J=(n,e,t)=>{var o=(a,p,i,c)=>{try{var l=t[a](p),m=(p=l.value)instanceof A,y=l.done;Promise.resolve(m?p[0]:p).then(f=>m?o(a==="return"?a:"next",p[1]?{done:f.done,value:f.value}:f,i,c):i({value:f,done:y})).catch(f=>o("throw",f,i,c))}catch(f){c(f)}},r=a=>s[a]=p=>new Promise((i,c)=>o(a,p,i,c)),s={};return t=t.apply(n,e),s[Symbol.asyncIterator]=()=>s,r("next"),r("throw"),r("return"),s};var D=(n,e,t)=>(e=n[ne("asyncIterator")])?e.call(n):(n=n[ne("iterator")](),e={},t=(o,r)=>(r=n[o])&&(e[o]=s=>new Promise((a,p,i)=>(s=r.call(n,s),i=s.done,Promise.resolve(s.value).then(c=>a({value:c,done:i}),p)))),t("next"),t("return"),e);import Ve from"ably";var Y="SET_WORKFLOW_COMPLETE";function Xe(n,e,t){return u(this,null,function*(){let o=yield fetch(`${R}/workflow-version-execution-results?workflow_version_execution_id=${n}&return_all_outputs=${e}`,{headers:t});if(!o.ok)throw new Error("Failed to fetch final output");return o.json()})}function ze(n,e,t,o){return function(r){return u(this,null,function*(){if(r.name===Y)try{let s=JSON.parse(r.data),a=s.result_code,p;if(a==="OK"||a==null)p=s.final_output;else if(a==="EXCEEDS_SIZE_LIMIT")p=yield Xe(e,t,o);else throw new Error(`Unsupported final output code: ${a}`);n.resolve(p)}catch(s){n.reject(s)}})}}function He(a){return u(this,arguments,function*({token:n,channelName:e,executionId:t,returnAllOutputs:o,headers:r,timeout:s}){let p=new Ve.Realtime(n),i=p.channels.get(e),c={},l=new Promise((y,f)=>{c.resolve=y,c.reject=f}),m=ze(c,t,o,r);yield i.subscribe(Y,m);try{return yield new Promise((y,f)=>{let _=setTimeout(()=>{f(new Error("Workflow execution did not complete properly (timeout)"))},s);l.then(w=>{clearTimeout(_),y(w)}).catch(w=>{clearTimeout(_),f(w)})})}finally{console.log("Closing client"),i.unsubscribe(Y,m),p.close(),console.log("Closed client")}})}var R=process.env.PROMPTLAYER_API_URL||"https://api.promptlayer.com",ce=(n,e)=>u(void 0,null,function*(){return e.request_response[Symbol.asyncIterator]!==void 0?Ze(n,e.request_response,e):yield pe(n,e)}),pe=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/track-request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=yield t.json();if(t.status!==200&&S(o,"WARNING: While logging your request, PromptLayer experienced the following error:"),o&&e.return_pl_id)return[e.request_response,o.request_id]}catch(t){console.warn(`WARNING: While logging your request PromptLayer had the following error: ${t}`)}return e.request_response}),le=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/library-track-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T(h({},e),{api_key:n}))}),o=yield t.json();if(t.status!==200)return S(o,"WARNING: While logging metadata to your request, PromptLayer experienced the following error"),!1}catch(t){return console.warn(`WARNING: While logging metadata to your request, PromptLayer experienced the following error: ${t}`),!1}return!0}),ue=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/library-track-score`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T(h({},e),{api_key:n}))}),o=yield t.json();if(t.status!==200)return S(o,"WARNING: While scoring your request, PromptLayer experienced the following error"),!1}catch(t){return console.warn(`WARNING: While scoring your request, PromptLayer experienced the following error: ${t}`),!1}return!0}),me=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/library-track-prompt`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T(h({},e),{api_key:n}))}),o=yield t.json();if(t.status!==200)return S(o,"WARNING: While associating your request with a prompt template, PromptLayer experienced the following error"),!1}catch(t){return console.warn(`WARNING: While associating your request with a prompt template, PromptLayer experienced the following error: ${t}`),!1}return!0}),fe=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/track-group`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T(h({},e),{api_key:n}))}),o=yield t.json();if(t.status!==200)return S(o,"WARNING: While associating your request with a group, PromptLayer experienced the following error"),!1}catch(t){return console.warn(`WARNING: While associating your request with a group, PromptLayer experienced the following error: ${t}`),!1}return!0}),de=n=>u(void 0,null,function*(){try{let e=yield fetch(`${R}/create-group`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:n})}),t=yield e.json();return e.status!==200?(S(t,"WARNING: While creating a group PromptLayer had the following error"),!1):t.id}catch(e){return console.warn(`WARNING: While creating a group PromptLayer had the following error: ${e}`),!1}}),he=(n,e,t)=>u(void 0,null,function*(){try{let o=new URL(`${R}/prompt-templates/${e}`),r=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":n},body:JSON.stringify(t)}),s=yield r.json();return r.status!==200?(S(s,"WARNING: While fetching a prompt template PromptLayer had the following error"),null):(s.warning&&console.warn(`WARNING: While fetching your prompt PromptLayer had the following error: ${s.warning}`),s)}catch(o){return console.warn(`WARNING: While fetching a prompt template PromptLayer had the following error: ${o}`),null}}),ye=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/rest/prompt-templates`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":n},body:JSON.stringify({prompt_template:h({},e),prompt_version:h({},e),release_labels:e.release_labels?e.release_labels:void 0})}),o=yield t.json();return t.status===400&&S(o,"WARNING: While publishing a prompt template PromptLayer had the following error"),o}catch(t){console.warn(`WARNING: While publishing a prompt template PromptLayer had the following error: ${t}`)}}),ge=(n,e)=>u(void 0,null,function*(){var t;try{let o=new URL(`${R}/prompt-templates`);Object.entries(e||{}).forEach(([a,p])=>o.searchParams.append(a,p.toString()));let r=yield fetch(o,{headers:{"Content-Type":"application/json","X-API-KEY":n}}),s=yield r.json();return r.status!==200?(S(s,"WARNING: While fetching all prompt templates PromptLayer had the following error"),null):(t=s.items)!=null?t:[]}catch(o){return console.warn(`WARNING: While fetching all prompt templates PromptLayer had the following error: ${o}`),null}}),_e=i=>u(void 0,[i],function*({workflow_name:n,input_variables:e,metadata:t={},workflow_label_name:o=null,workflow_version_number:r=null,return_all_outputs:s=!1,api_key:a,timeout:p=36e5}){let c={input_variables:e,metadata:t,workflow_label_name:o,workflow_version_number:r,return_all_outputs:s},l={"X-API-KEY":a,"Content-Type":"application/json"};try{let m=yield fetch(`${R}/workflows/${encodeURIComponent(n)}/run`,{method:"POST",headers:l,body:JSON.stringify(c)});if(m.status!==201)return{success:!1,message:`Failed to run workflow: ${(yield m.json().catch(()=>({}))).error||m.statusText}`};let y=yield m.json();y.warning&&console.warn(`WARNING: ${y.warning}`);let f=y.workflow_version_execution_id;if(!f)return console.log("No execution ID returned from workflow run"),{success:!1,message:"Failed to run workflow"};let _=`workflow_updates:${f}`,O=(yield(yield fetch(`${R}/ws-token-request-library?capability=${_}`,{method:"POST",headers:l})).json()).token_details.token;return yield He({token:O,channelName:_,executionId:f,returnAllOutputs:s,headers:l,timeout:p})}catch(m){throw console.error(`Failed to run workflow: ${m instanceof Error?m.message:m}`),m}}),F=n=>{var p,i,c,l,m,y,f,_,w,b;let e=null,t,o={id:"",choices:[],created:Date.now(),model:"",object:"chat.completion"},r=n.at(-1);if(!r)return o;let s;for(let O of n){if(O.choices.length===0)continue;let g=O.choices[0].delta;g.content&&(e=`${e||""}${g.content||""}`),g.function_call&&(t={name:`${t?t.name:""}${g.function_call.name||""}`,arguments:`${t?t.arguments:""}${g.function_call.arguments||""}`});let d=(p=g.tool_calls)==null?void 0:p[0];if(d){s=s||[];let P=s.at(-1);if(!P||d.id){s.push({id:d.id||"",type:d.type||"function",function:{name:((i=d.function)==null?void 0:i.name)||"",arguments:((c=d.function)==null?void 0:c.arguments)||""}});continue}P.function.name=`${P.function.name}${((l=d.function)==null?void 0:l.name)||""}`,P.function.arguments=`${P.function.arguments}${((m=d.function)==null?void 0:m.arguments)||""}`}}let a=n[0].choices.at(0);return o.choices.push({finish_reason:(y=a==null?void 0:a.finish_reason)!=null?y:"stop",index:(f=a==null?void 0:a.index)!=null?f:0,logprobs:(_=a==null?void 0:a.logprobs)!=null?_:null,message:{role:"assistant",content:e,function_call:t||void 0,tool_calls:s||void 0,refusal:(w=a==null?void 0:a.delta.refusal)!=null?w:null}}),o.id=r.id,o.model=r.model,o.created=r.created,o.system_fingerprint=r.system_fingerprint,o.usage=(b=r.usage)!=null?b:void 0,o},we=n=>{var i;let e={id:"",model:"",content:[],role:"assistant",type:"message",stop_reason:"stop_sequence",stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,server_tool_use:null,service_tier:null}};if(!n.at(-1))return e;let o=null,r="",s="",a="",p="";for(let c of n)if(c.type==="message_start")e=h({},c.message);else if(c.type==="content_block_start")o=h({},c.content_block),o.type==="thinking"?(r="",s=""):o.type==="text"?a="":(o.type==="tool_use"||o.type==="server_tool_use")&&(p="");else if(c.type==="content_block_delta"&&o!==null){if(o.type==="thinking")"signature"in c.delta&&(r=c.delta.signature||""),"thinking"in c.delta&&(s+=c.delta.thinking||"");else if(o.type==="text")"text"in c.delta&&(a+=c.delta.text||"");else if((o.type==="tool_use"||o.type==="server_tool_use")&&c.delta.type==="input_json_delta"){let l=c.delta;p+=l.partial_json||""}}else if(c.type==="content_block_stop"&&o!==null){if(o.type==="thinking")o.signature=r,o.thinking=s;else if(o.type==="text")o.text=a,o.citations=null;else if(o.type==="tool_use"||o.type==="server_tool_use")try{o.input=p?JSON.parse(p):{}}catch(l){o.input={}}e.content.push(o),o=null,r="",s="",a="",p=""}else c.type==="message_delta"&&("usage"in c&&c.usage&&(e.usage=T(h({},e.usage),{output_tokens:(i=c.usage.output_tokens)!=null?i:0})),"delta"in c&&c.delta&&("stop_reason"in c.delta&&c.delta.stop_reason!==void 0&&(e.stop_reason=c.delta.stop_reason),"stop_sequence"in c.delta&&c.delta.stop_sequence!==void 0&&(e.stop_sequence=c.delta.stop_sequence)));return e},Be=(n,e="openai.chat.completions.create")=>{if("completion"in n[0])return n.reduce((t,o)=>T(h({},o),{completion:`${t.completion}${o.completion}`}),{});if(e==="anthropic.messages.create")return we(n);if("text"in n[0].choices[0]){let t="";for(let r of n)t=`${t}${r.choices[0].text}`;let o=structuredClone(n.at(-1));return o.choices[0].text=t,o}if("delta"in n[0].choices[0]){let t=F(n);return t.choices[0]=h(h({},t.choices[0]),t.choices[0].message),t}return""};function Ze(n,e,t){return J(this,null,function*(){let o=[];try{for(var a=D(e),p,i,c;p=!(i=yield new A(a.next())).done;p=!1){let l=i.value;yield t.return_pl_id?[l,null]:l,o.push(l)}}catch(i){c=[i]}finally{try{p&&(i=a.return)&&(yield new A(i.call(a)))}finally{if(c)throw c[0]}}let r=Be(o,t.function_name),s=yield new A(pe(n,T(h({},t),{request_response:r,request_end_time:new Date().toISOString()})));if(s&&t.return_pl_id){let l=s[1];yield[o.at(-1),l]}})}var S=(n,e)=>{try{console.warn(`${e}: ${n.message}`)}catch(t){console.warn(`${e}: ${n}`)}},Pe=n=>u(void 0,null,function*(){try{let e=yield fetch(`${R}/track-request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),t=yield e.json();return e.status!==200&&S(t,"WARNING: While logging your request, PromptLayer experienced the following error:"),t}catch(e){console.warn(`WARNING: While logging your request PromptLayer had the following error: ${e}`)}return{}}),ie=n=>{let e={id:"",choices:[{finish_reason:"stop",index:0,text:"",logprobs:null}],created:Date.now(),model:"",object:"text_completion"},t=n.at(-1);if(!t)return e;let o="";for(let r of n)r.choices.length>0&&r.choices[0].text&&(o=`${o}${r.choices[0].text}`);return e.choices[0].text=o,e.id=t.id,e.created=t.created,e.model=t.model,e.system_fingerprint=t.system_fingerprint,e.usage=t.usage,e},Qe=n=>{let e={completion:"",id:"",model:"",stop_reason:"",type:"completion"},t=n.at(-1);if(!t)return e;let o="";for(let r of n)o=`${o}${r.completion}`;return e.completion=o,e.id=t.id,e.model=t.model,e.stop_reason=t.stop_reason,e};function Re(n,e,t){return J(this,null,function*(){let o={request_id:null,raw_response:null,prompt_blueprint:null},r=[];try{for(var p=D(n),i,c,l;i=!(c=yield new A(p.next())).done;i=!1){let m=c.value;r.push(m),o.raw_response=m,yield o}}catch(c){l=[c]}finally{try{i&&(c=p.return)&&(yield new A(c.call(p)))}finally{if(l)throw l[0]}}let s=t(r),a=yield new A(e({request_response:s}));o.request_id=a.request_id,o.prompt_blueprint=a.prompt_blueprint,yield o})}var et=(n,e)=>u(void 0,null,function*(){return n.chat.completions.create(e)}),tt=(n,e)=>u(void 0,null,function*(){return n.completions.create(e)}),Te={chat:et,completion:tt},Se=(n,e)=>u(void 0,null,function*(){let t=C("openai").default,o=new t({baseURL:e.baseURL,apiKey:e.apiKey}),r=Te[n.prompt_template.type];return r(o,e)}),Oe=(n,e)=>u(void 0,null,function*(){let{AzureOpenAI:t}=C("openai"),o=new t({endpoint:process.env.AZURE_OPENAI_ENDPOINT||e.baseURL,apiVersion:process.env.OPENAI_API_VERSION||e.apiVersion,apiKey:process.env.AZURE_OPENAI_API_KEY||e.apiKey});e==null||delete e.baseURL,e==null||delete e.apiVersion,e==null||delete e.apiKey;let r=Te[n.prompt_template.type];return r(o,e)}),Ee=(n,e)=>u(void 0,null,function*(){return n.messages.create(e)}),nt=(n,e)=>u(void 0,null,function*(){return n.completions.create(e)}),ot={chat:Ee,completion:nt},be=(n,e)=>u(void 0,null,function*(){let t=C("@anthropic-ai/sdk").default,o=new t({baseURL:e.baseURL}),r=ot[n.prompt_template.type];return r(o,e)}),Ae=(n,e)=>u(void 0,null,function*(){try{let t=yield fetch(`${R}/log-request`,{method:"POST",headers:{"X-API-KEY":n,"Content-Type":"application/json"},body:JSON.stringify(e)}),o=yield t.json();return t.status!==201?(S(o,"WARNING: While logging your request PromptLayer had the following error"),null):o}catch(t){return console.warn(`WARNING: While tracking your prompt PromptLayer had the following error: ${t}`),null}}),rt=(n,e,t,o)=>{var a,p;let r=h({},o),s=[];if(n){let i={text:n,thought:!0};s.push(i)}if(e){let i={text:e,thought:null};s.push(i)}for(let i of t){let c={function_call:i};s.push(c)}return s.length>0&&((p=(a=r.candidates)==null?void 0:a[0])!=null&&p.content)&&(r.candidates[0].content.parts=s),r},Ce=n=>{var s,a;let{GenerateContentResponse:e}=C("@google/genai");if(!n.length)return new e;let t="",o="",r=[];for(let p of n)if(p.candidates&&((a=(s=p.candidates[0])==null?void 0:s.content)!=null&&a.parts))for(let i of p.candidates[0].content.parts)i.text?i.thought===!0?t+=i.text:o+=i.text:i.functionCall&&r.push(i.functionCall);return rt(t,o,r,n[n.length-1])},st=n=>Ce(n),at=n=>Ce(n),it=(n,e)=>u(void 0,null,function*(){var a,p;let t=e==null?void 0:e.history,o=e==null?void 0:e.generationConfig,r=t.length>0?(a=t[t.length-1])==null?void 0:a.parts:"",s=n.chats.create({model:e==null?void 0:e.model,history:(p=t.slice(0,-1))!=null?p:[],config:o});return e!=null&&e.stream?yield s.sendMessageStream({message:r}):yield s.sendMessage({message:r})}),ct=(n,o)=>u(void 0,null,function*(){var r=o,{stream:e}=r,t=ae(r,["stream"]);return e?yield n.generateContentStream(h({},t)):yield n.generateContent(h({},t))}),pt={chat:it,completion:ct},X=(n,e)=>u(void 0,null,function*(){let{GoogleGenAI:t}=yield import("@google/genai"),o=process.env.GOOGLE_API_KEY||process.env.GEMINI_API_KEY,r=process.env.VERTEX_AI_PROJECT_ID||process.env.GOOGLE_PROJECT_ID||process.env.GOOGLE_CLOUD_PROJECT,s=process.env.VERTEX_AI_PROJECT_LOCATION||process.env.GOOGLE_PROJECT_LOCATION||process.env.GOOGLE_CLOUD_PROJECT_LOCATION,a={keyFilename:process.env.GOOGLE_APPLICATION_CREDENTIALS,projectId:r,scopes:["https://www.googleapis.com/auth/cloud-platform"]},p=o?new t({apiKey:o}):new t({vertexai:!0,project:r,location:s,googleAuthOptions:a}),i=pt[n.prompt_template.type],c=V(e);return c.generationConfig&&(c.generationConfig=V(c.generationConfig)),yield i(p,c)}),lt=n=>n.replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),V=n=>!n||typeof n!="object"?n:Array.isArray(n)?n.map(V):Object.fromEntries(Object.entries(n).map(([e,t])=>[lt(e),t])),ut=["openai","openai.azure"],mt={openai:{chat:{function_name:"openai.chat.completions.create",stream_function:F},completion:{function_name:"openai.completions.create",stream_function:ie}},anthropic:{chat:{function_name:"anthropic.messages.create",stream_function:we},completion:{function_name:"anthropic.completions.create",stream_function:Qe}},"openai.azure":{chat:{function_name:"openai.AzureOpenAI.chat.completions.create",stream_function:F},completion:{function_name:"openai.AzureOpenAI.completions.create",stream_function:ie}},google:{chat:{function_name:"google.convo.send_message",stream_function:st},completion:{function_name:"google.model.generate_content",stream_function:at}}},Ie=(n,e,t={},o=!1)=>{var p,i,c,l,m;let r=(c=e==null?void 0:e.client)!=null?c:(i=(p=n.metadata)==null?void 0:p.model)==null?void 0:i.provider;if(!r)throw new Error("Provider type not found in prompt blueprint or custom provider");let s=T(h(h({},n.llm_kwargs||{}),t),{stream:o}),a={baseURL:(m=e==null?void 0:e.base_url)!=null?m:(l=n.provider_base_url)==null?void 0:l.url,apiKey:e==null?void 0:e.api_key};return Object.entries(a).forEach(([y,f])=>{f!==void 0&&(s[y]=f)}),o&&ut.includes(r)&&(s.stream_options={include_usage:!0}),{provider_type:r,kwargs:s}},Ne=(n,e)=>{let t=mt[n];if(!t)throw new Error(`Unsupported provider type: ${n}`);let o=e.type,r=t[o];if(!r)throw new Error(`Unsupported template type '${e.type}' for provider '${n}'`);return r},ke=(n,e)=>u(void 0,null,function*(){var o;let t=(o=n.metadata)==null?void 0:o.model;if(!t)throw new Error("Model metadata not found in prompt blueprint");if(t.name.startsWith("gemini"))return X(n,e);if(t.name.startsWith("claude")){let{AnthropicVertex:r}=yield import("@anthropic-ai/vertex-sdk"),s=new r({baseURL:e.baseURL});if(n.prompt_template.type==="chat")return Ee(s,e);throw new Error(`Unsupported prompt template type '${n.prompt_template.type}' for Anthropic Vertex AI`)}throw new Error(`Unsupported model name '${t.name}' for Vertex AI request`)});var v=class{constructor(e){this.create=()=>de(this.apiKey);this.apiKey=e}};import*as Le from"@opentelemetry/api";import{SimpleSpanProcessor as ft}from"@opentelemetry/sdk-trace-base";import{NodeTracerProvider as dt}from"@opentelemetry/sdk-trace-node";import{SpanKind as q,SpanStatusCode as z}from"@opentelemetry/api";import{ExportResultCode as x}from"@opentelemetry/core";var H=class{constructor(e,t){this.apiKey=t||process.env.PROMPTLAYER_API_KEY,this.enableTracing=e,this.url=`${R}/spans-bulk`}attributesToObject(e){return e?Object.fromEntries(Object.entries(e)):{}}spanKindToString(e){return{[q.INTERNAL]:"SpanKind.INTERNAL",[q.SERVER]:"SpanKind.SERVER",[q.CLIENT]:"SpanKind.CLIENT",[q.PRODUCER]:"SpanKind.PRODUCER",[q.CONSUMER]:"SpanKind.CONSUMER"}[e]||"SpanKind.INTERNAL"}statusCodeToString(e){return{[z.ERROR]:"StatusCode.ERROR",[z.OK]:"StatusCode.OK",[z.UNSET]:"StatusCode.UNSET"}[e]||"StatusCode.UNSET"}toNanoseconds(e){return(BigInt(e[0])*BigInt(1e9)+BigInt(e[1])).toString()}export(e){if(!this.enableTracing)return Promise.resolve(x.SUCCESS);let t=e.map(o=>{var r;return{name:o.name,context:{trace_id:o.spanContext().traceId,span_id:o.spanContext().spanId,trace_state:((r=o.spanContext().traceState)==null?void 0:r.serialize())||""},kind:this.spanKindToString(o.kind),parent_id:o.parentSpanId||null,start_time:this.toNanoseconds(o.startTime),end_time:this.toNanoseconds(o.endTime),status:{status_code:this.statusCodeToString(o.status.code),description:o.status.message},attributes:this.attributesToObject(o.attributes),events:o.events.map(s=>({name:s.name,timestamp:this.toNanoseconds(s.time),attributes:this.attributesToObject(s.attributes)})),links:o.links.map(s=>({context:s.context,attributes:this.attributesToObject(s.attributes)})),resource:{attributes:T(h({},o.resource.attributes),{"service.name":"prompt-layer-js"}),schema_url:""}}});return fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.apiKey||""},body:JSON.stringify({spans:t})}).then(o=>o.ok?x.SUCCESS:(console.error(`Error exporting spans
2
- HTTP error! status: ${o.status}`),x.FAILED)).catch(o=>(console.error("Error exporting spans:",o),x.FAILED))}shutdown(){return Promise.resolve()}},qe=H;var I=(n="promptlayer-tracer")=>Le.trace.getTracer(n),ve=(n,e)=>{let t=new dt,o=new qe(n,e),r=new ft(o);t.addSpanProcessor(r),t.register()};var ht=I(),B=(n,e,t="",o="openai")=>{let r={construct:(s,a)=>{let p=Reflect.construct(s,a);return Object.defineProperties(p,{function_name:{value:t,writable:!0},provider:{value:o}}),new Proxy(p,r)},get:(s,a,p)=>{let i=s[a],c=`${Reflect.get(s,"function_name")}.${a.toString()}`;return typeof i=="object"?(Object.defineProperties(i,{function_name:{value:c,writable:!0},provider:{value:o}}),new Proxy(i,r)):typeof i=="function"?(...l)=>{var w,b,O,g;let m=new Date().toISOString(),y=Reflect.get(s,"provider"),f=(w=l[0])==null?void 0:w.return_pl_id,_=(b=l[0])==null?void 0:b.pl_tags;return(O=l[0])==null||delete O.return_pl_id,(g=l[0])==null||delete g.pl_tags,ht.startActiveSpan(`${y}.${c}`,d=>u(void 0,null,function*(){try{d.setAttribute("function_input",JSON.stringify(l));let P=Reflect.apply(i,s,l),N=d.spanContext().spanId;return P instanceof Promise?new Promise((K,M)=>{P.then(E=>u(void 0,null,function*(){let k=yield ce(n,{api_key:n,provider_type:y,function_name:c,request_start_time:m,request_end_time:new Date().toISOString(),request_response:E,kwargs:l[0],return_pl_id:f,tags:_,span_id:N});d.setAttribute("function_output",JSON.stringify(k)),d.setAttribute("response_status","success"),d.end(),K(k)})).catch(E=>{d.recordException(E),d.setAttribute("response_status","error"),d.end(),M(E)})}):(d.setAttribute("function_output",JSON.stringify(P)),d.setAttribute("response_status","success"),d.end(),P)}catch(P){throw d.recordException(P),d.setAttribute("response_status","error"),d.end(),P}}))}:Reflect.get(s,a,p)}};return new Proxy(e,r)};import*as W from"@opentelemetry/api";var We=(n,e,t)=>function(...o){let r=I(),s=a=>{try{t&&Object.entries(t).forEach(([i,c])=>{a.setAttribute(i,c)}),a.setAttribute("function_input",JSON.stringify(o));let p=e(...o);return p instanceof Promise?p.then(i=>(a.setAttribute("function_output",JSON.stringify(i)),a.setStatus({code:W.SpanStatusCode.OK}),i)).catch(i=>{throw xe(a,i,o),i}).finally(()=>a.end()):(a.setAttribute("function_output",JSON.stringify(p)),a.setStatus({code:W.SpanStatusCode.OK}),a.end(),p)}catch(p){throw xe(a,p,o),p}};return r.startActiveSpan(n,s)},xe=(n,e,t)=>{n.setAttribute("function_input",JSON.stringify(t)),n.setStatus({code:W.SpanStatusCode.ERROR,message:e instanceof Error?e.message:"Unknown error"}),n.end()};var $=class{constructor(e){this.get=(e,t)=>he(this.apiKey,e,t);this.publish=e=>ye(this.apiKey,e);this.all=e=>ge(this.apiKey,e);this.apiKey=e}};var yt=(n,e)=>{if(!(e.metadata instanceof Object))throw new Error("Please provide a dictionary of metadata.");for(let[t,o]of Object.entries(e.metadata))if(typeof t!="string"||typeof o!="string")throw new Error("Please provide a dictionary of metadata with key value pair of strings.");return le(n,e)},gt=(n,e)=>{if(typeof e.score!="number")throw new Error("Score must be a number");if(e.score<0||e.score>100)throw new Error("Score must be a number between 0 and 100.");return ue(n,e)},_t=(n,e)=>{if(!(e.prompt_input_variables instanceof Object))throw new Error("Prompt template input variable dictionary not provided.");return me(n,e)},wt=(n,e)=>fe(n,e),G=class{constructor(e){this.group=e=>wt(this.apiKey,e);this.metadata=e=>yt(this.apiKey,e);this.prompt=e=>_t(this.apiKey,e);this.score=e=>gt(this.apiKey,e);this.apiKey=e}};import*as Ge from"@opentelemetry/api";var Pt={openai:Se,anthropic:be,"openai.azure":Oe,google:X,vertexai:ke},Rt=n=>{if(!n||typeof n!="object"||Array.isArray(n))return!1;let e=["status","value","error_message","raw_error_message","is_output_node"];return Object.values(n).every(o=>typeof o!="object"||o===null?!1:e.every(r=>r in o))},$e=class{constructor({apiKey:e=process.env.PROMPTLAYER_API_KEY,enableTracing:t=!1}={}){if(e===void 0)throw new Error("PromptLayer API key not provided. Please set the PROMPTLAYER_API_KEY environment variable or pass the api_key parameter.");this.apiKey=e,this.enableTracing=t,this.templates=new $(e),this.group=new v(e),this.track=new G(e),this.wrapWithSpan=We,t&&ve(t,e)}get Anthropic(){try{let e=C("@anthropic-ai/sdk").default;return B(this.apiKey,e,"anthropic","anthropic")}catch(e){console.error("To use the Anthropic module, you must install the @anthropic-ai/sdk package.")}}get OpenAI(){try{let e=C("openai").default;return B(this.apiKey,e,"openai","openai")}catch(e){console.error("To use the OpenAI module, you must install the @openai/api package.")}}run(y){return u(this,arguments,function*({promptName:e,promptVersion:t,promptReleaseLabel:o,inputVariables:r,tags:s,metadata:a,groupId:p,modelParameterOverrides:i,stream:c=!1,provider:l,model:m}){return I().startActiveSpan("PromptLayer Run",_=>u(this,null,function*(){try{let w={promptName:e,promptVersion:t,promptReleaseLabel:o,inputVariables:r,tags:s,metadata:a,groupId:p,modelParameterOverrides:i,stream:c};_.setAttribute("function_input",JSON.stringify(w));let b=r,O={label:o,version:t,metadata_filters:a,provider:l,model:m};r&&(O.input_variables=r);let g=yield this.templates.get(e,O);if(!g)throw new Error("Prompt not found");let d=g.prompt_template;g.llm_kwargs||console.warn(`Prompt '${e}' does not have any LLM kwargs associated with it. Please set your model parameters in the registry in the PromptLayer dashbaord.`);let P=g.metadata;if(!P)throw new Error(`Prompt '${e}' does not have any metadata associated with it.`);let N=P.model;if(!N)throw new Error(`Prompt '${e}' does not have a model parameters associated with it.`);let K=g.custom_provider,M=new Date().toISOString(),{provider_type:E,kwargs:k}=Ie(g,K,i,c),j=E;N.name.startsWith("gemini")?j="google":N.name.startsWith("claude")&&(j="anthropic");let Ke=Ne(j,d),{function_name:Me,stream_function:je}=Ke,Z=Pt[E];if(!Z)throw new Error(`No request function found for provider: ${E}`);let U=yield Z(g,k),Q=Ue=>{let Je=new Date().toISOString();return Pe(h({function_name:Me,provider_type:E,args:[],kwargs:k,tags:s,request_start_time:M,request_end_time:Je,api_key:this.apiKey,metadata:a,prompt_id:g.id,prompt_version:g.version,prompt_input_variables:b,group_id:p,return_prompt_blueprint:!0,span_id:_.spanContext().spanId},Ue))};if(c)return Re(U,Q,je);let ee=yield Q({request_response:U}),te={request_id:ee.request_id,raw_response:U,prompt_blueprint:ee.prompt_blueprint};return _.setAttribute("function_output",JSON.stringify(te)),te}catch(w){throw _.setStatus({code:Ge.SpanStatusCode.ERROR,message:w instanceof Error?w.message:"Unknown error"}),w}finally{_.end()}}))})}runWorkflow(p){return u(this,arguments,function*({workflowName:e,inputVariables:t={},metadata:o={},workflowLabelName:r=null,workflowVersion:s=null,returnAllOutputs:a=!1}){try{let i=yield _e({workflow_name:e,input_variables:t,metadata:o,workflow_label_name:r,workflow_version_number:s,return_all_outputs:a,api_key:this.apiKey});if(!a&&Rt(i)){let l=Object.values(i).filter(y=>y.is_output_node===!0);if(l.length===0)throw new Error(JSON.stringify(i,null,2));if(!l.some(y=>y.status==="SUCCESS"))throw new Error(JSON.stringify(i,null,2))}return i}catch(i){throw i instanceof Error?(console.error("Error running workflow:",i.message),new Error(`Error running workflow: ${i.message}`)):(console.error("Unknown error running workflow:",i),new Error("Unknown error running workflow"))}})}logRequest(e){return u(this,null,function*(){return Ae(this.apiKey,e)})}};export{$e as PromptLayer};
1
+ var tt=Object.defineProperty,nt=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var ce=(t,e)=>{if(e=Symbol[t])return e;throw Error("Symbol."+t+" is not defined")};var pe=(t,e,n)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))le.call(e,n)&&pe(t,n,e[n]);if(L)for(var n of L(e))ue.call(e,n)&&pe(t,n,e[n]);return t},R=(t,e)=>nt(t,ot(e));var I=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var v=(t,e)=>{var n={};for(var o in t)le.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&L)for(var o of L(t))e.indexOf(o)<0&&ue.call(t,o)&&(n[o]=t[o]);return n};var u=(t,e,n)=>new Promise((o,r)=>{var s=i=>{try{c(n.next(i))}catch(p){r(p)}},a=i=>{try{c(n.throw(i))}catch(p){r(p)}},c=i=>i.done?o(i.value):Promise.resolve(i.value).then(s,a);c((n=n.apply(t,e)).next())}),E=function(t,e){this[0]=t,this[1]=e},Y=(t,e,n)=>{var o=(a,c,i,p)=>{try{var m=n[a](c),f=(c=m.value)instanceof E,l=m.done;Promise.resolve(f?c[0]:c).then(d=>f?o(a==="return"?a:"next",c[1]?{done:d.done,value:d.value}:d,i,p):i({value:d,done:l})).catch(d=>o("throw",d,i,p))}catch(d){p(d)}},r=a=>s[a]=c=>new Promise((i,p)=>o(a,c,i,p)),s={};return n=n.apply(t,e),s[Symbol.asyncIterator]=()=>s,r("next"),r("throw"),r("return"),s};var B=(t,e,n)=>(e=t[ce("asyncIterator")])?e.call(t):(t=t[ce("iterator")](),e={},n=(o,r)=>(r=t[o])&&(e[o]=s=>new Promise((a,c,i)=>(s=r.call(t,s),i=s.done,Promise.resolve(s.value).then(p=>a({value:p,done:i}),c)))),n("next"),n("return"),e);import rt from"ably";var G=(t,e,n)=>({id:t,function:{name:e,input:n}}),C=n=>{var o=n,{type:t}=o,e=v(o,["type"]);return y({type:t},e)},V=(t,e)=>({input_variables:[],template_format:"f-string",content:t,role:"assistant",function_call:null,name:null,tool_calls:e}),X=(t,e)=>({prompt_template:{messages:[t],type:"chat",input_variables:[]},metadata:e}),me=(t,e)=>{let n=[],o=[];t.type==="content_block_start"?t.content_block.type==="thinking"?n.push(C({type:"thinking",thinking:"",signature:""})):t.content_block.type==="text"?n.push(C({type:"text",text:""})):t.content_block.type==="tool_use"&&o.push(G(t.content_block.id||"",t.content_block.name||"",{})):t.type==="content_block_delta"&&(t.delta.type==="thinking_delta"?n.push(C({type:"thinking",thinking:t.delta.thinking||"",signature:""})):t.delta.type==="text_delta"?n.push(C({type:"text",text:t.delta.text||""})):t.delta.type==="signature_delta"?n.push(C({type:"thinking",thinking:"",signature:t.delta.signature||""})):t.delta.type==="input_json_delta"&&o.push(G("","",t.delta.partial_json)));let r=V(n,o);return X(r,e)},fe=(t,e)=>{let n=[],o=[];for(let s of t.candidates)if(s.content&&s.content.parts&&Array.isArray(s.content.parts))for(let a of s.content.parts)a.text?a.thought===!0?n.push(C({type:"thinking",thinking:a.text,signature:a.thoughtSignature||""})):n.push(C({type:"text",text:a.text})):a.functionCall&&o.push(G(a.functionCall.id||"",a.functionCall.name||"",a.functionCall.args||{}));let r=V(n,o);return X(r,e)},de=(t,e)=>{let n=[],o=[];for(let s of t.choices)if(s.delta&&(s.delta.content&&n.push(C({type:"text",text:s.delta.content})),s.delta.tool_calls&&Array.isArray(s.delta.tool_calls)))for(let a of s.delta.tool_calls)a.function&&o.push(G(a.id||"",a.function.name||"",a.function.arguments||""));let r=V(n,o);return X(r,e)};var z="SET_WORKFLOW_COMPLETE";function st(t,e,n){return u(this,null,function*(){let o=yield fetch(`${T}/workflow-version-execution-results?workflow_version_execution_id=${t}&return_all_outputs=${e}`,{headers:n});if(!o.ok)throw new Error("Failed to fetch final output");return o.json()})}function at(t,e,n,o){return function(r){return u(this,null,function*(){if(r.name===z)try{let s=JSON.parse(r.data),a=s.result_code,c;if(a==="OK"||a==null)c=s.final_output;else if(a==="EXCEEDS_SIZE_LIMIT")c=yield st(e,n,o);else throw new Error(`Unsupported final output code: ${a}`);t.resolve(c)}catch(s){t.reject(s)}})}}function it(a){return u(this,arguments,function*({token:t,channelName:e,executionId:n,returnAllOutputs:o,headers:r,timeout:s}){let c=new rt.Realtime(t),i=c.channels.get(e),p={},m=new Promise((l,d)=>{p.resolve=l,p.reject=d}),f=at(p,n,o,r);yield i.subscribe(z,f);try{return yield new Promise((l,d)=>{let w=setTimeout(()=>{d(new Error("Workflow execution did not complete properly (timeout)"))},s);m.then(g=>{clearTimeout(w),l(g)}).catch(g=>{clearTimeout(w),d(g)})})}finally{console.log("Closing client"),i.unsubscribe(z,f),c.close(),console.log("Closed client")}})}var T=process.env.PROMPTLAYER_API_URL||"https://api.promptlayer.com",ge=(t,e)=>u(void 0,null,function*(){return e.request_response[Symbol.asyncIterator]!==void 0?pt(t,e.request_response,e):yield we(t,e)}),we=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/track-request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=yield n.json();if(n.status!==200&&b(o,"WARNING: While logging your request, PromptLayer experienced the following error:"),o&&e.return_pl_id)return[e.request_response,o.request_id]}catch(n){console.warn(`WARNING: While logging your request PromptLayer had the following error: ${n}`)}return e.request_response}),Pe=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/library-track-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R(y({},e),{api_key:t}))}),o=yield n.json();if(n.status!==200)return b(o,"WARNING: While logging metadata to your request, PromptLayer experienced the following error"),!1}catch(n){return console.warn(`WARNING: While logging metadata to your request, PromptLayer experienced the following error: ${n}`),!1}return!0}),Te=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/library-track-score`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R(y({},e),{api_key:t}))}),o=yield n.json();if(n.status!==200)return b(o,"WARNING: While scoring your request, PromptLayer experienced the following error"),!1}catch(n){return console.warn(`WARNING: While scoring your request, PromptLayer experienced the following error: ${n}`),!1}return!0}),Re=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/library-track-prompt`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R(y({},e),{api_key:t}))}),o=yield n.json();if(n.status!==200)return b(o,"WARNING: While associating your request with a prompt template, PromptLayer experienced the following error"),!1}catch(n){return console.warn(`WARNING: While associating your request with a prompt template, PromptLayer experienced the following error: ${n}`),!1}return!0}),be=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/track-group`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R(y({},e),{api_key:t}))}),o=yield n.json();if(n.status!==200)return b(o,"WARNING: While associating your request with a group, PromptLayer experienced the following error"),!1}catch(n){return console.warn(`WARNING: While associating your request with a group, PromptLayer experienced the following error: ${n}`),!1}return!0}),Se=t=>u(void 0,null,function*(){try{let e=yield fetch(`${T}/create-group`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:t})}),n=yield e.json();return e.status!==200?(b(n,"WARNING: While creating a group PromptLayer had the following error"),!1):n.id}catch(e){return console.warn(`WARNING: While creating a group PromptLayer had the following error: ${e}`),!1}}),Oe=(t,e,n)=>u(void 0,null,function*(){try{let o=new URL(`${T}/prompt-templates/${e}`),r=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":t},body:JSON.stringify(n)}),s=yield r.json();return r.status!==200?(b(s,"WARNING: While fetching a prompt template PromptLayer had the following error"),null):(s.warning&&console.warn(`WARNING: While fetching your prompt PromptLayer had the following error: ${s.warning}`),s)}catch(o){return console.warn(`WARNING: While fetching a prompt template PromptLayer had the following error: ${o}`),null}}),Ae=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/rest/prompt-templates`,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":t},body:JSON.stringify({prompt_template:y({},e),prompt_version:y({},e),release_labels:e.release_labels?e.release_labels:void 0})}),o=yield n.json();return n.status===400&&b(o,"WARNING: While publishing a prompt template PromptLayer had the following error"),o}catch(n){console.warn(`WARNING: While publishing a prompt template PromptLayer had the following error: ${n}`)}}),Ee=(t,e)=>u(void 0,null,function*(){var n;try{let o=new URL(`${T}/prompt-templates`);Object.entries(e||{}).forEach(([a,c])=>o.searchParams.append(a,c.toString()));let r=yield fetch(o,{headers:{"Content-Type":"application/json","X-API-KEY":t}}),s=yield r.json();return r.status!==200?(b(s,"WARNING: While fetching all prompt templates PromptLayer had the following error"),null):(n=s.items)!=null?n:[]}catch(o){return console.warn(`WARNING: While fetching all prompt templates PromptLayer had the following error: ${o}`),null}}),Ce=i=>u(void 0,[i],function*({workflow_name:t,input_variables:e,metadata:n={},workflow_label_name:o=null,workflow_version_number:r=null,return_all_outputs:s=!1,api_key:a,timeout:c=36e5}){let p={input_variables:e,metadata:n,workflow_label_name:o,workflow_version_number:r,return_all_outputs:s},m={"X-API-KEY":a,"Content-Type":"application/json"};try{let f=yield fetch(`${T}/workflows/${encodeURIComponent(t)}/run`,{method:"POST",headers:m,body:JSON.stringify(p)});if(f.status!==201)return{success:!1,message:`Failed to run workflow: ${(yield f.json().catch(()=>({}))).error||f.statusText}`};let l=yield f.json();l.warning&&console.warn(`WARNING: ${l.warning}`);let d=l.workflow_version_execution_id;if(!d)return console.log("No execution ID returned from workflow run"),{success:!1,message:"Failed to run workflow"};let w=`workflow_updates:${d}`,S=(yield(yield fetch(`${T}/ws-token-request-library?capability=${w}`,{method:"POST",headers:m})).json()).token_details.token;return yield it({token:S,channelName:w,executionId:d,returnAllOutputs:s,headers:m,timeout:c})}catch(f){throw console.error(`Failed to run workflow: ${f instanceof Error?f.message:f}`),f}}),H=t=>{var c,i,p,m,f,l,d,w,g,A;let e=null,n,o={id:"",choices:[],created:Date.now(),model:"",object:"chat.completion"},r=t.at(-1);if(!r)return o;let s;for(let S of t){if(S.choices.length===0)continue;let _=S.choices[0].delta;_.content&&(e=`${e||""}${_.content||""}`),_.function_call&&(n={name:`${n?n.name:""}${_.function_call.name||""}`,arguments:`${n?n.arguments:""}${_.function_call.arguments||""}`});let h=(c=_.tool_calls)==null?void 0:c[0];if(h){s=s||[];let P=s.at(-1);if(!P||h.id){s.push({id:h.id||"",type:h.type||"function",function:{name:((i=h.function)==null?void 0:i.name)||"",arguments:((p=h.function)==null?void 0:p.arguments)||""}});continue}P.function.name=`${P.function.name}${((m=h.function)==null?void 0:m.name)||""}`,P.function.arguments=`${P.function.arguments}${((f=h.function)==null?void 0:f.arguments)||""}`}}let a=t[0].choices.at(0);return o.choices.push({finish_reason:(l=a==null?void 0:a.finish_reason)!=null?l:"stop",index:(d=a==null?void 0:a.index)!=null?d:0,logprobs:(w=a==null?void 0:a.logprobs)!=null?w:null,message:{role:"assistant",content:e,function_call:n||void 0,tool_calls:s||void 0,refusal:(g=a==null?void 0:a.delta.refusal)!=null?g:null}}),o.id=r.id,o.model=r.model,o.created=r.created,o.system_fingerprint=r.system_fingerprint,o.usage=(A=r.usage)!=null?A:void 0,o},Z=t=>{var i;let e={id:"",model:"",content:[],role:"assistant",type:"message",stop_reason:"stop_sequence",stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,server_tool_use:null,service_tier:null}};if(!t.at(-1))return e;let o=null,r="",s="",a="",c="";for(let p of t)if(p.type==="message_start")e=y({},p.message);else if(p.type==="content_block_start")o=y({},p.content_block),o.type==="thinking"?(r="",s=""):o.type==="text"?a="":(o.type==="tool_use"||o.type==="server_tool_use")&&(c="");else if(p.type==="content_block_delta"&&o!==null){if(o.type==="thinking")"signature"in p.delta&&(r=p.delta.signature||""),"thinking"in p.delta&&(s+=p.delta.thinking||"");else if(o.type==="text")"text"in p.delta&&(a+=p.delta.text||"");else if((o.type==="tool_use"||o.type==="server_tool_use")&&p.delta.type==="input_json_delta"){let m=p.delta;c+=m.partial_json||""}}else if(p.type==="content_block_stop"&&o!==null){if(o.type==="thinking")o.signature=r,o.thinking=s;else if(o.type==="text")o.text=a,o.citations=null;else if(o.type==="tool_use"||o.type==="server_tool_use")try{o.input=c?JSON.parse(c):{}}catch(m){o.input={}}e.content.push(o),o=null,r="",s="",a="",c=""}else p.type==="message_delta"&&("usage"in p&&p.usage&&(e.usage=R(y({},e.usage),{output_tokens:(i=p.usage.output_tokens)!=null?i:0})),"delta"in p&&p.delta&&("stop_reason"in p.delta&&p.delta.stop_reason!==void 0&&(e.stop_reason=p.delta.stop_reason),"stop_sequence"in p.delta&&p.delta.stop_sequence!==void 0&&(e.stop_sequence=p.delta.stop_sequence)));return e},ct=(t,e="openai.chat.completions.create")=>{if("completion"in t[0])return t.reduce((n,o)=>R(y({},o),{completion:`${n.completion}${o.completion}`}),{});if(e==="anthropic.messages.create")return Z(t);if("text"in t[0].choices[0]){let n="";for(let r of t)n=`${n}${r.choices[0].text}`;let o=structuredClone(t.at(-1));return o.choices[0].text=n,o}if("delta"in t[0].choices[0]){let n=H(t);return n.choices[0]=y(y({},n.choices[0]),n.choices[0].message),n}return""};function pt(t,e,n){return Y(this,null,function*(){let o=[];try{for(var a=B(e),c,i,p;c=!(i=yield new E(a.next())).done;c=!1){let m=i.value;yield n.return_pl_id?[m,null]:m,o.push(m)}}catch(i){p=[i]}finally{try{c&&(i=a.return)&&(yield new E(i.call(a)))}finally{if(p)throw p[0]}}let r=ct(o,n.function_name),s=yield new E(we(t,R(y({},n),{request_response:r,request_end_time:new Date().toISOString()})));if(s&&n.return_pl_id){let m=s[1];yield[o.at(-1),m]}})}var b=(t,e)=>{try{console.warn(`${e}: ${t.message}`)}catch(n){console.warn(`${e}: ${t}`)}},Ie=t=>u(void 0,null,function*(){try{let e=yield fetch(`${T}/track-request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=yield e.json();return e.status!==200&&b(n,"WARNING: While logging your request, PromptLayer experienced the following error:"),n}catch(e){console.warn(`WARNING: While logging your request PromptLayer had the following error: ${e}`)}return{}}),he=t=>{let e={id:"",choices:[{finish_reason:"stop",index:0,text:"",logprobs:null}],created:Date.now(),model:"",object:"text_completion"},n=t.at(-1);if(!n)return e;let o="";for(let r of t)r.choices.length>0&&r.choices[0].text&&(o=`${o}${r.choices[0].text}`);return e.choices[0].text=o,e.id=n.id,e.created=n.created,e.model=n.model,e.system_fingerprint=n.system_fingerprint,e.usage=n.usage,e},ye=t=>{let e={completion:"",id:"",model:"",stop_reason:"",type:"completion"},n=t.at(-1);if(!n)return e;let o="";for(let r of t)o=`${o}${r.completion}`;return e.completion=o,e.id=n.id,e.model=n.model,e.stop_reason=n.stop_reason,e};function ke(t,e,n,o){return Y(this,null,function*(){let r={request_id:null,raw_response:null,prompt_blueprint:null},s=[];try{for(var i=B(t),p,m,f;p=!(m=yield new E(i.next())).done;p=!1){let l=m.value;s.push(l),r.raw_response=l,l&&typeof l=="object"&&"type"in l&&(r.prompt_blueprint=me(l,o)),l&&typeof l=="object"&&"candidates"in l&&(r.prompt_blueprint=fe(l,o)),l&&typeof l=="object"&&"choices"in l&&(r.prompt_blueprint=de(l,o)),yield r}}catch(m){f=[m]}finally{try{p&&(m=i.return)&&(yield new E(m.call(i)))}finally{if(f)throw f[0]}}let a=n(s),c=yield new E(e({request_response:a}));r.request_id=c.request_id,r.prompt_blueprint=c.prompt_blueprint,yield r})}var lt=(t,e)=>u(void 0,null,function*(){return t.chat.completions.create(e)}),ut=(t,e)=>u(void 0,null,function*(){return t.completions.create(e)}),Ne={chat:lt,completion:ut},xe=(t,e)=>u(void 0,null,function*(){let n=I("openai").default,o=new n({baseURL:e.baseURL,apiKey:e.apiKey}),r=Ne[t.prompt_template.type];return r(o,e)}),qe=(t,e)=>u(void 0,null,function*(){let{AzureOpenAI:n}=I("openai"),o=new n({endpoint:process.env.AZURE_OPENAI_ENDPOINT||e.baseURL,apiVersion:process.env.OPENAI_API_VERSION||e.apiVersion,apiKey:process.env.AZURE_OPENAI_API_KEY||e.apiKey});e==null||delete e.baseURL,e==null||delete e.apiVersion,e==null||delete e.apiKey;let r=Ne[t.prompt_template.type];return r(o,e)}),Le=(t,e)=>u(void 0,null,function*(){return t.messages.create(e)}),mt=(t,e)=>u(void 0,null,function*(){return t.completions.create(e)}),ve={chat:Le,completion:mt},Ge=(t,e)=>u(void 0,null,function*(){let n=I("@anthropic-ai/sdk").default,o=new n({baseURL:e.baseURL,apiKey:e.apiKey}),r=ve[t.prompt_template.type];return r(o,e)}),We=(t,e)=>u(void 0,null,function*(){try{let n=yield fetch(`${T}/log-request`,{method:"POST",headers:{"X-API-KEY":t,"Content-Type":"application/json"},body:JSON.stringify(e)}),o=yield n.json();return n.status!==201?(b(o,"WARNING: While logging your request PromptLayer had the following error"),null):o}catch(n){return console.warn(`WARNING: While tracking your prompt PromptLayer had the following error: ${n}`),null}}),ft=(t,e,n,o)=>{var a,c;let r=y({},o),s=[];if(t){let i={text:t,thought:!0};s.push(i)}if(e){let i={text:e,thought:null};s.push(i)}for(let i of n){let p={function_call:i};s.push(p)}return s.length>0&&((c=(a=r.candidates)==null?void 0:a[0])!=null&&c.content)&&(r.candidates[0].content.parts=s),r},$e=t=>{var s,a;let{GenerateContentResponse:e}=I("@google/genai");if(!t.length)return new e;let n="",o="",r=[];for(let c of t)if(c.candidates&&((a=(s=c.candidates[0])==null?void 0:s.content)!=null&&a.parts))for(let i of c.candidates[0].content.parts)i.text?i.thought===!0?n+=i.text:o+=i.text:i.functionCall&&r.push(i.functionCall);return ft(n,o,r,t[t.length-1])},dt=t=>$e(t),ht=t=>$e(t),yt=(t,e)=>u(void 0,null,function*(){var a,c;let n=e==null?void 0:e.history,o=e==null?void 0:e.generationConfig,r=n.length>0?(a=n[n.length-1])==null?void 0:a.parts:"",s=t.chats.create({model:e==null?void 0:e.model,history:(c=n.slice(0,-1))!=null?c:[],config:o});return e!=null&&e.stream?yield s.sendMessageStream({message:r}):yield s.sendMessage({message:r})}),_t=(t,o)=>u(void 0,null,function*(){var r=o,{stream:e}=r,n=v(r,["stream"]);return e?yield t.generateContentStream(y({},n)):yield t.generateContent(y({},n))}),gt={chat:yt,completion:_t},ee=(t,e)=>u(void 0,null,function*(){let{GoogleGenAI:n}=yield import("@google/genai"),o=process.env.GOOGLE_API_KEY||process.env.GEMINI_API_KEY,r=process.env.VERTEX_AI_PROJECT_ID||process.env.GOOGLE_PROJECT_ID||process.env.GOOGLE_CLOUD_PROJECT,s=process.env.VERTEX_AI_PROJECT_LOCATION||process.env.GOOGLE_PROJECT_LOCATION||process.env.GOOGLE_CLOUD_PROJECT_LOCATION,a={keyFilename:process.env.GOOGLE_APPLICATION_CREDENTIALS,projectId:r,scopes:["https://www.googleapis.com/auth/cloud-platform"]},c=o?new n({apiKey:o}):new n({vertexai:!0,project:r,location:s,googleAuthOptions:a}),i=gt[t.prompt_template.type];return yield i(c,e)}),_e=t=>t.replace(/_([a-z])/g,(e,n)=>n.toUpperCase()),Q=(t,e=new Set)=>!t||typeof t!="object"?t:Array.isArray(t)?t.map(n=>Q(n,e)):Object.fromEntries(Object.entries(t).map(([n,o])=>e.has(n)?[_e(n),o]:[_e(n),Q(o,e)])),wt=["openai","openai.azure"],Pt={openai:{chat:{function_name:"openai.chat.completions.create",stream_function:H},completion:{function_name:"openai.completions.create",stream_function:he}},anthropic:{chat:{function_name:"anthropic.messages.create",stream_function:Z},completion:{function_name:"anthropic.completions.create",stream_function:ye}},"openai.azure":{chat:{function_name:"openai.AzureOpenAI.chat.completions.create",stream_function:H},completion:{function_name:"openai.AzureOpenAI.completions.create",stream_function:he}},google:{chat:{function_name:"google.convo.send_message",stream_function:dt},completion:{function_name:"google.model.generate_content",stream_function:ht}},"anthropic.bedrock":{chat:{function_name:"anthropic.messages.create",stream_function:Z},completion:{function_name:"anthropic.completions.create",stream_function:ye}}},Me=(t,e,n={},o=!1)=>{var c,i,p,m,f,l,d;let r=(p=e==null?void 0:e.client)!=null?p:(i=(c=t.metadata)==null?void 0:c.model)==null?void 0:i.provider;if(!r)throw new Error("Provider type not found in prompt blueprint or custom provider");let s=R(y(y({},t.llm_kwargs||{}),n),{stream:o});["google","vertexai"].includes(r)&&((f=(m=t.metadata)==null?void 0:m.model)!=null&&f.name.startsWith("gemini"))&&(s=Q(s,new Set(["function_declarations"])));let a={baseURL:(d=e==null?void 0:e.base_url)!=null?d:(l=t.provider_base_url)==null?void 0:l.url,apiKey:e==null?void 0:e.api_key};return Object.entries(a).forEach(([w,g])=>{g!==void 0&&(s[w]=g)}),o&&wt.includes(r)&&(s.stream_options={include_usage:!0}),{provider_type:r,kwargs:s}},Ke=(t,e)=>{let n=Pt[t];if(!n)throw new Error(`Unsupported provider type: ${t}`);let o=e.type,r=n[o];if(!r)throw new Error(`Unsupported template type '${e.type}' for provider '${t}'`);return r},je=(t,e)=>u(void 0,null,function*(){var o;let n=(o=t.metadata)==null?void 0:o.model;if(!n)throw new Error("Model metadata not found in prompt blueprint");if(n.name.startsWith("gemini"))return ee(t,e);if(n.name.startsWith("claude")){let{AnthropicVertex:r}=yield import("@anthropic-ai/vertex-sdk"),s=new r({baseURL:e.baseURL});if(t.prompt_template.type==="chat")return Le(s,e);throw new Error(`Unsupported prompt template type '${t.prompt_template.type}' for Anthropic Vertex AI`)}throw new Error(`Unsupported model name '${n.name}' for Vertex AI request`)}),Ue=(t,e)=>u(void 0,null,function*(){let{AnthropicBedrock:n}=yield import("@anthropic-ai/bedrock-sdk"),o=new n({awsAccessKey:e.aws_access_key,awsSecretKey:e.aws_secret_key,awsRegion:e.aws_region,awsSessionToken:e.aws_session_token,baseURL:e.base_url}),r=ve[t.prompt_template.type];return r(o,e)});var W=class{constructor(e){this.create=()=>Se(this.apiKey);this.apiKey=e}};import*as De from"@opentelemetry/api";import{SimpleSpanProcessor as Tt}from"@opentelemetry/sdk-trace-base";import{NodeTracerProvider as Rt}from"@opentelemetry/sdk-trace-node";import{SpanKind as q,SpanStatusCode as te}from"@opentelemetry/api";import{ExportResultCode as $}from"@opentelemetry/core";var ne=class{constructor(e,n){this.apiKey=n||process.env.PROMPTLAYER_API_KEY,this.enableTracing=e,this.url=`${T}/spans-bulk`}attributesToObject(e){return e?Object.fromEntries(Object.entries(e)):{}}spanKindToString(e){return{[q.INTERNAL]:"SpanKind.INTERNAL",[q.SERVER]:"SpanKind.SERVER",[q.CLIENT]:"SpanKind.CLIENT",[q.PRODUCER]:"SpanKind.PRODUCER",[q.CONSUMER]:"SpanKind.CONSUMER"}[e]||"SpanKind.INTERNAL"}statusCodeToString(e){return{[te.ERROR]:"StatusCode.ERROR",[te.OK]:"StatusCode.OK",[te.UNSET]:"StatusCode.UNSET"}[e]||"StatusCode.UNSET"}toNanoseconds(e){return(BigInt(e[0])*BigInt(1e9)+BigInt(e[1])).toString()}export(e){if(!this.enableTracing)return Promise.resolve($.SUCCESS);let n=e.map(o=>{var r;return{name:o.name,context:{trace_id:o.spanContext().traceId,span_id:o.spanContext().spanId,trace_state:((r=o.spanContext().traceState)==null?void 0:r.serialize())||""},kind:this.spanKindToString(o.kind),parent_id:o.parentSpanId||null,start_time:this.toNanoseconds(o.startTime),end_time:this.toNanoseconds(o.endTime),status:{status_code:this.statusCodeToString(o.status.code),description:o.status.message},attributes:this.attributesToObject(o.attributes),events:o.events.map(s=>({name:s.name,timestamp:this.toNanoseconds(s.time),attributes:this.attributesToObject(s.attributes)})),links:o.links.map(s=>({context:s.context,attributes:this.attributesToObject(s.attributes)})),resource:{attributes:R(y({},o.resource.attributes),{"service.name":"prompt-layer-js"}),schema_url:""}}});return fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-API-KEY":this.apiKey||""},body:JSON.stringify({spans:n})}).then(o=>o.ok?$.SUCCESS:(console.error(`Error exporting spans
2
+ HTTP error! status: ${o.status}`),$.FAILED)).catch(o=>(console.error("Error exporting spans:",o),$.FAILED))}shutdown(){return Promise.resolve()}},Je=ne;var k=(t="promptlayer-tracer")=>De.trace.getTracer(t),Fe=(t,e)=>{let n=new Rt,o=new Je(t,e),r=new Tt(o);n.addSpanProcessor(r),n.register()};var bt=k(),oe=(t,e,n="",o="openai")=>{let r={construct:(s,a)=>{let c=Reflect.construct(s,a);return Object.defineProperties(c,{function_name:{value:n,writable:!0},provider:{value:o}}),new Proxy(c,r)},get:(s,a,c)=>{let i=s[a],p=`${Reflect.get(s,"function_name")}.${a.toString()}`;return typeof i=="object"?(Object.defineProperties(i,{function_name:{value:p,writable:!0},provider:{value:o}}),new Proxy(i,r)):typeof i=="function"?(...m)=>{var g,A,S,_;let f=new Date().toISOString(),l=Reflect.get(s,"provider"),d=(g=m[0])==null?void 0:g.return_pl_id,w=(A=m[0])==null?void 0:A.pl_tags;return(S=m[0])==null||delete S.return_pl_id,(_=m[0])==null||delete _.pl_tags,bt.startActiveSpan(`${l}.${p}`,h=>u(void 0,null,function*(){try{h.setAttribute("function_input",JSON.stringify(m));let P=Reflect.apply(i,s,m),N=h.spanContext().spanId;return P instanceof Promise?new Promise((U,J)=>{P.then(O=>u(void 0,null,function*(){let x=yield ge(t,{api_key:t,provider_type:l,function_name:p,request_start_time:f,request_end_time:new Date().toISOString(),request_response:O,kwargs:m[0],return_pl_id:d,tags:w,span_id:N});h.setAttribute("function_output",JSON.stringify(x)),h.setAttribute("response_status","success"),h.end(),U(x)})).catch(O=>{h.recordException(O),h.setAttribute("response_status","error"),h.end(),J(O)})}):(h.setAttribute("function_output",JSON.stringify(P)),h.setAttribute("response_status","success"),h.end(),P)}catch(P){throw h.recordException(P),h.setAttribute("response_status","error"),h.end(),P}}))}:Reflect.get(s,a,c)}};return new Proxy(e,r)};import*as M from"@opentelemetry/api";var Be=(t,e,n)=>function(...o){let r=k(),s=a=>{try{n&&Object.entries(n).forEach(([i,p])=>{a.setAttribute(i,p)}),a.setAttribute("function_input",JSON.stringify(o));let c=e(...o);return c instanceof Promise?c.then(i=>(a.setAttribute("function_output",JSON.stringify(i)),a.setStatus({code:M.SpanStatusCode.OK}),i)).catch(i=>{throw Ye(a,i,o),i}).finally(()=>a.end()):(a.setAttribute("function_output",JSON.stringify(c)),a.setStatus({code:M.SpanStatusCode.OK}),a.end(),c)}catch(c){throw Ye(a,c,o),c}};return r.startActiveSpan(t,s)},Ye=(t,e,n)=>{t.setAttribute("function_input",JSON.stringify(n)),t.setStatus({code:M.SpanStatusCode.ERROR,message:e instanceof Error?e.message:"Unknown error"}),t.end()};var K=class{constructor(e){this.get=(e,n)=>Oe(this.apiKey,e,n);this.publish=e=>Ae(this.apiKey,e);this.all=e=>Ee(this.apiKey,e);this.apiKey=e}};var St=(t,e)=>{if(!(e.metadata instanceof Object))throw new Error("Please provide a dictionary of metadata.");for(let[n,o]of Object.entries(e.metadata))if(typeof n!="string"||typeof o!="string")throw new Error("Please provide a dictionary of metadata with key value pair of strings.");return Pe(t,e)},Ot=(t,e)=>{if(typeof e.score!="number")throw new Error("Score must be a number");if(e.score<0||e.score>100)throw new Error("Score must be a number between 0 and 100.");return Te(t,e)},At=(t,e)=>{if(!(e.prompt_input_variables instanceof Object))throw new Error("Prompt template input variable dictionary not provided.");return Re(t,e)},Et=(t,e)=>be(t,e),j=class{constructor(e){this.group=e=>Et(this.apiKey,e);this.metadata=e=>St(this.apiKey,e);this.prompt=e=>At(this.apiKey,e);this.score=e=>Ot(this.apiKey,e);this.apiKey=e}};import*as Xe from"@opentelemetry/api";var Ct={openai:xe,anthropic:Ge,"openai.azure":qe,google:ee,vertexai:je,"anthropic.bedrock":Ue},It=t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=["status","value","error_message","raw_error_message","is_output_node"];return Object.values(t).every(o=>typeof o!="object"||o===null?!1:e.every(r=>r in o))},Ve=class{constructor({apiKey:e=process.env.PROMPTLAYER_API_KEY,enableTracing:n=!1}={}){if(e===void 0)throw new Error("PromptLayer API key not provided. Please set the PROMPTLAYER_API_KEY environment variable or pass the api_key parameter.");this.apiKey=e,this.enableTracing=n,this.templates=new K(e),this.group=new W(e),this.track=new j(e),this.wrapWithSpan=Be,n&&Fe(n,e)}get Anthropic(){try{let e=I("@anthropic-ai/sdk").default;return oe(this.apiKey,e,"anthropic","anthropic")}catch(e){console.error("To use the Anthropic module, you must install the @anthropic-ai/sdk package.")}}get OpenAI(){try{let e=I("openai").default;return oe(this.apiKey,e,"openai","openai")}catch(e){console.error("To use the OpenAI module, you must install the @openai/api package.")}}run(l){return u(this,arguments,function*({promptName:e,promptVersion:n,promptReleaseLabel:o,inputVariables:r,tags:s,metadata:a,groupId:c,modelParameterOverrides:i,stream:p=!1,provider:m,model:f}){return k().startActiveSpan("PromptLayer Run",w=>u(this,null,function*(){try{let g={promptName:e,promptVersion:n,promptReleaseLabel:o,inputVariables:r,tags:s,metadata:a,groupId:c,modelParameterOverrides:i,stream:p};w.setAttribute("function_input",JSON.stringify(g));let A=r,S={label:o,version:n,metadata_filters:a,provider:m,model:f};r&&(S.input_variables=r);let _=yield this.templates.get(e,S);if(!_)throw new Error("Prompt not found");let h=_.prompt_template;_.llm_kwargs||console.warn(`Prompt '${e}' does not have any LLM kwargs associated with it. Please set your model parameters in the registry in the PromptLayer dashbaord.`);let P=_.metadata;if(!P)throw new Error(`Prompt '${e}' does not have any metadata associated with it.`);let N=P.model;if(!N)throw new Error(`Prompt '${e}' does not have a model parameters associated with it.`);let U=_.custom_provider,J=new Date().toISOString(),{provider_type:O,kwargs:x}=Me(_,U,i,p),D=O;N.name.startsWith("gemini")?D="google":N.name.startsWith("claude")&&(D="anthropic");let ze=Ke(D,h),{function_name:He,stream_function:Ze}=ze,re=Ct[O];if(!re)throw new Error(`No request function found for provider: ${O}`);let F=yield re(_,x),se=Qe=>{let et=new Date().toISOString();return Ie(y({function_name:He,provider_type:O,args:[],kwargs:x,tags:s,request_start_time:J,request_end_time:et,api_key:this.apiKey,metadata:a,prompt_id:_.id,prompt_version:_.version,prompt_input_variables:A,group_id:c,return_prompt_blueprint:!0,span_id:w.spanContext().spanId},Qe))};if(p)return ke(F,se,Ze,a);let ae=yield se({request_response:F}),ie={request_id:ae.request_id,raw_response:F,prompt_blueprint:ae.prompt_blueprint};return w.setAttribute("function_output",JSON.stringify(ie)),ie}catch(g){throw w.setStatus({code:Xe.SpanStatusCode.ERROR,message:g instanceof Error?g.message:"Unknown error"}),g}finally{w.end()}}))})}runWorkflow(c){return u(this,arguments,function*({workflowName:e,inputVariables:n={},metadata:o={},workflowLabelName:r=null,workflowVersion:s=null,returnAllOutputs:a=!1}){try{let i=yield Ce({workflow_name:e,input_variables:n,metadata:o,workflow_label_name:r,workflow_version_number:s,return_all_outputs:a,api_key:this.apiKey});if(!a&&It(i)){let m=Object.values(i).filter(l=>l.is_output_node===!0);if(m.length===0)throw new Error(JSON.stringify(i,null,2));if(!m.some(l=>l.status==="SUCCESS"))throw new Error(JSON.stringify(i,null,2))}return i}catch(i){throw i instanceof Error?(console.error("Error running workflow:",i.message),new Error(`Error running workflow: ${i.message}`)):(console.error("Unknown error running workflow:",i),new Error("Unknown error running workflow"))}})}logRequest(e){return u(this,null,function*(){return We(this.apiKey,e)})}};export{Ve as PromptLayer};
3
3
  //# sourceMappingURL=index.js.map