You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
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

to
0.5.4

2

cjs/hf-react.js

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

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

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

import{createAdapter as e}from"@nlux/hf";export{createAdapter,llama2InputPreProcessor}from"@nlux/hf";import{useState as o,useEffect as r}from"react";import{NluxUsageError as t}from"@nlux/nlux";const s="hooks/initHfAdapter",n=n=>{if(!n.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[a,i]=o(!1),[m]=o((o=>{const{model:r,authToken:n,dataTransferMode:a,inputPreProcessor:i,maxNewTokens:m,systemMessage:u}=o||{};if(a&&"stream"!==a&&"fetch"!==a)throw new t({source:s,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===r)throw new t({source:s,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let d=e().withModel(r);return void 0!==n&&(d=d.withAuthToken(n)),void 0!==a&&(d=d.withDataTransferMode(a)),void 0!==i&&(d=d.withInputPreProcessor(i)),void 0!==u&&(d=d.withSystemMessage(u)),void 0!==m&&(d=d.withMaxNewTokens(m)),d})(n)),{authToken:u,dataTransferMode:d,model:f,systemMessage:h,inputPreProcessor:c,maxNewTokens:p}=n||{};return r((()=>{a||i(!0)}),[u,d,f,h,c,p]),m};export{n as useAdapter};
import{createAdapter as e}from"@nlux/hf";export{createAdapter,llama2InputPreProcessor,llama2OutputPreProcessor}from"@nlux/hf";import{useState as o,useEffect as t}from"react";import{NluxUsageError as r}from"@nlux/nlux";const s="hooks/initHfAdapter",n=n=>{if(!n.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[a,u]=o(!1),[i]=o((o=>{const{model:t,authToken:n,dataTransferMode:a,preProcessors:u,maxNewTokens:i,systemMessage:m}=o||{};if(a&&"stream"!==a&&"fetch"!==a)throw new r({source:s,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===t)throw new r({source:s,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let d=e().withModel(t);return void 0!==n&&(d=d.withAuthToken(n)),void 0!==a&&(d=d.withDataTransferMode(a)),void 0!==u?.input&&(d=d.withInputPreProcessor(u?.input)),void 0!==u?.output&&(d=d.withOutputPreProcessor(u?.output)),void 0!==m&&(d=d.withSystemMessage(m)),void 0!==i&&(d=d.withMaxNewTokens(i)),d})(n)),{authToken:m,dataTransferMode:d,model:p,systemMessage:c,preProcessors:{input:h,output:f}={},maxNewTokens:w}=n||{};return t((()=>{a||u(!0)}),[m,d,p,c,h,f,w]),i};export{n as useAdapter};
import { HfAdapterOptions, HfAdapterBuilder } from '@nlux/hf';
export { Adapter, DataTransferMode, HfAdapterBuilder, HfAdapterOptions, HfInputPreProcessor, StandardAdapter, createAdapter, llama2InputPreProcessor } from '@nlux/hf';
export { Adapter, DataTransferMode, HfAdapterBuilder, HfAdapterOptions, HfInputPreProcessor, StandardAdapter, createAdapter, llama2InputPreProcessor, llama2OutputPreProcessor } from '@nlux/hf';

@@ -4,0 +4,0 @@ declare const useAdapter: (options: HfAdapterOptions) => HfAdapterBuilder;

{
"name": "@nlux/hf-react",
"version": "0.5.3",
"version": "0.5.4",
"description": "The Hugging Face adapters for NLUX React, the React JS library for building conversational AI interfaces.",

@@ -55,3 +55,3 @@ "keywords": [

"dependencies": {
"@nlux/hf": "0.5.3"
"@nlux/hf": "0.5.4"
},

@@ -58,0 +58,0 @@ "peerDependencies": {

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@nlux/hf"),require("react"),require("@nlux/nlux")):"function"==typeof define&&define.amd?define(["exports","@nlux/hf","react","@nlux/nlux"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/hf-react"]={},e.hf,e.react,e.nlux)}(this,(function(e,r,t,o){"use strict";const n="hooks/initHfAdapter";Object.defineProperty(e,"createAdapter",{enumerable:!0,get:function(){return r.createAdapter}}),Object.defineProperty(e,"llama2InputPreProcessor",{enumerable:!0,get:function(){return r.llama2InputPreProcessor}}),e.useAdapter=e=>{if(!e.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[s,a]=t.useState(!1),[u]=t.useState((e=>{const{model:t,authToken:s,dataTransferMode:a,inputPreProcessor:u,maxNewTokens:i,systemMessage:d}=e||{};if(a&&"stream"!==a&&"fetch"!==a)throw new o.NluxUsageError({source:n,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===t)throw new o.NluxUsageError({source:n,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let f=r.createAdapter().withModel(t);return void 0!==s&&(f=f.withAuthToken(s)),void 0!==a&&(f=f.withDataTransferMode(a)),void 0!==u&&(f=f.withInputPreProcessor(u)),void 0!==d&&(f=f.withSystemMessage(d)),void 0!==i&&(f=f.withMaxNewTokens(i)),f})(e)),{authToken:i,dataTransferMode:d,model:f,systemMessage:c,inputPreProcessor:l,maxNewTokens:h}=e||{};return t.useEffect((()=>{s||a(!0)}),[i,d,f,c,l,h]),u}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/hf"),require("react"),require("@nlux/nlux")):"function"==typeof define&&define.amd?define(["exports","@nlux/hf","react","@nlux/nlux"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/hf-react"]={},e.hf,e.react,e.nlux)}(this,(function(e,t,r,o){"use strict";const n="hooks/initHfAdapter";Object.defineProperty(e,"createAdapter",{enumerable:!0,get:function(){return t.createAdapter}}),Object.defineProperty(e,"llama2InputPreProcessor",{enumerable:!0,get:function(){return t.llama2InputPreProcessor}}),Object.defineProperty(e,"llama2OutputPreProcessor",{enumerable:!0,get:function(){return t.llama2OutputPreProcessor}}),e.useAdapter=e=>{if(!e.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[s,u]=r.useState(!1),[a]=r.useState((e=>{const{model:r,authToken:s,dataTransferMode:u,preProcessors:a,maxNewTokens:i,systemMessage:c}=e||{};if(u&&"stream"!==u&&"fetch"!==u)throw new o.NluxUsageError({source:n,message:'Data transfer mode for Hugging Face Inference API must be either "stream" or "fetch"'});if(void 0===r)throw new o.NluxUsageError({source:n,message:"You must provide either a model or an endpoint to use Hugging Face Inference API."});let d=t.createAdapter().withModel(r);return void 0!==s&&(d=d.withAuthToken(s)),void 0!==u&&(d=d.withDataTransferMode(u)),void 0!==a?.input&&(d=d.withInputPreProcessor(a?.input)),void 0!==a?.output&&(d=d.withOutputPreProcessor(a?.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:l,output:p}={},maxNewTokens:m}=e||{};return r.useEffect((()=>{s||u(!0)}),[i,c,d,f,l,p,m]),a}}));