-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
11 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,5 @@ | ||
import { HfInference } from '@huggingface/inference'; | ||
|
||
export class HuggingFaceService { | ||
private static async _infer(input: string, token: string) { | ||
const client = new HfInference(token); | ||
|
||
try { | ||
const chatCompletion = await client.chatCompletion({ | ||
model: 'meta-llama/Llama-2-7b-chat-hf', | ||
messages: [ | ||
{ | ||
role: 'system', | ||
content: | ||
'You will be given text content from a social media' + | ||
' post, and your task is to explain it in English.', | ||
}, | ||
{ | ||
role: 'user', | ||
content: input, | ||
}, | ||
|
||
{ | ||
role: 'user', | ||
content: 'What is the capital of France?', | ||
}, | ||
], | ||
max_tokens: 500, | ||
}); | ||
console.log(chatCompletion.choices[0].message); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
static async inferServerless(input: string): Promise<string | null> { | ||
return this._infer(input, 'N/A'); | ||
} | ||
|
||
static async inferDedicated(input: string): Promise<string | null> { | ||
return this._infer(input, 'N/A'); | ||
export class OpenAiService { | ||
static async explain(input: string) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters