diff --git a/lib/huggingface/utils/audio.js b/lib/huggingface/utils/audio.js index 34d0597..7d07375 100644 --- a/lib/huggingface/utils/audio.js +++ b/lib/huggingface/utils/audio.js @@ -5,10 +5,7 @@ const { DEFAULT_MODELS } = require('../config.json'); const defaultModels = DEFAULT_MODELS.audio; -//......Audio....... - const audio = (hf) => ({ - // data = readFileSync('test/sample1.flac') async automaticSpeechRecognition( data, @@ -20,20 +17,14 @@ const audio = (hf) => ({ }, // data = readFileSync('test/sample1.flac') - async audioClassification( - data, - model = defaultModels.audioClassification, - ) { + async audioClassification(data, model = defaultModels.audioClassification) { const args = { data, model }; const res = await callAPI(hf, 'hf.audioClassification', args); return res; }, // inputs = 'Hello world!' - async textToSpeech( - inputs, - model = defaultModels.textToSpeech, - ) { + async textToSpeech(inputs, model = defaultModels.textToSpeech) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.textToSpeech', args); return res; @@ -44,7 +35,7 @@ const audio = (hf) => ({ const args = { data, model }; const res = await callAPI(hf, 'hf.audioToAudio', args); return res; - } + }, }); module.exports = { audio }; diff --git a/lib/huggingface/utils/computerVision.js b/lib/huggingface/utils/computerVision.js index 63655ad..97c7db7 100644 --- a/lib/huggingface/utils/computerVision.js +++ b/lib/huggingface/utils/computerVision.js @@ -5,14 +5,9 @@ const { DEFAULT_MODELS } = require('../config.json'); const defaultModels = DEFAULT_MODELS.computerVision; -//......ComputerVision....... - const computerVision = (hf) => ({ // data = readFileSync('test/cheetah.png') - async imageClassification( - data, - model = defaultModels.imageClassification, - ) { + async imageClassification(data, model = defaultModels.imageClassification) { const args = { data, model }; const res = await callAPI(hf, 'hf.imageClassification', args); return res; @@ -28,20 +23,14 @@ const computerVision = (hf) => ({ }, // data = readFileSync('test/cats.png') - async imageSegmentation( - data, - model = defaultModels.imageSegmentation, - ) { + async imageSegmentation(data, model = defaultModels.imageSegmentation) { const args = { data, model }; const res = await callAPI(hf, 'hf.imageSegmentation', args); return res; }, // data = await (await fetch('https://picsum.photos/300/300')).blob() - async imageToText( - data, - model = defaultModels.imageToText, - ) { + async imageToText(data, model = defaultModels.imageToText) { const args = { data, model }; const res = await callAPI(hf, 'hf.imageToText', args); return res; diff --git a/lib/huggingface/utils/custom.js b/lib/huggingface/utils/custom.js index 95dc5d5..831900d 100644 --- a/lib/huggingface/utils/custom.js +++ b/lib/huggingface/utils/custom.js @@ -2,8 +2,6 @@ const { callAPI } = require('../../common.js'); -//......Custom....... - const custom = (hf) => ({ /* inputs = "hello world", @@ -11,11 +9,7 @@ const custom = (hf) => ({ custom_param: 'some magic', } */ - async customCall( - inputs, - parameters = {}, - model, - ) { + async customCall(inputs, parameters = {}, model) { const args = { inputs, parameters, model }; const res = await callAPI(hf, 'hf.request', args); return res; @@ -27,11 +21,7 @@ const custom = (hf) => ({ custom_param: 'some magic', } */ - async customCallStreaming( - inputs, - parameters = {}, - model, - ) { + async customCallStreaming(inputs, parameters = {}, model) { const args = { inputs, parameters, model }; return callAPI(hf, 'hf.streamingRequest', args); }, @@ -51,9 +41,10 @@ const custom = (hf) => ({ 'Error occured while triggering "textGeneration" method', { cause: err, - }); + }, + ); } - } + }, }); module.exports = { custom }; diff --git a/lib/huggingface/utils/language.js b/lib/huggingface/utils/language.js index d6340dc..ba5e21d 100644 --- a/lib/huggingface/utils/language.js +++ b/lib/huggingface/utils/language.js @@ -5,8 +5,6 @@ const { DEFAULT_MODELS } = require('../config.json'); const defaultModels = DEFAULT_MODELS.language; -//......Natural Language Processing (language)....... - const language = (hf) => ({ // inputs = '[MASK] world!' async fillMask(inputs, model = defaultModels.fillMask) { @@ -39,10 +37,7 @@ const language = (hf) => ({ context: 'The capital of France is Paris.' }, */ - async questionAnswering( - inputs, - model = defaultModels.questionAnswering, - ) { + async questionAnswering(inputs, model = defaultModels.questionAnswering) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.questionAnswering', args); return res; @@ -69,10 +64,7 @@ const language = (hf) => ({ }, // inputs = 'I like you. I love you.' - async textClassification( - inputs, - model = defaultModels.textClassification, - ) { + async textClassification(inputs, model = defaultModels.textClassification) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.textClassification', args); return res; @@ -98,10 +90,7 @@ const language = (hf) => ({ }, // inputs = 'My name is Sarah Jessica Parker but you can call me Jessica' - async tokenClassification( - inputs, - model = defaultModels.tokenClassification, - ) { + async tokenClassification(inputs, model = defaultModels.tokenClassification) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.tokenClassification', args); return res; @@ -110,7 +99,9 @@ const language = (hf) => ({ // inputs = 'My name is Wolfgang and I live in Amsterdam', // parameters = {"src_lang": "en_XX", "tgt_lang": "fr_XX"} async translation( - inputs, parameters = {}, model = defaultModels.translation + inputs, + parameters = {}, + model = defaultModels.translation, ) { const args = { inputs, parameters, model }; const res = await callAPI(hf, 'hf.translation', args); @@ -145,14 +136,11 @@ const language = (hf) => ({ } */ - async sentenceSimilarity( - inputs, - model = defaultModels.sentenceSimilarity, - ) { + async sentenceSimilarity(inputs, model = defaultModels.sentenceSimilarity) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.sentenceSimilarity', args); return res; - } + }, }); module.exports = { language }; diff --git a/lib/huggingface/utils/multimodal.js b/lib/huggingface/utils/multimodal.js index cd94e86..6661493 100644 --- a/lib/huggingface/utils/multimodal.js +++ b/lib/huggingface/utils/multimodal.js @@ -5,15 +5,9 @@ const { DEFAULT_MODELS } = require('../config.json'); const defaultModels = DEFAULT_MODELS.multimodal; -//......Multimodal....... - const multimodal = (hf) => ({ - // inputs = "That is a happy person", - async featureExtraction( - inputs, - model = defaultModels.featureExtraction, - ) { + async featureExtraction(inputs, model = defaultModels.featureExtraction) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.featureExtraction', args); return res; @@ -47,7 +41,7 @@ const multimodal = (hf) => ({ const args = { inputs, model }; const res = await callAPI(hf, 'hf.documentQuestionAnswering', args); return res; - } + }, }); module.exports = { multimodal }; diff --git a/lib/huggingface/utils/tabular.js b/lib/huggingface/utils/tabular.js index a4f13ef..1992101 100644 --- a/lib/huggingface/utils/tabular.js +++ b/lib/huggingface/utils/tabular.js @@ -5,8 +5,6 @@ const { DEFAULT_MODELS } = require('../config.json'); const defaultModels = DEFAULT_MODELS.tabular; -//......Tabular....... - const tabular = (hf) => ({ /* inputs = { @@ -20,10 +18,7 @@ const tabular = (hf) => ({ }, }, */ - async tabularRegression( - inputs, - model = defaultModels.tabularRegression, - ) { + async tabularRegression(inputs, model = defaultModels.tabularRegression) { const args = { inputs, model }; const res = await callAPI(hf, 'hf.tabularRegression', args); return res; @@ -53,7 +48,7 @@ const tabular = (hf) => ({ const args = { inputs, model }; const res = await callAPI(hf, 'hf.tabularClassification', args); return res; - } + }, }); module.exports = { tabular }; diff --git a/test/huggingface/audio.js b/test/huggingface/audio.js index 5ce7bfe..714cf72 100644 --- a/test/huggingface/audio.js +++ b/test/huggingface/audio.js @@ -12,9 +12,7 @@ const { Chat } = huggingface; const API_KEY = process.env.HUGGINGFACE_API_KEY; -const { - audio: uAudio, -} = utils; +const { audio: uAudio } = utils; const FILES = process.cwd() + '/files/huggingface/'; const AUDIOS = FILES + 'audios'; diff --git a/test/huggingface/computerVision.js b/test/huggingface/computerVision.js index 50ed7f1..3ee6587 100644 --- a/test/huggingface/computerVision.js +++ b/test/huggingface/computerVision.js @@ -12,9 +12,7 @@ const { Chat } = huggingface; const API_KEY = process.env.HUGGINGFACE_API_KEY; -const { - computerVision: uComputerVision, -} = utils; +const { computerVision: uComputerVision } = utils; const FILES = process.cwd() + '/files/huggingface/'; const IMAGES = FILES + 'images'; @@ -91,10 +89,10 @@ describe('computerVision', () => { it('textToImage', async () => { const inputs = - 'award winning high resolution photo of a giant tortoise' + - '/((ladybird)) hybrid, [trending on artstation]'; + 'award winning high resolution photo of a giant tortoise' + + '/((ladybird)) hybrid, [trending on artstation]'; const res = await computerVision.textToImage(inputs, { - negative_prompt: 'blurry' + negative_prompt: 'blurry', }); assert.ok(res instanceof Blob); diff --git a/test/huggingface/custom.js b/test/huggingface/custom.js index 82f170a..992aca4 100644 --- a/test/huggingface/custom.js +++ b/test/huggingface/custom.js @@ -10,9 +10,7 @@ const { Chat } = huggingface; const API_KEY = process.env.HUGGINGFACE_API_KEY; -const { - custom: uCustom, -} = utils; +const { custom: uCustom } = utils; describe('custom', () => { let custom; diff --git a/test/huggingface/language.js b/test/huggingface/language.js index 8e8b168..017eaec 100644 --- a/test/huggingface/language.js +++ b/test/huggingface/language.js @@ -10,9 +10,7 @@ const { Chat } = huggingface; const API_KEY = process.env.HUGGINGFACE_API_KEY; -const { - language: uLanguage, -} = utils; +const { language: uLanguage } = utils; describe('language', () => { let language; diff --git a/test/huggingface/multimodal.js b/test/huggingface/multimodal.js index 85212dc..74034e5 100644 --- a/test/huggingface/multimodal.js +++ b/test/huggingface/multimodal.js @@ -12,9 +12,7 @@ const { Chat } = huggingface; const API_KEY = process.env.HUGGINGFACE_API_KEY; -const { - multimodal: uMultimodal, -} = utils; +const { multimodal: uMultimodal } = utils; const FILES = process.cwd() + '/files/huggingface/'; const IMAGES = FILES + 'images'; diff --git a/test/huggingface/tabular.js b/test/huggingface/tabular.js index f5110b0..0a65bf9 100644 --- a/test/huggingface/tabular.js +++ b/test/huggingface/tabular.js @@ -9,9 +9,7 @@ const { Chat } = huggingface; const API_KEY = process.env.HUGGINGFACE_API_KEY; -const { - tabular: uTabular, -} = utils; +const { tabular: uTabular } = utils; describe('tabular', () => { let tabular;