New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nlux/hf-react

Package Overview
Dependencies
Maintainers
1
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nlux/hf-react - npm Package Compare versions

Comparing version 2.0.8-alpha to 2.0.9-alpha

2

cjs/hf-react.js

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

"use strict";var e=require("@nlux/hf"),t=require("react"),r=Object.defineProperty,s=(e,t,s)=>((e,t,s)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class o extends Error{constructor(e={}){super(e.message),s(this,"exceptionId"),s(this,"message"),s(this,"source"),s(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class a extends o{}const n="hooks/initChatAdapter";Object.defineProperty(exports,"createChatAdapter",{enumerable:!0,get:function(){return e.createChatAdapter}}),Object.defineProperty(exports,"llama2InputPreProcessor",{enumerable:!0,get:function(){return e.llama2InputPreProcessor}}),Object.defineProperty(exports,"llama2OutputPreProcessor",{enumerable:!0,get:function(){return e.llama2OutputPreProcessor}}),exports.useChatAdapter=r=>{if(!r.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[s,o]=t.useState(!1),[u]=t.useState((t=>{const{model:r,authToken:s,dataTransferMode:o,preProcessors:u,maxNewTokens:i,systemMessage:c}=t||{};if(o&&"stream"!==o&&"fetch"!==o)throw new a({source:n,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===r)throw new a({source:n,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let p=e.createChatAdapter().withModel(r);return void 0!==s&&(p=p.withAuthToken(s)),void 0!==o&&(p=p.withDataTransferMode(o)),void 0!==u?.input&&(p=p.withInputPreProcessor(u?.input)),void 0!==u?.output&&(p=p.withOutputPreProcessor(u?.output)),void 0!==c&&(p=p.withSystemMessage(c)),void 0!==i&&(p=p.withMaxNewTokens(i)),p})(r)),{authToken:i,dataTransferMode:c,model:p,systemMessage:d,preProcessors:{input:h,output:m}={},maxNewTokens:l}=r||{};return t.useEffect((()=>{s||o(!0)}),[i,c,p,d,h,m,l]),u};
"use strict";var e=require("@nlux/hf"),t=require("react"),r=Object.defineProperty,s=(e,t,s)=>((e,t,s)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class o extends Error{constructor(e={}){super(e.message),s(this,"exceptionId"),s(this,"message"),s(this,"source"),s(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class a extends o{}const n="hooks/initChatAdapter";Object.defineProperty(exports,"createChatAdapter",{enumerable:!0,get:function(){return e.createChatAdapter}}),Object.defineProperty(exports,"llama2InputPreProcessor",{enumerable:!0,get:function(){return e.llama2InputPreProcessor}}),Object.defineProperty(exports,"llama2OutputPreProcessor",{enumerable:!0,get:function(){return e.llama2OutputPreProcessor}}),exports.useChatAdapter=r=>{if(!r.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[s,o]=t.useState(!1),[u]=t.useState((t=>{const{model:r,authToken:s,dataTransferMode:o,preProcessors:u,maxNewTokens:i,systemMessage:c}=t||{};if(o&&"stream"!==o&&"fetch"!==o)throw new a({source:n,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===r)throw new a({source:n,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let p=e.createChatAdapter().withModel(r);return void 0!==s&&(p=p.withAuthToken(s)),void 0!==o&&(p=p.withDataTransferMode(o)),void 0!==u?.input&&(p=p.withInputPreProcessor(u.input)),void 0!==u?.output&&(p=p.withOutputPreProcessor(u?.output)),void 0!==c&&(p=p.withSystemMessage(c)),void 0!==i&&(p=p.withMaxNewTokens(i)),p})(r)),{authToken:i,dataTransferMode:c,model:p,systemMessage:d,preProcessors:{input:h,output:m}={},maxNewTokens:l}=r||{};return t.useEffect((()=>{s||o(!0)}),[i,c,p,d,h,m,l]),u};

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

import{createChatAdapter as e}from"@nlux/hf";export{createChatAdapter,llama2InputPreProcessor,llama2OutputPreProcessor}from"@nlux/hf";import{useState as t,useEffect as o}from"react";var r=Object.defineProperty,s=(e,t,o)=>((e,t,o)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);class a extends Error{constructor(e={}){super(e.message),s(this,"exceptionId"),s(this,"message"),s(this,"source"),s(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class n extends a{}const i="hooks/initChatAdapter",u=r=>{if(!r.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[s,a]=t(!1),[u]=t((t=>{const{model:o,authToken:r,dataTransferMode:s,preProcessors:a,maxNewTokens:u,systemMessage:c}=t||{};if(s&&"stream"!==s&&"fetch"!==s)throw new n({source:i,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===o)throw new n({source:i,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let h=e().withModel(o);return void 0!==r&&(h=h.withAuthToken(r)),void 0!==s&&(h=h.withDataTransferMode(s)),void 0!==a?.input&&(h=h.withInputPreProcessor(a?.input)),void 0!==a?.output&&(h=h.withOutputPreProcessor(a?.output)),void 0!==c&&(h=h.withSystemMessage(c)),void 0!==u&&(h=h.withMaxNewTokens(u)),h})(r)),{authToken:c,dataTransferMode:h,model:m,systemMessage:d,preProcessors:{input:p,output:f}={},maxNewTokens:l}=r||{};return o((()=>{s||a(!0)}),[c,h,m,d,p,f,l]),u};export{u as useChatAdapter};
import{createChatAdapter as e}from"@nlux/hf";export{createChatAdapter,llama2InputPreProcessor,llama2OutputPreProcessor}from"@nlux/hf";import{useState as t,useEffect as o}from"react";var r=Object.defineProperty,s=(e,t,o)=>((e,t,o)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);class a extends Error{constructor(e={}){super(e.message),s(this,"exceptionId"),s(this,"message"),s(this,"source"),s(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class n extends a{}const i="hooks/initChatAdapter",u=r=>{if(!r.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[s,a]=t(!1),[u]=t((t=>{const{model:o,authToken:r,dataTransferMode:s,preProcessors:a,maxNewTokens:u,systemMessage:c}=t||{};if(s&&"stream"!==s&&"fetch"!==s)throw new n({source:i,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===o)throw new n({source:i,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let h=e().withModel(o);return void 0!==r&&(h=h.withAuthToken(r)),void 0!==s&&(h=h.withDataTransferMode(s)),void 0!==a?.input&&(h=h.withInputPreProcessor(a.input)),void 0!==a?.output&&(h=h.withOutputPreProcessor(a?.output)),void 0!==c&&(h=h.withSystemMessage(c)),void 0!==u&&(h=h.withMaxNewTokens(u)),h})(r)),{authToken:c,dataTransferMode:h,model:m,systemMessage:d,preProcessors:{input:p,output:f}={},maxNewTokens:l}=r||{};return o((()=>{s||a(!0)}),[c,h,m,d,p,f,l]),u};export{u as useChatAdapter};
{
"name": "@nlux/hf-react",
"version": "2.0.8-alpha",
"version": "2.0.9-alpha",
"description": "The Hugging Face adapters for nlux React, the React JS library for building conversational AI interfaces.",

@@ -62,6 +62,6 @@ "keywords": [

"dependencies": {
"@nlux/hf": "2.0.8-alpha"
"@nlux/hf": "2.0.9-alpha"
},
"peerDependencies": {
"@nlux/react": "2.0.8-alpha",
"@nlux/react": "2.0.9-alpha",
"react": "^18.2.0"

@@ -68,0 +68,0 @@ },

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/hf"),require("react")):"function"==typeof define&&define.amd?define(["exports","@nlux/hf","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/hf-react"]={},e.hf,e.react)}(this,(function(e,t,r){"use strict";var o=Object.defineProperty,s=(e,t,r)=>((e,t,r)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class n extends Error{constructor(e={}){super(e.message),s(this,"exceptionId"),s(this,"message"),s(this,"source"),s(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class a extends n{}const u="hooks/initChatAdapter";Object.defineProperty(e,"createChatAdapter",{enumerable:!0,get:function(){return t.createChatAdapter}}),Object.defineProperty(e,"llama2InputPreProcessor",{enumerable:!0,get:function(){return t.llama2InputPreProcessor}}),Object.defineProperty(e,"llama2OutputPreProcessor",{enumerable:!0,get:function(){return t.llama2OutputPreProcessor}}),e.useChatAdapter=e=>{if(!e.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[o,s]=r.useState(!1),[n]=r.useState((e=>{const{model:r,authToken:o,dataTransferMode:s,preProcessors:n,maxNewTokens:i,systemMessage:c}=e||{};if(s&&"stream"!==s&&"fetch"!==s)throw new a({source:u,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===r)throw new a({source:u,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let d=t.createChatAdapter().withModel(r);return void 0!==o&&(d=d.withAuthToken(o)),void 0!==s&&(d=d.withDataTransferMode(s)),void 0!==n?.input&&(d=d.withInputPreProcessor(n?.input)),void 0!==n?.output&&(d=d.withOutputPreProcessor(n?.output)),void 0!==c&&(d=d.withSystemMessage(c)),void 0!==i&&(d=d.withMaxNewTokens(i)),d})(e)),{authToken:i,dataTransferMode:c,model:d,systemMessage:f,preProcessors:{input:p,output:h}={},maxNewTokens:l}=e||{};return r.useEffect((()=>{o||s(!0)}),[i,c,d,f,p,h,l]),n}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/hf"),require("react")):"function"==typeof define&&define.amd?define(["exports","@nlux/hf","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/hf-react"]={},e.hf,e.react)}(this,(function(e,t,r){"use strict";var o=Object.defineProperty,s=(e,t,r)=>((e,t,r)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class n extends Error{constructor(e={}){super(e.message),s(this,"exceptionId"),s(this,"message"),s(this,"source"),s(this,"type"),this.message=e.message??"",this.source=e.source,this.type=this.constructor.name,this.exceptionId=e.exceptionId}}class a extends n{}const u="hooks/initChatAdapter";Object.defineProperty(e,"createChatAdapter",{enumerable:!0,get:function(){return t.createChatAdapter}}),Object.defineProperty(e,"llama2InputPreProcessor",{enumerable:!0,get:function(){return t.llama2InputPreProcessor}}),Object.defineProperty(e,"llama2OutputPreProcessor",{enumerable:!0,get:function(){return t.llama2OutputPreProcessor}}),e.useChatAdapter=e=>{if(!e.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[o,s]=r.useState(!1),[n]=r.useState((e=>{const{model:r,authToken:o,dataTransferMode:s,preProcessors:n,maxNewTokens:i,systemMessage:c}=e||{};if(s&&"stream"!==s&&"fetch"!==s)throw new a({source:u,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===r)throw new a({source:u,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let d=t.createChatAdapter().withModel(r);return void 0!==o&&(d=d.withAuthToken(o)),void 0!==s&&(d=d.withDataTransferMode(s)),void 0!==n?.input&&(d=d.withInputPreProcessor(n.input)),void 0!==n?.output&&(d=d.withOutputPreProcessor(n?.output)),void 0!==c&&(d=d.withSystemMessage(c)),void 0!==i&&(d=d.withMaxNewTokens(i)),d})(e)),{authToken:i,dataTransferMode:c,model:d,systemMessage:f,preProcessors:{input:p,output:h}={},maxNewTokens:l}=e||{};return r.useEffect((()=>{o||s(!0)}),[i,c,d,f,p,h,l]),n}}));
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc