
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
huggingface-chat
Advanced tools
A lightweight and powerful Node.js API client for Hugging Face Chat. Interact with open-source LLMs like Llama 3, Mixtral, and Gemma for conversational AI, text generation, and more. Supports ESM and CJS modules.
Deprecation Notice
The versions 2.x and lower are deprecated please use latest.
A simple api for hugging face chat with login caching.
Current stable release (4.x)
Added tools support 🎉
npm i huggingface-chat
import { Login ,ChatBot} from "huggingface-chat";
const EMAIL = "email"
const PASSWD = "password"
const cachePath = "./login_cache/"
const signin = new Login(EMAIL, PASSWD)
const res = await signin.login(cachePath) // default path is ./login_cache/
const chat = new ChatBot(res) // res is cookies which is required for subsequent aip calls
await chat.intialize()
const models = chat.listAvilableModels()
console.log(models)
const sessons = chat.listAvilableSesson()
console.log(sessons)
// more info : https://huggingface.co/chat/models
let currentModel = chat.showCurrentModel()
console.log(currentModel)
chat.switchModel("microsoft/Phi-3.5-mini-instruct")
currentModel = chat.showCurrentModel()
console.log(currentModel)
const currentChat = await chat.getNewChat("you are a drunk person") // optional if you want to set a system prompt
console.log(currentChat)
const tools = await chat.getToolList("1") // for the sake of not overloading the api the tools need to be called when needed also pass the page number more info : https://huggingface.co/chat/tools
console.log(tools)
let data = await chat.chat("take screenshoot of this website : google.com", undefined, {
tools:["000000000000000000000001","66e99753cb638fb7e2342da5"], // pass the tools id tools[0].id
rawResponse:true
});
let reader = data.stream.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) break; // The streaming has ended.
process.stdout.write(value)
}
data = await chat.chat("what is my name");
let response = await data.completeResponsePromise() //non streaming response
console.log(response)
data = await chat.chat("what is my name", sessons[0].id); // using existing sessons
response = await data.completeResponsePromise()
console.log(response)
Note: Supported in node 18.x and higher.
Note: In case the package stops working there is most likely a change in hugging face api, if possible please report it and update the package to latest if available.
Full API documentations of both classes can be found here Chat Login
FAQs
A lightweight and powerful Node.js API client for Hugging Face Chat. Interact with open-source LLMs like Llama 3, Mixtral, and Gemma for conversational AI, text generation, and more. Supports ESM and CJS modules.
The npm package huggingface-chat receives a total of 13 weekly downloads. As such, huggingface-chat popularity was classified as not popular.
We found that huggingface-chat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.