forked from nano-react-app/template-js
-
Notifications
You must be signed in to change notification settings - Fork 14
/
hf.js
29 lines (23 loc) · 724 Bytes
/
hf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { HfInference } from "@huggingface/inference";
const { HUGGINGFACEHUB_API_KEY } = process.env;
class HuggingFaceService {
constructor () {
this.modelName = 'microsoft/DialoGPT-large';
this.model = new HfInference(HUGGINGFACEHUB_API_KEY);
}
ingestFile() {
console.log('this is not implemented for HuggingFace yet');
}
async call(userInput) {
// TO DO: pass in past_user_inputs for context
const response = await this.model.conversational({
model: this.modelName,
temperature: 0,
inputs: {
text: userInput,
}
});
return { response: response && response.generated_text };
}
}
export { HuggingFaceService }