FECUOY commited on
Commit
ae5de09
·
verified ·
1 Parent(s): 63957d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -18
app.py CHANGED
@@ -1,23 +1,18 @@
1
- import { InferenceClient } from "@huggingface/inference";
 
2
 
3
- const client = new InferenceClient(process.env.HF_TOKEN);
 
 
4
 
5
- let out = "";
6
-
7
- const stream = client.chatCompletionStream({
8
- model: "moonshotai/Kimi-K2-Instruct-0905",
9
- messages: [
10
  {
11
- role: "user",
12
- content: "What is the capital of France?",
13
- },
14
  ],
15
- });
16
 
17
- for await (const chunk of stream) {
18
- if (chunk.choices && chunk.choices.length > 0) {
19
- const newContent = chunk.choices[0].delta.content;
20
- out += newContent;
21
- console.log(newContent);
22
- }
23
- }
 
1
+ import os
2
+ from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient(
5
+ api_key=os.environ["HF_TOKEN"],
6
+ )
7
 
8
+ completion = client.chat.completions.create(
9
+ model="moonshotai/Kimi-K2-Instruct-0905:groq",
10
+ messages=[
 
 
11
  {
12
+ "role": "user",
13
+ "content": "What is the capital of France?"
14
+ }
15
  ],
16
+ )
17
 
18
+ print(completion.choices[0].message)