Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
-
import
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
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 |
-
)
|
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 |
+
}
|