@smythos/sre 1.5.5 → 1.5.7

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/index.js CHANGED
@@ -73,7 +73,7 @@ const f=sa.genDsId(d,a,l);if(we(u.value.Source))throw r+=`STEP: Parsing input as
73
73
  `,{_debug:r,Success:!0}}catch(o){return r+=`Failed to delete data source:
74
74
  Error: ${o?.message}
75
75
  `,{_debug:r,_error:o?.message||"Couldn't delete data source"}}}validateInput(e){return h.object({}).unknown(!0).validate(e)}validateConfigData(e){return h.object({namespaceId:h.string().required(),id:h.string().optional().allow("").allow(null)}).unknown(!0).validate(e)}}var du=Object.defineProperty,mu=(n,e,t)=>e in n?du(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,pu=(n,e,t)=>mu(n,e+"",t);let hu=class{static async getInstance(e){throw new Error("Method not implemented.")}};class gu extends N{constructor(){super(),pu(this,"configSchema",h.object({topK:h.string().custom(Yi({min:0}),"custom range validation").label("Result Count"),model:h.string().valid("gpt-4o-mini","gpt-4","gpt-3.5-turbo","gpt-4","gpt-3.5-turbo-16k").optional(),prompt:h.string().max(3e4).allow("").label("Prompt").optional(),postprocess:h.boolean().strict().optional(),includeMetadata:h.boolean().strict().optional(),namespace:h.string().allow("").max(80).messages({"string.max":"The length of the 'namespace' name must be 50 characters or fewer."})}))}init(){}async process(e,t,s){await super.process(e,t,s);const a=t.id;s.components[a];const r=s.teamId;let o=s.agentRuntime?.debug?`== Data Source Lookup Log ==
76
- `:null;const i={};for(let A of t.outputs)A.default||(i[A.name]="");const l=t.data.namespace.split("_").slice(1).join("_")||t.data.namespace,c=t.data?.model||"gpt-4o-mini",u=t.data?.prompt?.trim?.()||"",d=t.data?.postprocess||!1,m=t.data?.includeMetadata||!1,p=typeof e.Query=="string"?e.Query:JSON.stringify(e.Query),g=Math.max(t.data?.topK||50,50);let f=b.getVectorDBConnector();if(!await f.requester(I.team(r)).namespaceExists(l))throw new Error(`Namespace ${l} does not exist`);let y,w;try{y=(await f.requester(I.team(r)).search(l,p,{topK:g,includeMetadata:!0})).slice(0,t.data.topK).map(A=>({content:A.metadata?.text,metadata:A.metadata})),m?y=y.map(A=>({content:A.content,metadata:this.parseMetadata(A.metadata||A.metadata?.metadata)})):y=y.map(A=>A.content),o+=`[Results]
76
+ `:null;const i={};for(let A of t.outputs)A.default||(i[A.name]="");const l=t.data.namespace.split("_").slice(1).join("_")||t.data.namespace,c=t.data?.model||"gpt-4o-mini",u=t.data?.prompt?.trim?.()||"",d=t.data?.postprocess||!1,m=t.data?.includeMetadata||!1,p=typeof e.Query=="string"?e.Query:JSON.stringify(e.Query),g=Math.max(t.data?.topK||50,50);let f=b.getVectorDBConnector();if(!await f.requester(I.team(r)).namespaceExists(l))throw new Error(`Namespace ${l} does not exist`);let y,w;try{y=(await f.requester(I.team(r)).search(l,p,{topK:g,includeMetadata:!0})).slice(0,t.data.topK).map(A=>({content:A.text,metadata:A.metadata})),m?y=y.map(A=>({content:A.content,metadata:this.parseMetadata(A.metadata||A.metadata?.metadata)})):y=y.map(A=>A.content),o+=`[Results]
77
77
  Loaded ${y.length} results from namespace: ${l}
78
78
 
79
79
  `}catch(A){w=A.toString()}if(d&&u){const A=[];for(let _ of y)M(u.replace(/{{result}}/g,JSON.stringify(_))).parse(e).result,await hu.getInstance(c);y=await Promise.all(A);for(let _=0;_<y.length;_++)typeof y[_]=="string"&&(y[_]=de(y[_]).tryParse())}const k=JSON.stringify(y).length;return o+=`[Total Length]