zhaozengxi commited on
Commit
108174a
·
verified ·
1 Parent(s): 7ec33b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -1,9 +1,11 @@
1
- import gradio as gr
2
 
3
- gr.load(
4
- "models/Qwen/Qwen3-235B-A22B",
5
- provider="hf-inference",
6
- messages: [
 
 
7
  {
8
  role: "user",
9
  content: "你是谁?",
@@ -17,6 +19,12 @@ gr.load(
17
  max_tokens: 50000,
18
  top_p: 0.6,
19
  response_format: undefined
20
- ).launch()
21
-
22
 
 
 
 
 
 
 
 
 
1
+ import { InferenceClient } from "@huggingface/inference";
2
 
3
+ let out = "";
4
+
5
+ const stream = client.chatCompletionStream({
6
+ provider: "hf-inference",
7
+ model: "Qwen/Qwen3-235B-A22B",
8
+ messages: [
9
  {
10
  role: "user",
11
  content: "你是谁?",
 
19
  max_tokens: 50000,
20
  top_p: 0.6,
21
  response_format: undefined
22
+ });
 
23
 
24
+ for await (const chunk of stream) {
25
+ if (chunk.choices && chunk.choices.length > 0) {
26
+ const newContent = chunk.choices[0].delta.content;
27
+ out += newContent;
28
+ console.log(newContent);
29
+ }
30
+ }