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 0.12.2 to 1.0.0

2

cjs/hf-react.js

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

"use strict";var e=require("@nlux/hf"),r=require("react"),t=require("@nlux/react");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[a,n]=r.useState(!1),[u]=r.useState((r=>{const{model:s,authToken:a,dataTransferMode:n,preProcessors:u,maxNewTokens:i,systemMessage:c}=r||{};if(n&&"stream"!==n&&"fetch"!==n)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!==a&&(d=d.withAuthToken(a)),void 0!==n&&(d=d.withDataTransferMode(n)),void 0!==u?.input&&(d=d.withInputPreProcessor(u?.input)),void 0!==u?.output&&(d=d.withOutputPreProcessor(u?.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((()=>{a||n(!0)}),[i,c,d,p,m,f,l]),u};
"use strict";var e=require("@nlux/hf"),r=require("react"),t=require("@nlux/react");const o="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=s=>{if(!s.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[a,n]=r.useState(!1),[u]=r.useState((r=>{const{model:s,authToken:a,dataTransferMode:n,preProcessors:u,maxNewTokens:i,systemMessage:c}=r||{};if(n&&"stream"!==n&&"fetch"!==n)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.createChatAdapter().withModel(s);return void 0!==a&&(d=d.withAuthToken(a)),void 0!==n&&(d=d.withDataTransferMode(n)),void 0!==u?.input&&(d=d.withInputPreProcessor(u?.input)),void 0!==u?.output&&(d=d.withOutputPreProcessor(u?.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:h,output:m}={},maxNewTokens:f}=s||{};return r.useEffect((()=>{a||n(!0)}),[i,c,d,p,h,m,f]),u};

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

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/react";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),[u]=o((o=>{const{model:t,authToken:n,dataTransferMode:a,preProcessors:i,maxNewTokens:u,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!==i?.input&&(d=d.withInputPreProcessor(i?.input)),void 0!==i?.output&&(d=d.withOutputPreProcessor(i?.output)),void 0!==m&&(d=d.withSystemMessage(m)),void 0!==u&&(d=d.withMaxNewTokens(u)),d})(n)),{authToken:m,dataTransferMode:d,model:p,systemMessage:c,preProcessors:{input:h,output:f}={},maxNewTokens:w}=n||{};return t((()=>{a||i(!0)}),[m,d,p,c,h,f,w]),u};export{n as useAdapter};
import{createChatAdapter as e}from"@nlux/hf";export{createChatAdapter,llama2InputPreProcessor,llama2OutputPreProcessor}from"@nlux/hf";import{useState as o,useEffect as t}from"react";import{NluxUsageError as r}from"@nlux/react";const s="hooks/initChatAdapter",a=a=>{if(!a.model)throw new Error("You must provide either a model or an endpoint to use Hugging Face Inference API.");const[n,i]=o(!1),[u]=o((o=>{const{model:t,authToken:a,dataTransferMode:n,preProcessors:i,maxNewTokens:u,systemMessage:m}=o||{};if(n&&"stream"!==n&&"fetch"!==n)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!==a&&(d=d.withAuthToken(a)),void 0!==n&&(d=d.withDataTransferMode(n)),void 0!==i?.input&&(d=d.withInputPreProcessor(i?.input)),void 0!==i?.output&&(d=d.withOutputPreProcessor(i?.output)),void 0!==m&&(d=d.withSystemMessage(m)),void 0!==u&&(d=d.withMaxNewTokens(u)),d})(a)),{authToken:m,dataTransferMode:d,model:h,systemMessage:p,preProcessors:{input:c,output:f}={},maxNewTokens:w}=a||{};return t((()=>{n||i(!0)}),[m,d,h,p,c,f,w]),u};export{a as useChatAdapter};

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

import { HfAdapterOptions, HfAdapterBuilder } from '@nlux/hf';
export { Adapter, DataTransferMode, HfAdapterBuilder, HfAdapterOptions, HfInputPreProcessor, StandardAdapter, createAdapter, llama2InputPreProcessor, llama2OutputPreProcessor } from '@nlux/hf';
import { ChatAdapterOptions, ChatAdapterBuilder } from '@nlux/hf';
export { ChatAdapter, ChatAdapterBuilder, ChatAdapterOptions, DataTransferMode, HfInputPreProcessor, StandardChatAdapter, StreamingAdapterObserver, createChatAdapter, llama2InputPreProcessor, llama2OutputPreProcessor } from '@nlux/hf';
declare const useAdapter: (options: HfAdapterOptions) => HfAdapterBuilder;
declare const useChatAdapter: (options: ChatAdapterOptions) => ChatAdapterBuilder;
export { useAdapter };
export { useChatAdapter };
{
"name": "@nlux/hf-react",
"version": "0.12.2",
"version": "1.0.0",
"description": "The Hugging Face adapters for nlux React, the React JS library for building conversational AI interfaces.",

@@ -14,2 +14,5 @@ "keywords": [

"ai-bot",
"ai-assistant",
"ai-copilot",
"copilot",
"chat-gpt",

@@ -60,6 +63,6 @@ "openai",

"dependencies": {
"@nlux/hf": "0.12.2"
"@nlux/hf": "1.0.0"
},
"peerDependencies": {
"@nlux/react": "0.12.2",
"@nlux/react": "1.0.0",
"react": "^18.2.0"

@@ -66,0 +69,0 @@ },

@@ -27,3 +27,3 @@ # nlux React Hugging Face Adapter

* **Build AI Chat Interfaces In Minutes** ― High quality conversational AI interfaces with just a few lines of code.
* **React Components & Hooks** ― `<AiChat />` for UI and `useAdapter` hook for easy integration.
* **React Components & Hooks** ― `<AiChat />` for UI and `useChatAdapter` hook for easy integration.
* **LLM Adapters** ― For `ChatGPT` / `LangChain` 🦜 LangServe / `HuggingFace` 🤗 Inference.

@@ -30,0 +30,0 @@ * A flexible interface to **Create Your Own Adapter** for any LLM or API.

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/hf"),require("react"),require("@nlux/react")):"function"==typeof define&&define.amd?define(["exports","@nlux/hf","react","@nlux/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/hf-react"]={},e.hf,e.react$1,e.react)}(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:p,output:l}={},maxNewTokens:m}=e||{};return r.useEffect((()=>{s||u(!0)}),[i,c,d,f,p,l,m]),a}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/hf"),require("react"),require("@nlux/react")):"function"==typeof define&&define.amd?define(["exports","@nlux/hf","react","@nlux/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/hf-react"]={},e.hf,e.react$1,e.react)}(this,(function(e,t,r,o){"use strict";const n="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[a,s]=r.useState(!1),[u]=r.useState((e=>{const{model:r,authToken:a,dataTransferMode:s,preProcessors:u,maxNewTokens:i,systemMessage:c}=e||{};if(s&&"stream"!==s&&"fetch"!==s)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.createChatAdapter().withModel(r);return void 0!==a&&(d=d.withAuthToken(a)),void 0!==s&&(d=d.withDataTransferMode(s)),void 0!==u?.input&&(d=d.withInputPreProcessor(u?.input)),void 0!==u?.output&&(d=d.withOutputPreProcessor(u?.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((()=>{a||s(!0)}),[i,c,d,f,p,h,l]),u}}));
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