Skip to content

Commit e8e5fa6

Browse files
committed
Example of use
1 parent 7460a2b commit e8e5fa6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { chatCompletionStream } from "@huggingface/inference";
2+
3+
async function main() {
4+
const endpointUrl = `http://localhost:9999/v1/chat/completions`;
5+
// launch "tiny-agents serve" before running this
6+
7+
for await (const chunk of chatCompletionStream({
8+
endpointUrl,
9+
model: "",
10+
messages: [{ role: "user", content: "What are the top 5 trending models on Hugging Face?" }],
11+
})) {
12+
console.log(chunk.choices[0]?.delta.content);
13+
}
14+
}
15+
16+
if (require.main === module) {
17+
main();
18+
}

0 commit comments

Comments
 (0)