I want to use an npm package but it doesnt work at all. I tried to do a prealod, i tried other things but it just doesnt work. How do i fix this?
Here is code for reference:
preload.js
const { contextBridge, ipcRenderer } = require("electron");
const fs = require("fs");
const path = require("path");
const { HfInference } = window.require('@huggingface/inference');
// Initialize HfInference instance
const hf = new HfInference('xxx');
// Expose everything via contextBridge
contextBridge.exposeInMainWorld("electronAPI", {
hfInference: hf
});
aiController.js
const client = window.electronAPI.hfInference;
...
const chatCompletion = await client.chatCompletion({
model: "mistralai/Mistral-Nemo-Instruct-2407",
messages: conversationHistory, // Send the updated conversation history
max_tokens: 500
});
The error is
aiController.js:37 Uncaught (in promise) TypeError: client.chatCompletion is not a function
at sendCodeForReview (aiController.js:37:41)
at bugPanelController.js:21:26
at Array.forEach (<anonymous>)
at loadFiles (bugPanelController.js:20:11)
at HTMLButtonElement.<anonymous> (bugPanelController.js:13:9)